OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/quads/shared_quad_state.h" | 5 #include "cc/quads/shared_quad_state.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/debug/traced_value.h" | 9 #include "cc/debug/traced_value.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 SharedQuadState::SharedQuadState() : is_clipped(false), opacity(0.f) {} | 13 namespace { |
| 14 |
| 15 const char* BlendModeToString(SkXfermode::Mode blendMode) { |
| 16 switch (blendMode) { |
| 17 case SkXfermode::kMultiply_Mode: return "multiply"; |
| 18 case SkXfermode::kScreen_Mode: return "screen"; |
| 19 case SkXfermode::kOverlay_Mode: return "overlay"; |
| 20 case SkXfermode::kDarken_Mode: return "darken"; |
| 21 case SkXfermode::kLighten_Mode: return "lighten"; |
| 22 case SkXfermode::kColorDodge_Mode: return "color-dodge"; |
| 23 case SkXfermode::kColorBurn_Mode: return "color-burn"; |
| 24 case SkXfermode::kHardLight_Mode: return "hard-light"; |
| 25 case SkXfermode::kSoftLight_Mode: return "soft-light"; |
| 26 case SkXfermode::kDifference_Mode: return "difference"; |
| 27 case SkXfermode::kExclusion_Mode: return "exclusion"; |
| 28 case SkXfermode::kHue_Mode: return "hue"; |
| 29 case SkXfermode::kSaturation_Mode: return "saturation"; |
| 30 case SkXfermode::kColor_Mode: return "color"; |
| 31 case SkXfermode::kLuminosity_Mode: return "luminosity"; |
| 32 default: return "normal"; |
| 33 } |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 38 SharedQuadState::SharedQuadState() : is_clipped(false), |
| 39 opacity(0.f), |
| 40 blend_mode(SkXfermode::kSrcOver_Mode) {} |
14 | 41 |
15 SharedQuadState::~SharedQuadState() { | 42 SharedQuadState::~SharedQuadState() { |
16 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 43 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
17 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 44 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
18 "cc::SharedQuadState", this); | 45 "cc::SharedQuadState", this); |
19 } | 46 } |
20 | 47 |
21 scoped_ptr<SharedQuadState> SharedQuadState::Create() { | 48 scoped_ptr<SharedQuadState> SharedQuadState::Create() { |
22 return make_scoped_ptr(new SharedQuadState); | 49 return make_scoped_ptr(new SharedQuadState); |
23 } | 50 } |
24 | 51 |
25 scoped_ptr<SharedQuadState> SharedQuadState::Copy() const { | 52 scoped_ptr<SharedQuadState> SharedQuadState::Copy() const { |
26 return make_scoped_ptr(new SharedQuadState(*this)); | 53 return make_scoped_ptr(new SharedQuadState(*this)); |
27 } | 54 } |
28 | 55 |
29 void SharedQuadState::SetAll( | 56 void SharedQuadState::SetAll( |
30 const gfx::Transform& content_to_target_transform, | 57 const gfx::Transform& content_to_target_transform, |
31 gfx::Size content_bounds, | 58 gfx::Size content_bounds, |
32 gfx::Rect visible_content_rect, | 59 gfx::Rect visible_content_rect, |
33 gfx::Rect clip_rect, | 60 gfx::Rect clip_rect, |
34 bool is_clipped, | 61 bool is_clipped, |
35 float opacity) { | 62 float opacity, |
| 63 SkXfermode::Mode blend_mode) { |
36 this->content_to_target_transform = content_to_target_transform; | 64 this->content_to_target_transform = content_to_target_transform; |
37 this->content_bounds = content_bounds; | 65 this->content_bounds = content_bounds; |
38 this->visible_content_rect = visible_content_rect; | 66 this->visible_content_rect = visible_content_rect; |
39 this->clip_rect = clip_rect; | 67 this->clip_rect = clip_rect; |
40 this->is_clipped = is_clipped; | 68 this->is_clipped = is_clipped; |
41 this->opacity = opacity; | 69 this->opacity = opacity; |
| 70 this->blend_mode = blend_mode; |
42 } | 71 } |
43 | 72 |
44 scoped_ptr<base::Value> SharedQuadState::AsValue() const { | 73 scoped_ptr<base::Value> SharedQuadState::AsValue() const { |
45 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 74 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
46 value->Set("transform", | 75 value->Set("transform", |
47 MathUtil::AsValue(content_to_target_transform).release()); | 76 MathUtil::AsValue(content_to_target_transform).release()); |
48 value->Set("layer_content_bounds", | 77 value->Set("layer_content_bounds", |
49 MathUtil::AsValue(content_bounds).release()); | 78 MathUtil::AsValue(content_bounds).release()); |
50 value->Set("layer_visible_content_rect", | 79 value->Set("layer_visible_content_rect", |
51 MathUtil::AsValue(visible_content_rect).release()); | 80 MathUtil::AsValue(visible_content_rect).release()); |
52 value->SetBoolean("is_clipped", is_clipped); | 81 value->SetBoolean("is_clipped", is_clipped); |
53 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); | 82 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); |
54 value->SetDouble("opacity", opacity); | 83 value->SetDouble("opacity", opacity); |
| 84 value->SetString("blend_mode", BlendModeToString(blend_mode)); |
55 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 85 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
56 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 86 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
57 value.get(), "cc::SharedQuadState", this); | 87 value.get(), "cc::SharedQuadState", this); |
58 return value.PassAs<base::Value>(); | 88 return value.PassAs<base::Value>(); |
59 } | 89 } |
60 | 90 |
61 } // namespace cc | 91 } // namespace cc |
OLD | NEW |