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

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

Issue 10915140: Add the partial screen magnifier to Chrome OS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Code review fixes Created 8 years, 2 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
« ui/compositor/layer.h ('K') | « 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 fills_bounds_opaquely_(true), 55 fills_bounds_opaquely_(true),
56 layer_updated_externally_(false), 56 layer_updated_externally_(false),
57 opacity_(1.0f), 57 opacity_(1.0f),
58 background_blur_radius_(0), 58 background_blur_radius_(0),
59 layer_saturation_(0.0f), 59 layer_saturation_(0.0f),
60 layer_brightness_(0.0f), 60 layer_brightness_(0.0f),
61 layer_grayscale_(0.0f), 61 layer_grayscale_(0.0f),
62 layer_inverted_(false), 62 layer_inverted_(false),
63 layer_mask_(NULL), 63 layer_mask_(NULL),
64 layer_mask_back_link_(NULL), 64 layer_mask_back_link_(NULL),
65 zoom_x_offset_(0),
66 zoom_y_offset_(0),
67 zoom_(1),
68 zoom_inset_(0),
65 delegate_(NULL), 69 delegate_(NULL),
66 web_layer_(NULL), 70 web_layer_(NULL),
67 scale_content_(true), 71 scale_content_(true),
68 device_scale_factor_(1.0f) { 72 device_scale_factor_(1.0f) {
69 CreateWebLayer(); 73 CreateWebLayer();
70 } 74 }
71 75
72 Layer::Layer(LayerType type) 76 Layer::Layer(LayerType type)
73 : type_(type), 77 : type_(type),
74 compositor_(NULL), 78 compositor_(NULL),
75 parent_(NULL), 79 parent_(NULL),
76 visible_(true), 80 visible_(true),
77 force_render_surface_(false), 81 force_render_surface_(false),
78 fills_bounds_opaquely_(true), 82 fills_bounds_opaquely_(true),
79 layer_updated_externally_(false), 83 layer_updated_externally_(false),
80 opacity_(1.0f), 84 opacity_(1.0f),
81 background_blur_radius_(0), 85 background_blur_radius_(0),
82 layer_saturation_(0.0f), 86 layer_saturation_(0.0f),
83 layer_brightness_(0.0f), 87 layer_brightness_(0.0f),
84 layer_grayscale_(0.0f), 88 layer_grayscale_(0.0f),
85 layer_inverted_(false), 89 layer_inverted_(false),
86 layer_mask_(NULL), 90 layer_mask_(NULL),
87 layer_mask_back_link_(NULL), 91 layer_mask_back_link_(NULL),
92 zoom_x_offset_(0),
93 zoom_y_offset_(0),
94 zoom_(1),
95 zoom_inset_(0),
88 delegate_(NULL), 96 delegate_(NULL),
89 scale_content_(true), 97 scale_content_(true),
90 device_scale_factor_(1.0f) { 98 device_scale_factor_(1.0f) {
91 CreateWebLayer(); 99 CreateWebLayer();
92 } 100 }
93 101
94 Layer::~Layer() { 102 Layer::~Layer() {
95 // Destroying the animator may cause observers to use the layer (and 103 // Destroying the animator may cause observers to use the layer (and
96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer 104 // indirectly the WebLayer). Destroy the animator first so that the WebLayer
97 // is still around. 105 // is still around.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 while (current) { 235 while (current) {
228 opacity *= current->opacity_; 236 opacity *= current->opacity_;
229 current = current->parent_; 237 current = current->parent_;
230 } 238 }
231 return opacity; 239 return opacity;
232 } 240 }
233 241
234 void Layer::SetBackgroundBlur(int blur_radius) { 242 void Layer::SetBackgroundBlur(int blur_radius) {
235 background_blur_radius_ = blur_radius; 243 background_blur_radius_ = blur_radius;
236 244
237 WebKit::WebFilterOperations filters; 245 SetLayerBackgroundFilters();
238 if (background_blur_radius_) {
239 filters.append(WebKit::WebFilterOperation::createBlurFilter(
240 background_blur_radius_));
241 }
242 web_layer_->setBackgroundFilters(filters);
243 } 246 }
244 247
245 void Layer::SetLayerSaturation(float saturation) { 248 void Layer::SetLayerSaturation(float saturation) {
246 layer_saturation_ = saturation; 249 layer_saturation_ = saturation;
247 SetLayerFilters(); 250 SetLayerFilters();
248 } 251 }
249 252
250 void Layer::SetLayerBrightness(float brightness) { 253 void Layer::SetLayerBrightness(float brightness) {
251 GetAnimator()->SetBrightness(brightness); 254 GetAnimator()->SetBrightness(brightness);
252 } 255 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 layer_mask_->layer_mask_back_link_ = NULL; 294 layer_mask_->layer_mask_back_link_ = NULL;
292 layer_mask_ = layer_mask; 295 layer_mask_ = layer_mask;
293 web_layer_->setMaskLayer( 296 web_layer_->setMaskLayer(
294 layer_mask ? layer_mask->web_layer() : NULL); 297 layer_mask ? layer_mask->web_layer() : NULL);
295 // We need to reference the linked object so that it can properly break the 298 // We need to reference the linked object so that it can properly break the
296 // link to us when it gets deleted. 299 // link to us when it gets deleted.
297 if (layer_mask) 300 if (layer_mask)
298 layer_mask->layer_mask_back_link_ = this; 301 layer_mask->layer_mask_back_link_ = this;
299 } 302 }
300 303
304 void Layer::SetBackgroundZoom(float x_offset, float y_offset, float zoom,
sky 2012/10/11 17:00:49 When you wrap one arg, wrap them all.
Zachary Kuznia 2012/10/12 08:41:35 Done.
305 int inset) {
306 zoom_x_offset_ = x_offset;
307 zoom_y_offset_ = y_offset;
308 zoom_ = zoom;
309 zoom_inset_ = inset;
310
311 SetLayerBackgroundFilters();
312 }
313
301 void Layer::SetLayerFilters() { 314 void Layer::SetLayerFilters() {
302 WebKit::WebFilterOperations filters; 315 WebKit::WebFilterOperations filters;
303 if (layer_saturation_) { 316 if (layer_saturation_) {
304 filters.append(WebKit::WebFilterOperation::createSaturateFilter( 317 filters.append(WebKit::WebFilterOperation::createSaturateFilter(
305 layer_saturation_)); 318 layer_saturation_));
306 } 319 }
307 if (layer_grayscale_) { 320 if (layer_grayscale_) {
308 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter( 321 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter(
309 layer_grayscale_)); 322 layer_grayscale_));
310 } 323 }
311 if (layer_inverted_) 324 if (layer_inverted_)
312 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0)); 325 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0));
313 // Brightness goes last, because the resulting colors neeed clamping, which 326 // Brightness goes last, because the resulting colors neeed clamping, which
314 // cause further color matrix filters to be applied separately. In this order, 327 // cause further color matrix filters to be applied separately. In this order,
315 // they all can be combined in a single pass. 328 // they all can be combined in a single pass.
316 if (layer_brightness_) { 329 if (layer_brightness_) {
317 filters.append(WebKit::WebFilterOperation::createBrightnessFilter( 330 filters.append(WebKit::WebFilterOperation::createBrightnessFilter(
318 layer_brightness_)); 331 layer_brightness_));
319 } 332 }
320 333
321 web_layer_->setFilters(filters); 334 web_layer_->setFilters(filters);
322 } 335 }
323 336
337 void Layer::SetLayerBackgroundFilters() {
338 WebKit::WebFilterOperations filters;
339 if (zoom_ != 1) {
340 filters.append(WebKit::WebFilterOperation::createZoomFilter(
341 WebKit::WebRect(zoom_x_offset_, zoom_y_offset_,
342 (GetTargetBounds().width() / zoom_),
343 (GetTargetBounds().height() / zoom_)),
344 zoom_inset_));
345 }
346
347 if (background_blur_radius_) {
348 filters.append(WebKit::WebFilterOperation::createBlurFilter(
349 background_blur_radius_));
350 }
351
352 web_layer_->setBackgroundFilters(filters);
353 }
354
324 float Layer::GetTargetOpacity() const { 355 float Layer::GetTargetOpacity() const {
325 if (animator_.get() && animator_->IsAnimatingProperty( 356 if (animator_.get() && animator_->IsAnimatingProperty(
326 LayerAnimationElement::OPACITY)) 357 LayerAnimationElement::OPACITY))
327 return animator_->GetTargetOpacity(); 358 return animator_->GetTargetOpacity();
328 return opacity_; 359 return opacity_;
329 } 360 }
330 361
331 void Layer::SetVisible(bool visible) { 362 void Layer::SetVisible(bool visible) {
332 GetAnimator()->SetVisibility(visible); 363 GetAnimator()->SetVisibility(visible);
333 } 364 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 return; 808 return;
778 unsigned int color = 0xFF000000; 809 unsigned int color = 0xFF000000;
779 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 810 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
780 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 811 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
781 if (!opaque) 812 if (!opaque)
782 color |= 0xFF; 813 color |= 0xFF;
783 web_layer_->setDebugBorderColor(color); 814 web_layer_->setDebugBorderColor(color);
784 } 815 }
785 816
786 } // namespace ui 817 } // namespace ui
OLDNEW
« ui/compositor/layer.h ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698