Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / quads / shared_quad_state.cc
blob57959e3cdd92919615e68d9d7c95c205453fe770
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),
15 opacity(0.f),
16 blend_mode(SkXfermode::kSrcOver_Mode),
17 sorting_context_id(0) {
20 SharedQuadState::~SharedQuadState() {
21 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
22 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"),
23 "cc::SharedQuadState", this);
26 void SharedQuadState::CopyFrom(const SharedQuadState* other) {
27 *this = *other;
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 int sorting_context_id) {
38 this->content_to_target_transform = content_to_target_transform;
39 this->content_bounds = content_bounds;
40 this->visible_content_rect = visible_content_rect;
41 this->clip_rect = clip_rect;
42 this->is_clipped = is_clipped;
43 this->opacity = opacity;
44 this->blend_mode = blend_mode;
45 this->sorting_context_id = sorting_context_id;
48 scoped_ptr<base::Value> SharedQuadState::AsValue() const {
49 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
50 value->Set("transform",
51 MathUtil::AsValue(content_to_target_transform).release());
52 value->Set("layer_content_bounds",
53 MathUtil::AsValue(content_bounds).release());
54 value->Set("layer_visible_content_rect",
55 MathUtil::AsValue(visible_content_rect).release());
56 value->SetBoolean("is_clipped", is_clipped);
57 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release());
58 value->SetDouble("opacity", opacity);
59 value->SetString("blend_mode", SkXfermode::ModeName(blend_mode));
60 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
61 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"),
62 value.get(), "cc::SharedQuadState", this);
63 return value.PassAs<base::Value>();
66 } // namespace cc