Revert 264226 "Reduce dependency of TiclInvalidationService on P..."
[chromium-blink-merge.git] / cc / quads / shared_quad_state.cc
blob9ea3faa27dc21693733b954dd5958c745418b3b2
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/shared_quad_state.h"
7 #include "base/values.h"
8 #include "cc/base/math_util.h"
9 #include "cc/debug/traced_value.h"
11 namespace cc {
13 SharedQuadState::SharedQuadState()
14 : is_clipped(false), opacity(0.f), blend_mode(SkXfermode::kSrcOver_Mode) {}
16 SharedQuadState::~SharedQuadState() {
17 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
18 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"),
19 "cc::SharedQuadState", this);
22 scoped_ptr<SharedQuadState> SharedQuadState::Create() {
23 return make_scoped_ptr(new SharedQuadState);
26 scoped_ptr<SharedQuadState> SharedQuadState::Copy() const {
27 return make_scoped_ptr(new SharedQuadState(*this));
30 void SharedQuadState::SetAll(const gfx::Transform& content_to_target_transform,
31 const gfx::Size& content_bounds,
32 const gfx::Rect& visible_content_rect,
33 const gfx::Rect& clip_rect,
34 bool is_clipped,
35 float opacity,
36 SkXfermode::Mode blend_mode) {
37 this->content_to_target_transform = content_to_target_transform;
38 this->content_bounds = content_bounds;
39 this->visible_content_rect = visible_content_rect;
40 this->clip_rect = clip_rect;
41 this->is_clipped = is_clipped;
42 this->opacity = opacity;
43 this->blend_mode = blend_mode;
46 scoped_ptr<base::Value> SharedQuadState::AsValue() const {
47 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
48 value->Set("transform",
49 MathUtil::AsValue(content_to_target_transform).release());
50 value->Set("layer_content_bounds",
51 MathUtil::AsValue(content_bounds).release());
52 value->Set("layer_visible_content_rect",
53 MathUtil::AsValue(visible_content_rect).release());
54 value->SetBoolean("is_clipped", is_clipped);
55 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release());
56 value->SetDouble("opacity", opacity);
57 value->SetString("blend_mode", SkXfermode::ModeName(blend_mode));
58 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
59 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"),
60 value.get(), "cc::SharedQuadState", this);
61 return value.PassAs<base::Value>();
64 } // namespace cc