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/debug/trace_event_argument.h"
8 #include "base/values.h"
9 #include "cc/base/math_util.h"
10 #include "cc/debug/traced_value.h"
11 #include "third_party/skia/include/core/SkImageFilter.h"
15 RenderPassDrawQuad::RenderPassDrawQuad()
16 : render_pass_id(RenderPassId(-1, -1)),
17 mask_resource_id(static_cast<ResourceProvider::ResourceId
>(-1)) {
20 RenderPassDrawQuad::~RenderPassDrawQuad() {
23 void RenderPassDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
24 const gfx::Rect
& rect
,
25 const gfx::Rect
& visible_rect
,
26 RenderPassId render_pass_id
,
27 ResourceProvider::ResourceId mask_resource_id
,
28 const gfx::RectF
& mask_uv_rect
,
29 const FilterOperations
& filters
,
30 const gfx::Vector2dF
& filters_scale
,
31 const FilterOperations
& background_filters
) {
32 DCHECK_GT(render_pass_id
.layer_id
, 0);
33 DCHECK_GE(render_pass_id
.index
, 0);
35 gfx::Rect opaque_rect
;
36 bool needs_blending
= false;
37 SetAll(shared_quad_state
,
50 void RenderPassDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
51 const gfx::Rect
& rect
,
52 const gfx::Rect
& opaque_rect
,
53 const gfx::Rect
& visible_rect
,
55 RenderPassId render_pass_id
,
56 ResourceProvider::ResourceId mask_resource_id
,
57 const gfx::RectF
& mask_uv_rect
,
58 const FilterOperations
& filters
,
59 const gfx::Vector2dF
& filters_scale
,
60 const FilterOperations
& background_filters
) {
61 DCHECK_GT(render_pass_id
.layer_id
, 0);
62 DCHECK_GE(render_pass_id
.index
, 0);
64 DrawQuad::SetAll(shared_quad_state
, DrawQuad::RENDER_PASS
, rect
, opaque_rect
,
65 visible_rect
, needs_blending
);
66 this->render_pass_id
= render_pass_id
;
67 this->mask_resource_id
= mask_resource_id
;
68 this->mask_uv_rect
= mask_uv_rect
;
69 this->filters
= filters
;
70 this->filters_scale
= filters_scale
;
71 this->background_filters
= background_filters
;
74 void RenderPassDrawQuad::IterateResources(
75 const ResourceIteratorCallback
& callback
) {
77 mask_resource_id
= callback
.Run(mask_resource_id
);
80 const RenderPassDrawQuad
* RenderPassDrawQuad::MaterialCast(
81 const DrawQuad
* quad
) {
82 DCHECK_EQ(quad
->material
, DrawQuad::RENDER_PASS
);
83 return static_cast<const RenderPassDrawQuad
*>(quad
);
86 void RenderPassDrawQuad::ExtendValue(base::debug::TracedValue
* value
) const {
87 TracedValue::SetIDRef(render_pass_id
.AsTracingId(), value
, "render_pass_id");
88 value
->SetInteger("mask_resource_id", mask_resource_id
);
90 value
->BeginArray("mask_uv_rect");
91 MathUtil::AddToTracedValue(mask_uv_rect
, value
);
94 value
->BeginDictionary("filters");
95 filters
.AsValueInto(value
);
96 value
->EndDictionary();
98 value
->BeginArray("filters_scale");
99 MathUtil::AddToTracedValue(filters_scale
, value
);
102 value
->BeginDictionary("background_filters");
103 background_filters
.AsValueInto(value
);
104 value
->EndDictionary();