1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/quads/render_pass_draw_quad.h"
7 #include "base/values.h"
8 #include "cc/base/math_util.h"
9 #include "cc/debug/traced_value.h"
10 #include "third_party/skia/include/core/SkImageFilter.h"
14 RenderPassDrawQuad::RenderPassDrawQuad()
15 : render_pass_id(RenderPass::Id(-1, -1)),
17 mask_resource_id(-1) {
20 RenderPassDrawQuad::~RenderPassDrawQuad() {
23 scoped_ptr
<RenderPassDrawQuad
> RenderPassDrawQuad::Create() {
24 return make_scoped_ptr(new RenderPassDrawQuad
);
27 scoped_ptr
<RenderPassDrawQuad
> RenderPassDrawQuad::Copy(
28 const SharedQuadState
* copied_shared_quad_state
,
29 RenderPass::Id copied_render_pass_id
) const {
30 scoped_ptr
<RenderPassDrawQuad
> copy_quad(
31 new RenderPassDrawQuad(*MaterialCast(this)));
32 copy_quad
->shared_quad_state
= copied_shared_quad_state
;
33 copy_quad
->render_pass_id
= copied_render_pass_id
;
34 return copy_quad
.Pass();
37 void RenderPassDrawQuad::SetNew(
38 const SharedQuadState
* shared_quad_state
,
39 const gfx::Rect
& rect
,
40 const gfx::Rect
& visible_rect
,
41 RenderPass::Id render_pass_id
,
43 ResourceProvider::ResourceId mask_resource_id
,
44 const gfx::Rect
& contents_changed_since_last_frame
,
45 const gfx::RectF
& mask_uv_rect
,
46 const FilterOperations
& filters
,
47 const FilterOperations
& background_filters
) {
48 DCHECK_GT(render_pass_id
.layer_id
, 0);
49 DCHECK_GE(render_pass_id
.index
, 0);
51 gfx::Rect opaque_rect
;
52 bool needs_blending
= false;
53 SetAll(shared_quad_state
, rect
, opaque_rect
, visible_rect
, needs_blending
,
54 render_pass_id
, is_replica
, mask_resource_id
,
55 contents_changed_since_last_frame
, mask_uv_rect
, filters
,
59 void RenderPassDrawQuad::SetAll(
60 const SharedQuadState
* shared_quad_state
,
61 const gfx::Rect
& rect
,
62 const gfx::Rect
& opaque_rect
,
63 const gfx::Rect
& visible_rect
,
65 RenderPass::Id render_pass_id
,
67 ResourceProvider::ResourceId mask_resource_id
,
68 const gfx::Rect
& contents_changed_since_last_frame
,
69 const gfx::RectF
& mask_uv_rect
,
70 const FilterOperations
& filters
,
71 const FilterOperations
& background_filters
) {
72 DCHECK_GT(render_pass_id
.layer_id
, 0);
73 DCHECK_GE(render_pass_id
.index
, 0);
75 DrawQuad::SetAll(shared_quad_state
, DrawQuad::RENDER_PASS
, rect
, opaque_rect
,
76 visible_rect
, needs_blending
);
77 this->render_pass_id
= render_pass_id
;
78 this->is_replica
= is_replica
;
79 this->mask_resource_id
= mask_resource_id
;
80 this->contents_changed_since_last_frame
= contents_changed_since_last_frame
;
81 this->mask_uv_rect
= mask_uv_rect
;
82 this->filters
= filters
;
83 this->background_filters
= background_filters
;
86 void RenderPassDrawQuad::IterateResources(
87 const ResourceIteratorCallback
& callback
) {
89 mask_resource_id
= callback
.Run(mask_resource_id
);
92 const RenderPassDrawQuad
* RenderPassDrawQuad::MaterialCast(
93 const DrawQuad
* quad
) {
94 DCHECK_EQ(quad
->material
, DrawQuad::RENDER_PASS
);
95 return static_cast<const RenderPassDrawQuad
*>(quad
);
98 void RenderPassDrawQuad::ExtendValue(base::DictionaryValue
* value
) const {
99 value
->Set("render_pass_id",
100 TracedValue::CreateIDRef(render_pass_id
.AsTracingId()).release());
101 value
->SetBoolean("is_replica", is_replica
);
102 value
->SetInteger("mask_resource_id", mask_resource_id
);
103 value
->Set("contents_changed_since_last_frame",
104 MathUtil::AsValue(contents_changed_since_last_frame
).release());
105 value
->Set("mask_uv_rect", MathUtil::AsValue(mask_uv_rect
).release());
106 value
->Set("filters", filters
.AsValue().release());
107 value
->Set("background_filters", background_filters
.AsValue().release());