Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: ui/compositor/layer.cc

Issue 10201014: Implement High Contrast mode for Chrome OS (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove extra define guard Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 189 }
188 190
189 bool Layer::GetMasksToBounds() const { 191 bool Layer::GetMasksToBounds() const {
190 return web_layer_.masksToBounds(); 192 return web_layer_.masksToBounds();
191 } 193 }
192 194
193 void Layer::SetOpacity(float opacity) { 195 void Layer::SetOpacity(float opacity) {
194 GetAnimator()->SetOpacity(opacity); 196 GetAnimator()->SetOpacity(opacity);
195 } 197 }
196 198
197 void Layer::SetBackgroundBlur(int blur_radius) 199 void Layer::SetBackgroundBlur(int blur_radius) {
198 {
199 WebKit::WebFilterOperations filters; 200 WebKit::WebFilterOperations filters;
200 if (blur_radius) 201 if (blur_radius)
201 filters.append(WebKit::WebBlurFilterOperation(blur_radius)); 202 filters.append(WebKit::WebBlurFilterOperation(blur_radius));
202 web_layer_.setBackgroundFilters(filters); 203 web_layer_.setBackgroundFilters(filters);
203 204
204 background_blur_radius_ = blur_radius; 205 background_blur_radius_ = blur_radius;
205 } 206 }
206 207
208 void Layer::SetInverted(bool inverted) {
209 WebKit::WebFilterOperations filters;
210 if (inverted) {
211 filters.append(WebKit::WebBasicComponentTransferFilterOperation(
212 WebKit::WebBasicComponentTransferFilterOperation::
213 BasicComponentTransferFilterTypeInvert, 1.0));
214 }
215 web_layer_.setFilters(filters);
216
217 inverted_ = inverted;
218 }
219
207 float Layer::GetTargetOpacity() const { 220 float Layer::GetTargetOpacity() const {
208 if (animator_.get() && animator_->IsAnimatingProperty( 221 if (animator_.get() && animator_->IsAnimatingProperty(
209 LayerAnimationElement::OPACITY)) 222 LayerAnimationElement::OPACITY))
210 return animator_->GetTargetOpacity(); 223 return animator_->GetTargetOpacity();
211 return opacity_; 224 return opacity_;
212 } 225 }
213 226
214 void Layer::SetVisible(bool visible) { 227 void Layer::SetVisible(bool visible) {
215 GetAnimator()->SetVisibility(visible); 228 GetAnimator()->SetVisibility(visible);
216 } 229 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return; 625 return;
613 unsigned int color = 0xFF000000; 626 unsigned int color = 0xFF000000;
614 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 627 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
615 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 628 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
616 if (!opaque) 629 if (!opaque)
617 color |= 0xFF; 630 color |= 0xFF;
618 web_layer_.setDebugBorderColor(color); 631 web_layer_.setDebugBorderColor(color);
619 } 632 }
620 633
621 } // namespace ui 634 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698