OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 namespace ui { | 45 namespace ui { |
46 | 46 |
47 Layer::Layer() | 47 Layer::Layer() |
48 : type_(LAYER_TEXTURED), | 48 : type_(LAYER_TEXTURED), |
49 compositor_(NULL), | 49 compositor_(NULL), |
50 parent_(NULL), | 50 parent_(NULL), |
51 visible_(true), | 51 visible_(true), |
52 fills_bounds_opaquely_(true), | 52 fills_bounds_opaquely_(true), |
53 layer_updated_externally_(false), | 53 layer_updated_externally_(false), |
54 opacity_(1.0f), | 54 opacity_(1.0f), |
| 55 inverted_(false), |
55 delegate_(NULL), | 56 delegate_(NULL), |
56 scale_canvas_(true), | 57 scale_canvas_(true), |
57 device_scale_factor_(1.0f) { | 58 device_scale_factor_(1.0f) { |
58 CreateWebLayer(); | 59 CreateWebLayer(); |
59 } | 60 } |
60 | 61 |
61 Layer::Layer(LayerType type) | 62 Layer::Layer(LayerType type) |
62 : type_(type), | 63 : type_(type), |
63 compositor_(NULL), | 64 compositor_(NULL), |
64 parent_(NULL), | 65 parent_(NULL), |
65 visible_(true), | 66 visible_(true), |
66 fills_bounds_opaquely_(true), | 67 fills_bounds_opaquely_(true), |
67 layer_updated_externally_(false), | 68 layer_updated_externally_(false), |
68 opacity_(1.0f), | 69 opacity_(1.0f), |
| 70 inverted_(false), |
69 delegate_(NULL), | 71 delegate_(NULL), |
70 scale_canvas_(true), | 72 scale_canvas_(true), |
71 device_scale_factor_(1.0f) { | 73 device_scale_factor_(1.0f) { |
72 CreateWebLayer(); | 74 CreateWebLayer(); |
73 } | 75 } |
74 | 76 |
75 Layer::~Layer() { | 77 Layer::~Layer() { |
76 // Destroying the animator may cause observers to use the layer (and | 78 // Destroying the animator may cause observers to use the layer (and |
77 // indirectly the WebLayer). Destroy the animator first so that the WebLayer | 79 // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
78 // is still around. | 80 // is still around. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 190 } |
189 | 191 |
190 bool Layer::GetMasksToBounds() const { | 192 bool Layer::GetMasksToBounds() const { |
191 return web_layer_.masksToBounds(); | 193 return web_layer_.masksToBounds(); |
192 } | 194 } |
193 | 195 |
194 void Layer::SetOpacity(float opacity) { | 196 void Layer::SetOpacity(float opacity) { |
195 GetAnimator()->SetOpacity(opacity); | 197 GetAnimator()->SetOpacity(opacity); |
196 } | 198 } |
197 | 199 |
198 void Layer::SetBackgroundBlur(int blur_radius) | 200 void Layer::SetBackgroundBlur(int blur_radius) { |
199 { | |
200 WebKit::WebFilterOperations filters; | 201 WebKit::WebFilterOperations filters; |
201 if (blur_radius) | 202 if (blur_radius) |
202 filters.append(WebKit::WebBlurFilterOperation(blur_radius)); | 203 filters.append(WebKit::WebBlurFilterOperation(blur_radius)); |
203 web_layer_.setBackgroundFilters(filters); | 204 web_layer_.setBackgroundFilters(filters); |
204 | 205 |
205 background_blur_radius_ = blur_radius; | 206 background_blur_radius_ = blur_radius; |
206 } | 207 } |
207 | 208 |
| 209 void Layer::SetInverted(bool inverted) { |
| 210 WebKit::WebFilterOperations filters; |
| 211 if (inverted) { |
| 212 filters.append(WebKit::WebBasicComponentTransferFilterOperation( |
| 213 WebKit::WebBasicComponentTransferFilterOperation:: |
| 214 BasicComponentTransferFilterTypeInvert, 1.0)); |
| 215 } |
| 216 web_layer_.setFilters(filters); |
| 217 |
| 218 inverted_ = inverted; |
| 219 } |
| 220 |
208 float Layer::GetTargetOpacity() const { | 221 float Layer::GetTargetOpacity() const { |
209 if (animator_.get() && animator_->IsAnimatingProperty( | 222 if (animator_.get() && animator_->IsAnimatingProperty( |
210 LayerAnimationElement::OPACITY)) | 223 LayerAnimationElement::OPACITY)) |
211 return animator_->GetTargetOpacity(); | 224 return animator_->GetTargetOpacity(); |
212 return opacity_; | 225 return opacity_; |
213 } | 226 } |
214 | 227 |
215 void Layer::SetVisible(bool visible) { | 228 void Layer::SetVisible(bool visible) { |
216 GetAnimator()->SetVisibility(visible); | 229 GetAnimator()->SetVisibility(visible); |
217 } | 230 } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 return; | 631 return; |
619 unsigned int color = 0xFF000000; | 632 unsigned int color = 0xFF000000; |
620 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 633 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
621 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 634 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
622 if (!opaque) | 635 if (!opaque) |
623 color |= 0xFF; | 636 color |= 0xFF; |
624 web_layer_.setDebugBorderColor(color); | 637 web_layer_.setDebugBorderColor(color); |
625 } | 638 } |
626 | 639 |
627 } // namespace ui | 640 } // namespace ui |
OLD | NEW |