[GCM] Remove GCMDriver::Purge and GCMClient::CheckOut
[chromium-blink-merge.git] / cc / quads / draw_quad.cc
blob7322a7afa1a5de0058f386ee5263ef3950e0836b
1 // Copyright 2012 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/draw_quad.h"
7 #include "base/debug/trace_event_argument.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
11 #include "cc/debug/traced_value.h"
12 #include "cc/quads/checkerboard_draw_quad.h"
13 #include "cc/quads/debug_border_draw_quad.h"
14 #include "cc/quads/io_surface_draw_quad.h"
15 #include "cc/quads/picture_draw_quad.h"
16 #include "cc/quads/render_pass_draw_quad.h"
17 #include "cc/quads/solid_color_draw_quad.h"
18 #include "cc/quads/stream_video_draw_quad.h"
19 #include "cc/quads/surface_draw_quad.h"
20 #include "cc/quads/texture_draw_quad.h"
21 #include "cc/quads/tile_draw_quad.h"
22 #include "cc/quads/yuv_video_draw_quad.h"
23 #include "ui/gfx/geometry/quad_f.h"
25 namespace cc {
27 DrawQuad::DrawQuad()
28 : material(INVALID),
29 needs_blending(false),
30 shared_quad_state() {
33 void DrawQuad::SetAll(const SharedQuadState* shared_quad_state,
34 Material material,
35 const gfx::Rect& rect,
36 const gfx::Rect& opaque_rect,
37 const gfx::Rect& visible_rect,
38 bool needs_blending) {
39 DCHECK(rect.Contains(visible_rect)) << "rect: " << rect.ToString()
40 << " visible_rect: "
41 << visible_rect.ToString();
42 DCHECK(opaque_rect.IsEmpty() || rect.Contains(opaque_rect))
43 << "rect: " << rect.ToString() << "opaque_rect "
44 << opaque_rect.ToString();
46 this->material = material;
47 this->rect = rect;
48 this->opaque_rect = opaque_rect;
49 this->visible_rect = visible_rect;
50 this->needs_blending = needs_blending;
51 this->shared_quad_state = shared_quad_state;
53 DCHECK(shared_quad_state);
54 DCHECK(material != INVALID);
57 DrawQuad::~DrawQuad() {
60 void DrawQuad::AsValueInto(base::debug::TracedValue* value) const {
61 value->SetInteger("material", material);
62 TracedValue::SetIDRef(shared_quad_state, value, "shared_state");
64 value->BeginArray("content_space_rect");
65 MathUtil::AddToTracedValue(rect, value);
66 value->EndArray();
68 bool rect_is_clipped;
69 gfx::QuadF rect_as_target_space_quad = MathUtil::MapQuad(
70 shared_quad_state->content_to_target_transform,
71 gfx::QuadF(rect),
72 &rect_is_clipped);
73 value->BeginArray("rect_as_target_space_quad");
74 MathUtil::AddToTracedValue(rect_as_target_space_quad, value);
75 value->EndArray();
77 value->SetBoolean("rect_is_clipped", rect_is_clipped);
79 value->BeginArray("content_space_opaque_rect");
80 MathUtil::AddToTracedValue(opaque_rect, value);
81 value->EndArray();
83 bool opaque_rect_is_clipped;
84 gfx::QuadF opaque_rect_as_target_space_quad = MathUtil::MapQuad(
85 shared_quad_state->content_to_target_transform,
86 gfx::QuadF(opaque_rect),
87 &opaque_rect_is_clipped);
88 value->BeginArray("opaque_rect_as_target_space_quad");
89 MathUtil::AddToTracedValue(opaque_rect_as_target_space_quad, value);
90 value->EndArray();
92 value->SetBoolean("opaque_rect_is_clipped", opaque_rect_is_clipped);
94 value->BeginArray("content_space_visible_rect");
95 MathUtil::AddToTracedValue(visible_rect, value);
96 value->EndArray();
98 bool visible_rect_is_clipped;
99 gfx::QuadF visible_rect_as_target_space_quad = MathUtil::MapQuad(
100 shared_quad_state->content_to_target_transform,
101 gfx::QuadF(visible_rect),
102 &visible_rect_is_clipped);
104 value->BeginArray("visible_rect_as_target_space_quad");
105 MathUtil::AddToTracedValue(visible_rect_as_target_space_quad, value);
106 value->EndArray();
108 value->SetBoolean("visible_rect_is_clipped", visible_rect_is_clipped);
110 value->SetBoolean("needs_blending", needs_blending);
111 value->SetBoolean("should_draw_with_blending", ShouldDrawWithBlending());
112 ExtendValue(value);
115 } // namespace cc