OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/render_pass_draw_quad.h" | 5 #include "cc/render_pass_draw_quad.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 RenderPassDrawQuad::RenderPassDrawQuad() | 9 RenderPassDrawQuad::RenderPassDrawQuad() |
10 : render_pass_id(RenderPass::Id(-1, -1)), | 10 : render_pass_id(RenderPass::Id(-1, -1)), |
11 is_replica(false), | 11 is_replica(false), |
12 mask_resource_id(-1), | 12 mask_resource_id(-1) { |
13 mask_tex_coord_scale_x(0), | |
14 mask_tex_coord_scale_y(0), | |
15 mask_tex_coord_offset_x(0), | |
16 mask_tex_coord_offset_y(0) { | |
17 } | 13 } |
18 | 14 |
19 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Create() { | 15 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Create() { |
20 return make_scoped_ptr(new RenderPassDrawQuad); | 16 return make_scoped_ptr(new RenderPassDrawQuad); |
21 } | 17 } |
22 | 18 |
23 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Copy( | 19 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Copy( |
24 const SharedQuadState* copied_shared_quad_state, | 20 const SharedQuadState* copied_shared_quad_state, |
25 RenderPass::Id copied_render_pass_id) const { | 21 RenderPass::Id copied_render_pass_id) const { |
26 scoped_ptr<RenderPassDrawQuad> copy_quad(new RenderPassDrawQuad(*MaterialCast(
this))); | 22 scoped_ptr<RenderPassDrawQuad> copy_quad(new RenderPassDrawQuad(*MaterialCast(
this))); |
27 copy_quad->shared_quad_state = copied_shared_quad_state; | 23 copy_quad->shared_quad_state = copied_shared_quad_state; |
28 copy_quad->render_pass_id = copied_render_pass_id; | 24 copy_quad->render_pass_id = copied_render_pass_id; |
29 return copy_quad.Pass(); | 25 return copy_quad.Pass(); |
30 } | 26 } |
31 | 27 |
32 void RenderPassDrawQuad::SetNew(const SharedQuadState* shared_quad_state, | 28 void RenderPassDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
33 gfx::Rect rect, | 29 gfx::Rect rect, |
34 RenderPass::Id render_pass_id, | 30 RenderPass::Id render_pass_id, |
35 bool is_replica, | 31 bool is_replica, |
36 ResourceProvider::ResourceId mask_resource_id, | 32 ResourceProvider::ResourceId mask_resource_id, |
37 gfx::Rect contents_changed_since_last_frame, | 33 gfx::Rect contents_changed_since_last_frame, |
38 float mask_tex_coord_scale_x, | 34 gfx::RectF mask_uv_rect) { |
39 float mask_tex_coord_scale_y, | |
40 float mask_tex_coord_offset_x, | |
41 float mask_tex_coord_offset_y) { | |
42 DCHECK(render_pass_id.layer_id > 0); | 35 DCHECK(render_pass_id.layer_id > 0); |
43 DCHECK(render_pass_id.index >= 0); | 36 DCHECK(render_pass_id.index >= 0); |
44 | 37 |
45 gfx::Rect opaque_rect; | 38 gfx::Rect opaque_rect; |
46 gfx::Rect visible_rect = rect; | 39 gfx::Rect visible_rect = rect; |
47 bool needs_blending = false; | 40 bool needs_blending = false; |
48 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect, | 41 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect, |
49 visible_rect, needs_blending); | 42 visible_rect, needs_blending); |
50 this->render_pass_id = render_pass_id; | 43 this->render_pass_id = render_pass_id; |
51 this->is_replica = is_replica; | 44 this->is_replica = is_replica; |
52 this->mask_resource_id = mask_resource_id; | 45 this->mask_resource_id = mask_resource_id; |
53 this->contents_changed_since_last_frame = contents_changed_since_last_frame; | 46 this->contents_changed_since_last_frame = contents_changed_since_last_frame; |
54 this->mask_tex_coord_scale_x = mask_tex_coord_scale_x; | 47 this->mask_uv_rect = mask_uv_rect; |
55 this->mask_tex_coord_scale_y = mask_tex_coord_scale_y; | |
56 this->mask_tex_coord_offset_x = mask_tex_coord_offset_x; | |
57 this->mask_tex_coord_offset_y = mask_tex_coord_offset_y; | |
58 } | 48 } |
59 | 49 |
60 void RenderPassDrawQuad::SetAll(const SharedQuadState* shared_quad_state, | 50 void RenderPassDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
61 gfx::Rect rect, | 51 gfx::Rect rect, |
62 gfx::Rect opaque_rect, | 52 gfx::Rect opaque_rect, |
63 gfx::Rect visible_rect, | 53 gfx::Rect visible_rect, |
64 bool needs_blending, | 54 bool needs_blending, |
65 RenderPass::Id render_pass_id, | 55 RenderPass::Id render_pass_id, |
66 bool is_replica, | 56 bool is_replica, |
67 ResourceProvider::ResourceId mask_resource_id, | 57 ResourceProvider::ResourceId mask_resource_id, |
68 gfx::Rect contents_changed_since_last_frame, | 58 gfx::Rect contents_changed_since_last_frame, |
69 float mask_tex_coord_scale_x, | 59 gfx::RectF mask_uv_rect) { |
70 float mask_tex_coord_scale_y, | |
71 float mask_tex_coord_offset_x, | |
72 float mask_tex_coord_offset_y) { | |
73 DCHECK(render_pass_id.layer_id > 0); | 60 DCHECK(render_pass_id.layer_id > 0); |
74 DCHECK(render_pass_id.index >= 0); | 61 DCHECK(render_pass_id.index >= 0); |
75 | 62 |
76 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect, | 63 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect, |
77 visible_rect, needs_blending); | 64 visible_rect, needs_blending); |
78 this->render_pass_id = render_pass_id; | 65 this->render_pass_id = render_pass_id; |
79 this->is_replica = is_replica; | 66 this->is_replica = is_replica; |
80 this->mask_resource_id = mask_resource_id; | 67 this->mask_resource_id = mask_resource_id; |
81 this->contents_changed_since_last_frame = contents_changed_since_last_frame; | 68 this->contents_changed_since_last_frame = contents_changed_since_last_frame; |
82 this->mask_tex_coord_scale_x = mask_tex_coord_scale_x; | 69 this->mask_uv_rect = mask_uv_rect; |
83 this->mask_tex_coord_scale_y = mask_tex_coord_scale_y; | |
84 this->mask_tex_coord_offset_x = mask_tex_coord_offset_x; | |
85 this->mask_tex_coord_offset_y = mask_tex_coord_offset_y; | |
86 } | 70 } |
87 | 71 |
88 const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast( | 72 const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast( |
89 const DrawQuad* quad) { | 73 const DrawQuad* quad) { |
90 DCHECK(quad->material == DrawQuad::RENDER_PASS); | 74 DCHECK(quad->material == DrawQuad::RENDER_PASS); |
91 return static_cast<const RenderPassDrawQuad*>(quad); | 75 return static_cast<const RenderPassDrawQuad*>(quad); |
92 } | 76 } |
93 | 77 |
94 } // namespace cc | 78 } // namespace cc |
OLD | NEW |