Delete unused downloads page asset.
[chromium-blink-merge.git] / cc / quads / render_pass_draw_quad.cc
blob47c976b96bcbc3bb3b8c69c40f868bddb5468f05
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/trace_event/trace_event_argument.h"
8 #include "base/values.h"
9 #include "cc/base/math_util.h"
10 #include "cc/debug/traced_value.h"
11 #include "third_party/skia/include/core/SkImageFilter.h"
13 namespace cc {
15 RenderPassDrawQuad::RenderPassDrawQuad() {
18 RenderPassDrawQuad::~RenderPassDrawQuad() {
21 void RenderPassDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
22 const gfx::Rect& rect,
23 const gfx::Rect& visible_rect,
24 RenderPassId render_pass_id,
25 ResourceId mask_resource_id,
26 const gfx::Vector2dF& mask_uv_scale,
27 const gfx::Size& mask_texture_size,
28 const FilterOperations& filters,
29 const gfx::Vector2dF& filters_scale,
30 const FilterOperations& background_filters) {
31 DCHECK_GT(render_pass_id.layer_id, 0);
33 gfx::Rect opaque_rect;
34 bool needs_blending = false;
35 SetAll(shared_quad_state,
36 rect,
37 opaque_rect,
38 visible_rect,
39 needs_blending,
40 render_pass_id,
41 mask_resource_id,
42 mask_uv_scale,
43 mask_texture_size,
44 filters,
45 filters_scale,
46 background_filters);
49 void RenderPassDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
50 const gfx::Rect& rect,
51 const gfx::Rect& opaque_rect,
52 const gfx::Rect& visible_rect,
53 bool needs_blending,
54 RenderPassId render_pass_id,
55 ResourceId mask_resource_id,
56 const gfx::Vector2dF& mask_uv_scale,
57 const gfx::Size& mask_texture_size,
58 const FilterOperations& filters,
59 const gfx::Vector2dF& filters_scale,
60 const FilterOperations& background_filters) {
61 DCHECK_GT(render_pass_id.layer_id, 0);
63 DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect,
64 visible_rect, needs_blending);
65 this->render_pass_id = render_pass_id;
66 resources.ids[kMaskResourceIdIndex] = mask_resource_id;
67 resources.count = mask_resource_id ? 1 : 0;
68 this->mask_uv_scale = mask_uv_scale;
69 this->mask_texture_size = mask_texture_size;
70 this->filters = filters;
71 this->filters_scale = filters_scale;
72 this->background_filters = background_filters;
75 gfx::RectF RenderPassDrawQuad::MaskUVRect() const {
76 gfx::RectF mask_uv_rect((mask_uv_scale.x() * rect.x()) / rect.width(),
77 (mask_uv_scale.y() * rect.y()) / rect.height(),
78 mask_uv_scale.x(),
79 mask_uv_scale.y());
80 return mask_uv_rect;
83 const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast(
84 const DrawQuad* quad) {
85 DCHECK_EQ(quad->material, DrawQuad::RENDER_PASS);
86 return static_cast<const RenderPassDrawQuad*>(quad);
89 void RenderPassDrawQuad::ExtendValue(
90 base::trace_event::TracedValue* value) const {
91 TracedValue::SetIDRef(render_pass_id.AsTracingId(), value, "render_pass_id");
92 value->SetInteger("mask_resource_id", resources.ids[kMaskResourceIdIndex]);
93 MathUtil::AddToTracedValue("mask_texture_size", mask_texture_size, value);
94 MathUtil::AddToTracedValue("mask_uv_scale", mask_uv_scale, value);
96 value->BeginArray("filters");
97 filters.AsValueInto(value);
98 value->EndArray();
99 MathUtil::AddToTracedValue("filters_scale", filters_scale, value);
101 value->BeginDictionary("background_filters");
102 background_filters.AsValueInto(value);
103 value->EndDictionary();
106 } // namespace cc