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

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, 3 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),
65 delegate_(NULL), 68 delegate_(NULL),
66 web_layer_(NULL), 69 web_layer_(NULL),
67 scale_content_(true), 70 scale_content_(true),
68 device_scale_factor_(1.0f) { 71 device_scale_factor_(1.0f) {
69 CreateWebLayer(); 72 CreateWebLayer();
70 } 73 }
71 74
72 Layer::Layer(LayerType type) 75 Layer::Layer(LayerType type)
73 : type_(type), 76 : type_(type),
74 compositor_(NULL), 77 compositor_(NULL),
75 parent_(NULL), 78 parent_(NULL),
76 visible_(true), 79 visible_(true),
77 force_render_surface_(false), 80 force_render_surface_(false),
78 fills_bounds_opaquely_(true), 81 fills_bounds_opaquely_(true),
79 layer_updated_externally_(false), 82 layer_updated_externally_(false),
80 opacity_(1.0f), 83 opacity_(1.0f),
81 background_blur_radius_(0), 84 background_blur_radius_(0),
82 layer_saturation_(0.0f), 85 layer_saturation_(0.0f),
83 layer_brightness_(0.0f), 86 layer_brightness_(0.0f),
84 layer_grayscale_(0.0f), 87 layer_grayscale_(0.0f),
85 layer_inverted_(false), 88 layer_inverted_(false),
86 layer_mask_(NULL), 89 layer_mask_(NULL),
87 layer_mask_back_link_(NULL), 90 layer_mask_back_link_(NULL),
91 zoom_x_offset_(0),
92 zoom_y_offset_(0),
93 zoom_(1),
88 delegate_(NULL), 94 delegate_(NULL),
89 scale_content_(true), 95 scale_content_(true),
90 device_scale_factor_(1.0f) { 96 device_scale_factor_(1.0f) {
91 CreateWebLayer(); 97 CreateWebLayer();
92 } 98 }
93 99
94 Layer::~Layer() { 100 Layer::~Layer() {
95 // Destroying the animator may cause observers to use the layer (and 101 // Destroying the animator may cause observers to use the layer (and
96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer 102 // indirectly the WebLayer). Destroy the animator first so that the WebLayer
97 // is still around. 103 // is still around.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 while (current) { 231 while (current) {
226 opacity *= current->opacity_; 232 opacity *= current->opacity_;
227 current = current->parent_; 233 current = current->parent_;
228 } 234 }
229 return opacity; 235 return opacity;
230 } 236 }
231 237
232 void Layer::SetBackgroundBlur(int blur_radius) { 238 void Layer::SetBackgroundBlur(int blur_radius) {
233 background_blur_radius_ = blur_radius; 239 background_blur_radius_ = blur_radius;
234 240
235 WebKit::WebFilterOperations filters; 241 SetLayerBackgroundFilters();
236 if (background_blur_radius_) {
237 filters.append(WebKit::WebFilterOperation::createBlurFilter(
238 background_blur_radius_));
239 }
240 web_layer_->setBackgroundFilters(filters);
241 } 242 }
242 243
243 void Layer::SetLayerSaturation(float saturation) { 244 void Layer::SetLayerSaturation(float saturation) {
244 layer_saturation_ = saturation; 245 layer_saturation_ = saturation;
245 SetLayerFilters(); 246 SetLayerFilters();
246 } 247 }
247 248
248 void Layer::SetLayerBrightness(float brightness) { 249 void Layer::SetLayerBrightness(float brightness) {
249 GetAnimator()->SetBrightness(brightness); 250 GetAnimator()->SetBrightness(brightness);
250 } 251 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 layer_mask_->layer_mask_back_link_ = NULL; 290 layer_mask_->layer_mask_back_link_ = NULL;
290 layer_mask_ = layer_mask; 291 layer_mask_ = layer_mask;
291 web_layer_->setMaskLayer( 292 web_layer_->setMaskLayer(
292 layer_mask ? layer_mask->web_layer() : NULL); 293 layer_mask ? layer_mask->web_layer() : NULL);
293 // We need to reference the linked object so that it can properly break the 294 // We need to reference the linked object so that it can properly break the
294 // link to us when it gets deleted. 295 // link to us when it gets deleted.
295 if (layer_mask) 296 if (layer_mask)
296 layer_mask->layer_mask_back_link_ = this; 297 layer_mask->layer_mask_back_link_ = this;
297 } 298 }
298 299
300 void Layer::SetBackgroundZoom(float x_offset, float y_offset, float zoom,
301 int inset) {
302 zoom_x_offset_ = x_offset;
303 zoom_y_offset_ = y_offset;
304 zoom_ = zoom;
305 zoom_inset_ = inset;
306
307 SetLayerBackgroundFilters();
308 }
309
299 void Layer::SetLayerFilters() { 310 void Layer::SetLayerFilters() {
300 WebKit::WebFilterOperations filters; 311 WebKit::WebFilterOperations filters;
301 if (layer_saturation_) { 312 if (layer_saturation_) {
302 filters.append(WebKit::WebFilterOperation::createSaturateFilter( 313 filters.append(WebKit::WebFilterOperation::createSaturateFilter(
303 layer_saturation_)); 314 layer_saturation_));
304 } 315 }
305 if (layer_grayscale_) { 316 if (layer_grayscale_) {
306 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter( 317 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter(
307 layer_grayscale_)); 318 layer_grayscale_));
308 } 319 }
309 if (layer_inverted_) 320 if (layer_inverted_)
310 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0)); 321 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0));
311 // Brightness goes last, because the resulting colors neeed clamping, which 322 // Brightness goes last, because the resulting colors neeed clamping, which
312 // cause further color matrix filters to be applied separately. In this order, 323 // cause further color matrix filters to be applied separately. In this order,
313 // they all can be combined in a single pass. 324 // they all can be combined in a single pass.
314 if (layer_brightness_) { 325 if (layer_brightness_) {
315 filters.append(WebKit::WebFilterOperation::createBrightnessFilter( 326 filters.append(WebKit::WebFilterOperation::createBrightnessFilter(
316 layer_brightness_)); 327 layer_brightness_));
317 } 328 }
318 329
319 web_layer_->setFilters(filters); 330 web_layer_->setFilters(filters);
320 } 331 }
321 332
333 void Layer::SetLayerBackgroundFilters() {
334 WebKit::WebFilterOperations filters;
335 if (zoom_ != 1) {
336 filters.append(WebKit::WebFilterOperation::createZoomFilter(
337 WebKit::WebRect(zoom_x_offset_, zoom_y_offset_,
338 (GetTargetBounds().width() / zoom_),
339 (GetTargetBounds().height() / zoom_)),
340 zoom_inset_));
341 }
342
343 if (background_blur_radius_) {
344 filters.append(WebKit::WebFilterOperation::createBlurFilter(
345 background_blur_radius_));
346 }
347
348 web_layer_->setBackgroundFilters(filters);
349 }
350
322 float Layer::GetTargetOpacity() const { 351 float Layer::GetTargetOpacity() const {
323 if (animator_.get() && animator_->IsAnimatingProperty( 352 if (animator_.get() && animator_->IsAnimatingProperty(
324 LayerAnimationElement::OPACITY)) 353 LayerAnimationElement::OPACITY))
325 return animator_->GetTargetOpacity(); 354 return animator_->GetTargetOpacity();
326 return opacity_; 355 return opacity_;
327 } 356 }
328 357
329 void Layer::SetVisible(bool visible) { 358 void Layer::SetVisible(bool visible) {
330 GetAnimator()->SetVisibility(visible); 359 GetAnimator()->SetVisibility(visible);
331 } 360 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 return; 802 return;
774 unsigned int color = 0xFF000000; 803 unsigned int color = 0xFF000000;
775 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 804 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
776 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 805 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
777 if (!opaque) 806 if (!opaque)
778 color |= 0xFF; 807 color |= 0xFF;
779 web_layer_->setDebugBorderColor(color); 808 web_layer_->setDebugBorderColor(color);
780 } 809 }
781 810
782 } // namespace ui 811 } // 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