Setup a experiment to enable background tracing.
[chromium-blink-merge.git] / cc / quads / draw_quad.cc
blob1142cc10ddca99fef9e345fd0783cd81c1cef755
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/logging.h"
8 #include "base/trace_event/trace_event_argument.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), needs_blending(false), shared_quad_state(0) {
31 void DrawQuad::SetAll(const SharedQuadState* shared_quad_state,
32 Material material,
33 const gfx::Rect& rect,
34 const gfx::Rect& opaque_rect,
35 const gfx::Rect& visible_rect,
36 bool needs_blending) {
37 DCHECK(rect.Contains(visible_rect)) << "rect: " << rect.ToString()
38 << " visible_rect: "
39 << visible_rect.ToString();
40 DCHECK(opaque_rect.IsEmpty() || rect.Contains(opaque_rect))
41 << "rect: " << rect.ToString() << "opaque_rect "
42 << opaque_rect.ToString();
44 this->material = material;
45 this->rect = rect;
46 this->opaque_rect = opaque_rect;
47 this->visible_rect = visible_rect;
48 this->needs_blending = needs_blending;
49 this->shared_quad_state = shared_quad_state;
51 DCHECK(shared_quad_state);
52 DCHECK(material != INVALID);
55 DrawQuad::~DrawQuad() {
58 void DrawQuad::AsValueInto(base::trace_event::TracedValue* value) const {
59 value->SetInteger("material", material);
60 TracedValue::SetIDRef(shared_quad_state, value, "shared_state");
62 MathUtil::AddToTracedValue("content_space_rect", rect, value);
64 bool rect_is_clipped;
65 gfx::QuadF rect_as_target_space_quad = MathUtil::MapQuad(
66 shared_quad_state->content_to_target_transform,
67 gfx::QuadF(rect),
68 &rect_is_clipped);
69 MathUtil::AddToTracedValue("rect_as_target_space_quad",
70 rect_as_target_space_quad, value);
72 value->SetBoolean("rect_is_clipped", rect_is_clipped);
74 MathUtil::AddToTracedValue("content_space_opaque_rect", opaque_rect, value);
76 bool opaque_rect_is_clipped;
77 gfx::QuadF opaque_rect_as_target_space_quad = MathUtil::MapQuad(
78 shared_quad_state->content_to_target_transform,
79 gfx::QuadF(opaque_rect),
80 &opaque_rect_is_clipped);
81 MathUtil::AddToTracedValue("opaque_rect_as_target_space_quad",
82 opaque_rect_as_target_space_quad, value);
84 value->SetBoolean("opaque_rect_is_clipped", opaque_rect_is_clipped);
86 MathUtil::AddToTracedValue("content_space_visible_rect", visible_rect, value);
88 bool visible_rect_is_clipped;
89 gfx::QuadF visible_rect_as_target_space_quad = MathUtil::MapQuad(
90 shared_quad_state->content_to_target_transform,
91 gfx::QuadF(visible_rect),
92 &visible_rect_is_clipped);
94 MathUtil::AddToTracedValue("visible_rect_as_target_space_quad",
95 visible_rect_as_target_space_quad, value);
97 value->SetBoolean("visible_rect_is_clipped", visible_rect_is_clipped);
99 value->SetBoolean("needs_blending", needs_blending);
100 value->SetBoolean("should_draw_with_blending", ShouldDrawWithBlending());
101 ExtendValue(value);
104 DrawQuad::Resources::Resources() : count(0) {
105 for (size_t i = 0; i < kMaxResourceIdCount; ++i)
106 ids[i] = 0;
109 } // namespace cc