cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / quads / render_pass_draw_quad.cc
blob0528cd5e34f8e1ff0ff2e88e0ec33c574a040003
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"
7 #include "base/values.h"
8 #include "cc/base/math_util.h"
9 #include "cc/debug/traced_value.h"
11 namespace cc {
13 RenderPassDrawQuad::RenderPassDrawQuad()
14 : render_pass_id(RenderPass::Id(-1, -1)),
15 is_replica(false),
16 mask_resource_id(-1) {
19 RenderPassDrawQuad::~RenderPassDrawQuad() {
22 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Create() {
23 return make_scoped_ptr(new RenderPassDrawQuad);
26 scoped_ptr<RenderPassDrawQuad> RenderPassDrawQuad::Copy(
27 const SharedQuadState* copied_shared_quad_state,
28 RenderPass::Id copied_render_pass_id) const {
29 scoped_ptr<RenderPassDrawQuad> copy_quad(
30 new RenderPassDrawQuad(*MaterialCast(this)));
31 copy_quad->shared_quad_state = copied_shared_quad_state;
32 copy_quad->render_pass_id = copied_render_pass_id;
33 return copy_quad.Pass();
36 void RenderPassDrawQuad::SetNew(
37 const SharedQuadState* shared_quad_state,
38 gfx::Rect rect,
39 RenderPass::Id render_pass_id,
40 bool is_replica,
41 ResourceProvider::ResourceId mask_resource_id,
42 gfx::Rect contents_changed_since_last_frame,
43 gfx::RectF mask_uv_rect,
44 const FilterOperations& filters,
45 skia::RefPtr<SkImageFilter> filter,
46 const FilterOperations& background_filters) {
47 DCHECK_GT(render_pass_id.layer_id, 0);
48 DCHECK_GE(render_pass_id.index, 0);
50 gfx::Rect opaque_rect;
51 gfx::Rect visible_rect = rect;
52 bool needs_blending = false;
53 SetAll(shared_quad_state, rect, opaque_rect, visible_rect, needs_blending,
54 render_pass_id, is_replica, mask_resource_id,
55 contents_changed_since_last_frame, mask_uv_rect, filters, filter,
56 background_filters);
59 void RenderPassDrawQuad::SetAll(
60 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 gfx::RectF mask_uv_rect,
70 const FilterOperations& filters,
71 skia::RefPtr<SkImageFilter> filter,
72 const FilterOperations& background_filters) {
73 DCHECK_GT(render_pass_id.layer_id, 0);
74 DCHECK_GE(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_uv_rect = mask_uv_rect;
83 this->filters = filters;
84 this->filter = filter;
85 this->background_filters = background_filters;
88 void RenderPassDrawQuad::IterateResources(
89 const ResourceIteratorCallback& callback) {
90 if (mask_resource_id)
91 mask_resource_id = callback.Run(mask_resource_id);
94 const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast(
95 const DrawQuad* quad) {
96 DCHECK_EQ(quad->material, DrawQuad::RENDER_PASS);
97 return static_cast<const RenderPassDrawQuad*>(quad);
100 void RenderPassDrawQuad::ExtendValue(base::DictionaryValue* value) const {
101 value->Set("render_pass_id",
102 TracedValue::CreateIDRef(render_pass_id.AsTracingId()).release());
103 value->SetBoolean("is_replica", is_replica);
104 value->SetInteger("mask_resource_id", mask_resource_id);
105 value->Set("contents_changed_since_last_frame",
106 MathUtil::AsValue(contents_changed_since_last_frame).release());
107 value->Set("mask_uv_rect", MathUtil::AsValue(mask_uv_rect).release());
108 value->Set("filters", filters.AsValue().release());
109 // TODO(piman): dump SkImageFilters rather than just indicating if there are
110 // any or not.
111 value->SetBoolean("has_filter", !!filter);
112 value->Set("background_filters", background_filters.AsValue().release());
115 } // namespace cc