Chromium Code Reviews| 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) { | |
|
enne (OOO)
2013/11/01 18:49:02
blend_mode
rosca
2013/11/04 17:14:34
Done.
| |
| 16 switch (blendMode) { | |
| 17 case SkXfermode::kMultiply_Mode: | |
| 18 return "multiply"; | |
| 19 case SkXfermode::kScreen_Mode: | |
| 20 return "screen"; | |
| 21 case SkXfermode::kOverlay_Mode: | |
| 22 return "overlay"; | |
| 23 case SkXfermode::kDarken_Mode: | |
| 24 return "darken"; | |
| 25 case SkXfermode::kLighten_Mode: | |
| 26 return "lighten"; | |
| 27 case SkXfermode::kColorDodge_Mode: | |
| 28 return "color-dodge"; | |
| 29 case SkXfermode::kColorBurn_Mode: | |
| 30 return "color-burn"; | |
| 31 case SkXfermode::kHardLight_Mode: | |
| 32 return "hard-light"; | |
| 33 case SkXfermode::kSoftLight_Mode: | |
| 34 return "soft-light"; | |
| 35 case SkXfermode::kDifference_Mode: | |
| 36 return "difference"; | |
| 37 case SkXfermode::kExclusion_Mode: | |
| 38 return "exclusion"; | |
| 39 case SkXfermode::kHue_Mode: | |
| 40 return "hue"; | |
| 41 case SkXfermode::kSaturation_Mode: | |
| 42 return "saturation"; | |
| 43 case SkXfermode::kColor_Mode: | |
| 44 return "color"; | |
| 45 case SkXfermode::kLuminosity_Mode: | |
| 46 return "luminosity"; | |
| 47 default: | |
| 48 return "normal"; | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 SharedQuadState::SharedQuadState() | |
| 55 : is_clipped(false), opacity(0.f), blend_mode(SkXfermode::kSrcOver_Mode) {} | |
| 14 | 56 |
| 15 SharedQuadState::~SharedQuadState() { | 57 SharedQuadState::~SharedQuadState() { |
| 16 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 58 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 17 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 59 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
| 18 "cc::SharedQuadState", this); | 60 "cc::SharedQuadState", this); |
| 19 } | 61 } |
| 20 | 62 |
| 21 scoped_ptr<SharedQuadState> SharedQuadState::Create() { | 63 scoped_ptr<SharedQuadState> SharedQuadState::Create() { |
| 22 return make_scoped_ptr(new SharedQuadState); | 64 return make_scoped_ptr(new SharedQuadState); |
| 23 } | 65 } |
| 24 | 66 |
| 25 scoped_ptr<SharedQuadState> SharedQuadState::Copy() const { | 67 scoped_ptr<SharedQuadState> SharedQuadState::Copy() const { |
| 26 return make_scoped_ptr(new SharedQuadState(*this)); | 68 return make_scoped_ptr(new SharedQuadState(*this)); |
| 27 } | 69 } |
| 28 | 70 |
| 29 void SharedQuadState::SetAll( | 71 void SharedQuadState::SetAll(const gfx::Transform& content_to_target_transform, |
| 30 const gfx::Transform& content_to_target_transform, | 72 gfx::Size content_bounds, |
| 31 gfx::Size content_bounds, | 73 gfx::Rect visible_content_rect, |
| 32 gfx::Rect visible_content_rect, | 74 gfx::Rect clip_rect, |
| 33 gfx::Rect clip_rect, | 75 bool is_clipped, |
| 34 bool is_clipped, | 76 float opacity, |
| 35 float opacity) { | 77 SkXfermode::Mode blend_mode) { |
| 36 this->content_to_target_transform = content_to_target_transform; | 78 this->content_to_target_transform = content_to_target_transform; |
| 37 this->content_bounds = content_bounds; | 79 this->content_bounds = content_bounds; |
| 38 this->visible_content_rect = visible_content_rect; | 80 this->visible_content_rect = visible_content_rect; |
| 39 this->clip_rect = clip_rect; | 81 this->clip_rect = clip_rect; |
| 40 this->is_clipped = is_clipped; | 82 this->is_clipped = is_clipped; |
| 41 this->opacity = opacity; | 83 this->opacity = opacity; |
| 84 this->blend_mode = blend_mode; | |
| 42 } | 85 } |
| 43 | 86 |
| 44 scoped_ptr<base::Value> SharedQuadState::AsValue() const { | 87 scoped_ptr<base::Value> SharedQuadState::AsValue() const { |
| 45 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 88 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 46 value->Set("transform", | 89 value->Set("transform", |
| 47 MathUtil::AsValue(content_to_target_transform).release()); | 90 MathUtil::AsValue(content_to_target_transform).release()); |
| 48 value->Set("layer_content_bounds", | 91 value->Set("layer_content_bounds", |
| 49 MathUtil::AsValue(content_bounds).release()); | 92 MathUtil::AsValue(content_bounds).release()); |
| 50 value->Set("layer_visible_content_rect", | 93 value->Set("layer_visible_content_rect", |
| 51 MathUtil::AsValue(visible_content_rect).release()); | 94 MathUtil::AsValue(visible_content_rect).release()); |
| 52 value->SetBoolean("is_clipped", is_clipped); | 95 value->SetBoolean("is_clipped", is_clipped); |
| 53 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); | 96 value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); |
| 54 value->SetDouble("opacity", opacity); | 97 value->SetDouble("opacity", opacity); |
| 98 value->SetString("blend_mode", BlendModeToString(blend_mode)); | |
| 55 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 99 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
| 56 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 100 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
| 57 value.get(), "cc::SharedQuadState", this); | 101 value.get(), "cc::SharedQuadState", this); |
| 58 return value.PassAs<base::Value>(); | 102 return value.PassAs<base::Value>(); |
| 59 } | 103 } |
| 60 | 104 |
| 61 } // namespace cc | 105 } // namespace cc |
| OLD | NEW |