Add intro to any Chrome app API with no overview docs.
[chromium-blink-merge.git] / cc / render_pass_draw_quad.cc
blob5f3df0839df115c762f9715f19b1fba6c09452a5
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/render_pass_draw_quad.h"
7 namespace cc {
9 RenderPassDrawQuad::RenderPassDrawQuad()
10 : render_pass_id(RenderPass::Id(-1, -1)),
11 is_replica(false),
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) {
19 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Create() {
20 return make_scoped_ptr(new RenderPassDrawQuad);
23 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Copy(
24 const SharedQuadState* copied_shared_quad_state,
25 RenderPass::Id copied_render_pass_id) const {
26 scoped_ptr<RenderPassDrawQuad> copy_quad(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(const SharedQuadState* shared_quad_state,
33 gfx::Rect rect,
34 RenderPass::Id render_pass_id,
35 bool is_replica,
36 ResourceProvider::ResourceId mask_resource_id,
37 gfx::Rect contents_changed_since_last_frame,
38 float mask_tex_coord_scale_x,
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);
43 DCHECK(render_pass_id.index >= 0);
45 gfx::Rect opaque_rect;
46 gfx::Rect visible_rect = rect;
47 bool needs_blending = false;
48 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect,
49 visible_rect, needs_blending);
50 this->render_pass_id = render_pass_id;
51 this->is_replica = is_replica;
52 this->mask_resource_id = mask_resource_id;
53 this->contents_changed_since_last_frame = contents_changed_since_last_frame;
54 this->mask_tex_coord_scale_x = mask_tex_coord_scale_x;
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;
60 void RenderPassDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
61 gfx::Rect rect,
62 gfx::Rect opaque_rect,
63 gfx::Rect visible_rect,
64 bool needs_blending,
65 RenderPass::Id render_pass_id,
66 bool is_replica,
67 ResourceProvider::ResourceId mask_resource_id,
68 gfx::Rect contents_changed_since_last_frame,
69 float mask_tex_coord_scale_x,
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);
74 DCHECK(render_pass_id.index >= 0);
76 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect,
77 visible_rect, needs_blending);
78 this->render_pass_id = render_pass_id;
79 this->is_replica = is_replica;
80 this->mask_resource_id = mask_resource_id;
81 this->contents_changed_since_last_frame = contents_changed_since_last_frame;
82 this->mask_tex_coord_scale_x = mask_tex_coord_scale_x;
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;
88 const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast(
89 const DrawQuad* quad) {
90 DCHECK(quad->material == DrawQuad::RENDER_PASS);
91 return static_cast<const RenderPassDrawQuad*>(quad);
94 } // namespace cc