| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "cc/base/scoped_ptr_algorithm.h" | 13 #include "cc/base/scoped_ptr_algorithm.h" |
| 14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
| 15 #include "cc/layers/delegated_renderer_layer.h" | 15 #include "cc/layers/delegated_renderer_layer.h" |
| 16 #include "cc/layers/solid_color_layer.h" | 16 #include "cc/layers/solid_color_layer.h" |
| 17 #include "cc/layers/texture_layer.h" | 17 #include "cc/layers/texture_layer.h" |
| 18 #include "cc/output/delegated_frame_data.h" | 18 #include "cc/output/delegated_frame_data.h" |
| 19 #include "cc/output/filter_operation.h" |
| 20 #include "cc/output/filter_operations.h" |
| 19 #include "cc/resources/transferable_resource.h" | 21 #include "cc/resources/transferable_resource.h" |
| 20 #include "third_party/WebKit/public/platform/WebFilterOperation.h" | |
| 21 #include "third_party/WebKit/public/platform/WebFilterOperations.h" | |
| 22 #include "ui/base/animation/animation.h" | 22 #include "ui/base/animation/animation.h" |
| 23 #include "ui/compositor/compositor_switches.h" | 23 #include "ui/compositor/compositor_switches.h" |
| 24 #include "ui/compositor/dip_util.h" | 24 #include "ui/compositor/dip_util.h" |
| 25 #include "ui/compositor/layer_animator.h" | 25 #include "ui/compositor/layer_animator.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/display.h" | 27 #include "ui/gfx/display.h" |
| 28 #include "ui/gfx/interpolated_transform.h" | 28 #include "ui/gfx/interpolated_transform.h" |
| 29 #include "ui/gfx/point3_f.h" | 29 #include "ui/gfx/point3_f.h" |
| 30 #include "ui/gfx/point_conversions.h" | 30 #include "ui/gfx/point_conversions.h" |
| 31 #include "ui/gfx/size_conversions.h" | 31 #include "ui/gfx/size_conversions.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 | 308 |
| 309 void Layer::SetBackgroundZoom(float zoom, int inset) { | 309 void Layer::SetBackgroundZoom(float zoom, int inset) { |
| 310 zoom_ = zoom; | 310 zoom_ = zoom; |
| 311 zoom_inset_ = inset; | 311 zoom_inset_ = inset; |
| 312 | 312 |
| 313 SetLayerBackgroundFilters(); | 313 SetLayerBackgroundFilters(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void Layer::SetLayerFilters() { | 316 void Layer::SetLayerFilters() { |
| 317 WebKit::WebFilterOperations filters; | 317 cc::FilterOperations filters; |
| 318 if (layer_saturation_) { | 318 if (layer_saturation_) { |
| 319 filters.append(WebKit::WebFilterOperation::createSaturateFilter( | 319 filters.Append(cc::FilterOperation::CreateSaturateFilter( |
| 320 layer_saturation_)); | 320 layer_saturation_)); |
| 321 } | 321 } |
| 322 if (layer_grayscale_) { | 322 if (layer_grayscale_) { |
| 323 filters.append(WebKit::WebFilterOperation::createGrayscaleFilter( | 323 filters.Append(cc::FilterOperation::CreateGrayscaleFilter( |
| 324 layer_grayscale_)); | 324 layer_grayscale_)); |
| 325 } | 325 } |
| 326 if (layer_inverted_) | 326 if (layer_inverted_) |
| 327 filters.append(WebKit::WebFilterOperation::createInvertFilter(1.0)); | 327 filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); |
| 328 // Brightness goes last, because the resulting colors neeed clamping, which | 328 // Brightness goes last, because the resulting colors neeed clamping, which |
| 329 // cause further color matrix filters to be applied separately. In this order, | 329 // cause further color matrix filters to be applied separately. In this order, |
| 330 // they all can be combined in a single pass. | 330 // they all can be combined in a single pass. |
| 331 if (layer_brightness_) { | 331 if (layer_brightness_) { |
| 332 filters.append(WebKit::WebFilterOperation::createSaturatingBrightnessFilter( | 332 filters.Append(cc::FilterOperation::CreateSaturatingBrightnessFilter( |
| 333 layer_brightness_)); | 333 layer_brightness_)); |
| 334 } | 334 } |
| 335 | 335 |
| 336 cc_layer_->SetFilters(filters); | 336 cc_layer_->SetFilters(filters); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void Layer::SetLayerBackgroundFilters() { | 339 void Layer::SetLayerBackgroundFilters() { |
| 340 WebKit::WebFilterOperations filters; | 340 cc::FilterOperations filters; |
| 341 if (zoom_ != 1) { | 341 if (zoom_ != 1) |
| 342 filters.append(WebKit::WebFilterOperation::createZoomFilter(zoom_, | 342 filters.Append(cc::FilterOperation::CreateZoomFilter(zoom_, zoom_inset_)); |
| 343 zoom_inset_)); | |
| 344 } | |
| 345 | 343 |
| 346 if (background_blur_radius_) { | 344 if (background_blur_radius_) { |
| 347 filters.append(WebKit::WebFilterOperation::createBlurFilter( | 345 filters.Append(cc::FilterOperation::CreateBlurFilter( |
| 348 background_blur_radius_)); | 346 background_blur_radius_)); |
| 349 } | 347 } |
| 350 | 348 |
| 351 cc_layer_->SetBackgroundFilters(filters); | 349 cc_layer_->SetBackgroundFilters(filters); |
| 352 } | 350 } |
| 353 | 351 |
| 354 float Layer::GetTargetOpacity() const { | 352 float Layer::GetTargetOpacity() const { |
| 355 if (animator_.get() && animator_->IsAnimatingProperty( | 353 if (animator_.get() && animator_->IsAnimatingProperty( |
| 356 LayerAnimationElement::OPACITY)) | 354 LayerAnimationElement::OPACITY)) |
| 357 return animator_->GetTargetOpacity(); | 355 return animator_->GetTargetOpacity(); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 971 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
| 974 } | 972 } |
| 975 | 973 |
| 976 void Layer::RecomputePosition() { | 974 void Layer::RecomputePosition() { |
| 977 cc_layer_->SetPosition(gfx::ScalePoint( | 975 cc_layer_->SetPosition(gfx::ScalePoint( |
| 978 gfx::PointF(bounds_.x(), bounds_.y()), | 976 gfx::PointF(bounds_.x(), bounds_.y()), |
| 979 device_scale_factor_)); | 977 device_scale_factor_)); |
| 980 } | 978 } |
| 981 | 979 |
| 982 } // namespace ui | 980 } // namespace ui |
| OLD | NEW |