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"
9 RenderPassDrawQuad::RenderPassDrawQuad()
10 : render_pass_id(RenderPass::Id(-1, -1)),
12 mask_resource_id(-1) {
15 RenderPassDrawQuad::~RenderPassDrawQuad() {
18 scoped_ptr
<RenderPassDrawQuad
> RenderPassDrawQuad::Create() {
19 return make_scoped_ptr(new RenderPassDrawQuad
);
22 scoped_ptr
<RenderPassDrawQuad
> RenderPassDrawQuad::Copy(
23 const SharedQuadState
* copied_shared_quad_state
,
24 RenderPass::Id copied_render_pass_id
) const {
25 scoped_ptr
<RenderPassDrawQuad
> copy_quad(
26 new RenderPassDrawQuad(*MaterialCast(this)));
27 copy_quad
->shared_quad_state
= copied_shared_quad_state
;
28 copy_quad
->render_pass_id
= copied_render_pass_id
;
29 return copy_quad
.Pass();
32 void RenderPassDrawQuad::SetNew(
33 const SharedQuadState
* shared_quad_state
,
35 RenderPass::Id render_pass_id
,
37 ResourceProvider::ResourceId mask_resource_id
,
38 gfx::Rect contents_changed_since_last_frame
,
39 gfx::RectF mask_uv_rect
,
40 const WebKit::WebFilterOperations
& filters
,
41 skia::RefPtr
<SkImageFilter
> filter
,
42 const WebKit::WebFilterOperations
& background_filters
) {
43 DCHECK_GT(render_pass_id
.layer_id
, 0);
44 DCHECK_GE(render_pass_id
.index
, 0);
46 gfx::Rect opaque_rect
;
47 gfx::Rect visible_rect
= rect
;
48 bool needs_blending
= false;
49 SetAll(shared_quad_state
, rect
, opaque_rect
, visible_rect
, needs_blending
,
50 render_pass_id
, is_replica
, mask_resource_id
,
51 contents_changed_since_last_frame
, mask_uv_rect
, filters
, filter
,
55 void RenderPassDrawQuad::SetAll(
56 const SharedQuadState
* shared_quad_state
,
58 gfx::Rect opaque_rect
,
59 gfx::Rect visible_rect
,
61 RenderPass::Id render_pass_id
,
63 ResourceProvider::ResourceId mask_resource_id
,
64 gfx::Rect contents_changed_since_last_frame
,
65 gfx::RectF mask_uv_rect
,
66 const WebKit::WebFilterOperations
& filters
,
67 skia::RefPtr
<SkImageFilter
> filter
,
68 const WebKit::WebFilterOperations
& background_filters
) {
69 DCHECK_GT(render_pass_id
.layer_id
, 0);
70 DCHECK_GE(render_pass_id
.index
, 0);
72 DrawQuad::SetAll(shared_quad_state
, DrawQuad::RENDER_PASS
, rect
, opaque_rect
,
73 visible_rect
, needs_blending
);
74 this->render_pass_id
= render_pass_id
;
75 this->is_replica
= is_replica
;
76 this->mask_resource_id
= mask_resource_id
;
77 this->contents_changed_since_last_frame
= contents_changed_since_last_frame
;
78 this->mask_uv_rect
= mask_uv_rect
;
79 this->filters
= filters
;
80 this->filter
= filter
;
81 this->background_filters
= background_filters
;
84 void RenderPassDrawQuad::IterateResources(
85 const ResourceIteratorCallback
& callback
) {
87 mask_resource_id
= callback
.Run(mask_resource_id
);
90 const RenderPassDrawQuad
* RenderPassDrawQuad::MaterialCast(
91 const DrawQuad
* quad
) {
92 DCHECK_EQ(quad
->material
, DrawQuad::RENDER_PASS
);
93 return static_cast<const RenderPassDrawQuad
*>(quad
);