| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   51       force_render_surface_(false), |   51       force_render_surface_(false), | 
|   52       fills_bounds_opaquely_(true), |   52       fills_bounds_opaquely_(true), | 
|   53       layer_updated_externally_(false), |   53       layer_updated_externally_(false), | 
|   54       background_blur_radius_(0), |   54       background_blur_radius_(0), | 
|   55       layer_saturation_(0.0f), |   55       layer_saturation_(0.0f), | 
|   56       layer_brightness_(0.0f), |   56       layer_brightness_(0.0f), | 
|   57       layer_grayscale_(0.0f), |   57       layer_grayscale_(0.0f), | 
|   58       layer_inverted_(false), |   58       layer_inverted_(false), | 
|   59       layer_mask_(NULL), |   59       layer_mask_(NULL), | 
|   60       layer_mask_back_link_(NULL), |   60       layer_mask_back_link_(NULL), | 
|   61       zoom_x_offset_(0), |  | 
|   62       zoom_y_offset_(0), |  | 
|   63       zoom_(1), |   61       zoom_(1), | 
|   64       zoom_inset_(0), |   62       zoom_inset_(0), | 
|   65       delegate_(NULL), |   63       delegate_(NULL), | 
|   66       cc_layer_(NULL), |   64       cc_layer_(NULL), | 
|   67       scale_content_(true), |   65       scale_content_(true), | 
|   68       device_scale_factor_(1.0f) { |   66       device_scale_factor_(1.0f) { | 
|   69   CreateWebLayer(); |   67   CreateWebLayer(); | 
|   70 } |   68 } | 
|   71  |   69  | 
|   72 Layer::Layer(LayerType type) |   70 Layer::Layer(LayerType type) | 
|   73     : type_(type), |   71     : type_(type), | 
|   74       compositor_(NULL), |   72       compositor_(NULL), | 
|   75       parent_(NULL), |   73       parent_(NULL), | 
|   76       visible_(true), |   74       visible_(true), | 
|   77       is_drawn_(true), |   75       is_drawn_(true), | 
|   78       force_render_surface_(false), |   76       force_render_surface_(false), | 
|   79       fills_bounds_opaquely_(true), |   77       fills_bounds_opaquely_(true), | 
|   80       layer_updated_externally_(false), |   78       layer_updated_externally_(false), | 
|   81       background_blur_radius_(0), |   79       background_blur_radius_(0), | 
|   82       layer_saturation_(0.0f), |   80       layer_saturation_(0.0f), | 
|   83       layer_brightness_(0.0f), |   81       layer_brightness_(0.0f), | 
|   84       layer_grayscale_(0.0f), |   82       layer_grayscale_(0.0f), | 
|   85       layer_inverted_(false), |   83       layer_inverted_(false), | 
|   86       layer_mask_(NULL), |   84       layer_mask_(NULL), | 
|   87       layer_mask_back_link_(NULL), |   85       layer_mask_back_link_(NULL), | 
|   88       zoom_x_offset_(0), |  | 
|   89       zoom_y_offset_(0), |  | 
|   90       zoom_(1), |   86       zoom_(1), | 
|   91       zoom_inset_(0), |   87       zoom_inset_(0), | 
|   92       delegate_(NULL), |   88       delegate_(NULL), | 
|   93       scale_content_(true), |   89       scale_content_(true), | 
|   94       device_scale_factor_(1.0f) { |   90       device_scale_factor_(1.0f) { | 
|   95   CreateWebLayer(); |   91   CreateWebLayer(); | 
|   96 } |   92 } | 
|   97  |   93  | 
|   98 Layer::~Layer() { |   94 Layer::~Layer() { | 
|   99   // Destroying the animator may cause observers to use the layer (and |   95   // Destroying the animator may cause observers to use the layer (and | 
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  302   cc_layer_->SetMaskLayer( |  298   cc_layer_->SetMaskLayer( | 
|  303       layer_mask ? layer_mask->cc_layer() : NULL); |  299       layer_mask ? layer_mask->cc_layer() : NULL); | 
|  304   // We need to reference the linked object so that it can properly break the |  300   // We need to reference the linked object so that it can properly break the | 
|  305   // link to us when it gets deleted. |  301   // link to us when it gets deleted. | 
|  306   if (layer_mask) { |  302   if (layer_mask) { | 
|  307     layer_mask->layer_mask_back_link_ = this; |  303     layer_mask->layer_mask_back_link_ = this; | 
|  308     layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_); |  304     layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_); | 
|  309   } |  305   } | 
|  310 } |  306 } | 
|  311  |  307  | 
|  312 void Layer::SetBackgroundZoom(float x_offset, |  308 void Layer::SetBackgroundZoom(float zoom, int inset) { | 
|  313                               float y_offset, |  | 
|  314                               float zoom, |  | 
|  315                               int inset) { |  | 
|  316   zoom_x_offset_ = x_offset; |  | 
|  317   zoom_y_offset_ = y_offset; |  | 
|  318   zoom_ = zoom; |  309   zoom_ = zoom; | 
|  319   zoom_inset_ = inset; |  310   zoom_inset_ = inset; | 
|  320  |  311  | 
|  321   SetLayerBackgroundFilters(); |  312   SetLayerBackgroundFilters(); | 
|  322 } |  313 } | 
|  323  |  314  | 
|  324 void Layer::SetLayerFilters() { |  315 void Layer::SetLayerFilters() { | 
|  325   WebKit::WebFilterOperations filters; |  316   WebKit::WebFilterOperations filters; | 
|  326   if (layer_saturation_) { |  317   if (layer_saturation_) { | 
|  327     filters.append(WebKit::WebFilterOperation::createSaturateFilter( |  318     filters.append(WebKit::WebFilterOperation::createSaturateFilter( | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  340     filters.append(WebKit::WebFilterOperation::createSaturatingBrightnessFilter( |  331     filters.append(WebKit::WebFilterOperation::createSaturatingBrightnessFilter( | 
|  341         layer_brightness_)); |  332         layer_brightness_)); | 
|  342   } |  333   } | 
|  343  |  334  | 
|  344   cc_layer_->SetFilters(filters); |  335   cc_layer_->SetFilters(filters); | 
|  345 } |  336 } | 
|  346  |  337  | 
|  347 void Layer::SetLayerBackgroundFilters() { |  338 void Layer::SetLayerBackgroundFilters() { | 
|  348   WebKit::WebFilterOperations filters; |  339   WebKit::WebFilterOperations filters; | 
|  349   if (zoom_ != 1) { |  340   if (zoom_ != 1) { | 
|  350     filters.append(WebKit::WebFilterOperation::createZoomFilter( |  341 #ifdef NEW_ZOOM_FILTER // TODO(danakj): Remove this when WebKit rolls. | 
|  351         WebKit::WebRect(zoom_x_offset_, zoom_y_offset_, |  342     filters.append(WebKit::WebFilterOperation::createZoomFilter(zoom_, | 
|  352                         (GetTargetBounds().width() / zoom_), |  343                                                                 zoom_inset_)); | 
|  353                         (GetTargetBounds().height() / zoom_)), |  344 #endif | 
|  354         zoom_inset_)); |  | 
|  355   } |  345   } | 
|  356  |  346  | 
|  357   if (background_blur_radius_) { |  347   if (background_blur_radius_) { | 
|  358     filters.append(WebKit::WebFilterOperation::createBlurFilter( |  348     filters.append(WebKit::WebFilterOperation::createBlurFilter( | 
|  359         background_blur_radius_)); |  349         background_blur_radius_)); | 
|  360   } |  350   } | 
|  361  |  351  | 
|  362   cc_layer_->SetBackgroundFilters(filters); |  352   cc_layer_->SetBackgroundFilters(filters); | 
|  363 } |  353 } | 
|  364  |  354  | 
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  911     texture_layer_->setUV(uv_top_left, uv_bottom_right); |  901     texture_layer_->setUV(uv_top_left, uv_bottom_right); | 
|  912   } else if (delegated_renderer_layer_.get()) { |  902   } else if (delegated_renderer_layer_.get()) { | 
|  913     delegated_renderer_layer_->SetDisplaySize( |  903     delegated_renderer_layer_->SetDisplaySize( | 
|  914         ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); |  904         ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); | 
|  915     size.ClampToMax(delegated_frame_size_in_dip_); |  905     size.ClampToMax(delegated_frame_size_in_dip_); | 
|  916   } |  906   } | 
|  917   cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |  907   cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 
|  918 } |  908 } | 
|  919  |  909  | 
|  920 }  // namespace ui |  910 }  // namespace ui | 
| OLD | NEW |