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

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
« chrome/common/pref_names.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),
piman 2012/10/09 17:38:05 zoom_inset_ should be initialized.
Zachary Kuznia 2012/10/10 09:45:43 Done.
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),
piman 2012/10/09 17:38:05 zoom_inset_ should be initialized.
Zachary Kuznia 2012/10/10 09:45:43 Done.
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 while (current) { 233 while (current) {
228 opacity *= current->opacity_; 234 opacity *= current->opacity_;
229 current = current->parent_; 235 current = current->parent_;
230 } 236 }
231 return opacity; 237 return opacity;
232 } 238 }
233 239
234 void Layer::SetBackgroundBlur(int blur_radius) { 240 void Layer::SetBackgroundBlur(int blur_radius) {
235 background_blur_radius_ = blur_radius; 241 background_blur_radius_ = blur_radius;
236 242
237 WebKit::WebFilterOperations filters; 243 SetLayerBackgroundFilters();
238 if (background_blur_radius_) {
239 filters.append(WebKit::WebFilterOperation::createBlurFilter(
240 background_blur_radius_));
241 }
242 web_layer_->setBackgroundFilters(filters);
243 } 244 }
244 245
245 void Layer::SetLayerSaturation(float saturation) { 246 void Layer::SetLayerSaturation(float saturation) {
246 layer_saturation_ = saturation; 247 layer_saturation_ = saturation;
247 SetLayerFilters(); 248 SetLayerFilters();
248 } 249 }
249 250
250 void Layer::SetLayerBrightness(float brightness) { 251 void Layer::SetLayerBrightness(float brightness) {
251 GetAnimator()->SetBrightness(brightness); 252 GetAnimator()->SetBrightness(brightness);
252 } 253 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 layer_mask_->layer_mask_back_link_ = NULL; 292 layer_mask_->layer_mask_back_link_ = NULL;
292 layer_mask_ = layer_mask; 293 layer_mask_ = layer_mask;
293 web_layer_->setMaskLayer( 294 web_layer_->setMaskLayer(
294 layer_mask ? layer_mask->web_layer() : NULL); 295 layer_mask ? layer_mask->web_layer() : NULL);
295 // We need to reference the linked object so that it can properly break the 296 // We need to reference the linked object so that it can properly break the
296 // link to us when it gets deleted. 297 // link to us when it gets deleted.
297 if (layer_mask) 298 if (layer_mask)
298 layer_mask->layer_mask_back_link_ = this; 299 layer_mask->layer_mask_back_link_ = this;
299 } 300 }
300 301
302 void Layer::SetBackgroundZoom(float x_offset, float y_offset, float zoom,
303 int inset) {
304 zoom_x_offset_ = x_offset;
305 zoom_y_offset_ = y_offset;
306 zoom_ = zoom;
307 zoom_inset_ = inset;
308
309 SetLayerBackgroundFilters();
310 }
311
301 void Layer::SetLayerFilters() { 312 void Layer::SetLayerFilters() {
302 WebKit::WebFilterOperations filters; 313 WebKit::WebFilterOperations filters;
303 if (layer_saturation_) { 314 if (layer_saturation_) {
304 filters.append(WebKit::WebFilterOperation::createSaturateFilter( 315 filters.append(WebKit::WebFilterOperation::createSaturateFilter(
305 layer_saturation_)); 316 layer_saturation_));
306 } 317 }
307 if (layer_grayscale_) { 318 if (layer_grayscale_) {
308 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter( 319 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter(
309 layer_grayscale_)); 320 layer_grayscale_));
310 } 321 }
311 if (layer_inverted_) 322 if (layer_inverted_)
312 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0)); 323 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0));
313 // Brightness goes last, because the resulting colors neeed clamping, which 324 // Brightness goes last, because the resulting colors neeed clamping, which
314 // cause further color matrix filters to be applied separately. In this order, 325 // cause further color matrix filters to be applied separately. In this order,
315 // they all can be combined in a single pass. 326 // they all can be combined in a single pass.
316 if (layer_brightness_) { 327 if (layer_brightness_) {
317 filters.append(WebKit::WebFilterOperation::createBrightnessFilter( 328 filters.append(WebKit::WebFilterOperation::createBrightnessFilter(
318 layer_brightness_)); 329 layer_brightness_));
319 } 330 }
320 331
321 web_layer_->setFilters(filters); 332 web_layer_->setFilters(filters);
322 } 333 }
323 334
335 void Layer::SetLayerBackgroundFilters() {
336 WebKit::WebFilterOperations filters;
337 if (zoom_ != 1) {
338 filters.append(WebKit::WebFilterOperation::createZoomFilter(
339 WebKit::WebRect(zoom_x_offset_, zoom_y_offset_,
340 (GetTargetBounds().width() / zoom_),
341 (GetTargetBounds().height() / zoom_)),
342 zoom_inset_));
343 }
344
345 if (background_blur_radius_) {
346 filters.append(WebKit::WebFilterOperation::createBlurFilter(
347 background_blur_radius_));
348 }
349
350 web_layer_->setBackgroundFilters(filters);
351 }
352
324 float Layer::GetTargetOpacity() const { 353 float Layer::GetTargetOpacity() const {
325 if (animator_.get() && animator_->IsAnimatingProperty( 354 if (animator_.get() && animator_->IsAnimatingProperty(
326 LayerAnimationElement::OPACITY)) 355 LayerAnimationElement::OPACITY))
327 return animator_->GetTargetOpacity(); 356 return animator_->GetTargetOpacity();
328 return opacity_; 357 return opacity_;
329 } 358 }
330 359
331 void Layer::SetVisible(bool visible) { 360 void Layer::SetVisible(bool visible) {
332 GetAnimator()->SetVisibility(visible); 361 GetAnimator()->SetVisibility(visible);
333 } 362 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 return; 806 return;
778 unsigned int color = 0xFF000000; 807 unsigned int color = 0xFF000000;
779 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 808 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
780 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 809 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
781 if (!opaque) 810 if (!opaque)
782 color |= 0xFF; 811 color |= 0xFF;
783 web_layer_->setDebugBorderColor(color); 812 web_layer_->setDebugBorderColor(color);
784 } 813 }
785 814
786 } // namespace ui 815 } // namespace ui
OLDNEW
« chrome/common/pref_names.h ('K') | « ui/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698