| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/layers/picture_image_layer.h" | 5 #include "cc/layers/picture_image_layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/layers/picture_image_layer_impl.h" | 9 #include "cc/layers/picture_image_layer_impl.h" |
| 10 #include "cc/playback/display_item_list_settings.h" | 10 #include "cc/playback/display_item_list_settings.h" |
| 11 #include "cc/playback/drawing_display_item.h" | 11 #include "cc/playback/drawing_display_item.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 #include "third_party/skia/include/core/SkColorFilter.h" |
| 13 #include "third_party/skia/include/core/SkImage.h" | 14 #include "third_party/skia/include/core/SkImage.h" |
| 14 #include "third_party/skia/include/core/SkPictureRecorder.h" | 15 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 16 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" |
| 15 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 16 | 18 |
| 17 namespace cc { | 19 namespace cc { |
| 18 | 20 |
| 19 scoped_refptr<PictureImageLayer> PictureImageLayer::Create( | 21 scoped_refptr<PictureImageLayer> PictureImageLayer::Create( |
| 20 const LayerSettings& settings) { | 22 const LayerSettings& settings) { |
| 21 return make_scoped_refptr(new PictureImageLayer(settings)); | 23 return make_scoped_refptr(new PictureImageLayer(settings)); |
| 22 } | 24 } |
| 23 | 25 |
| 24 PictureImageLayer::PictureImageLayer(const LayerSettings& settings) | 26 PictureImageLayer::PictureImageLayer(const LayerSettings& settings) |
| 25 : PictureLayer(settings, this) { | 27 : PictureLayer(settings, this) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 PictureImageLayer::~PictureImageLayer() { | 30 PictureImageLayer::~PictureImageLayer() { |
| 29 ClearClient(); | 31 ClearClient(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl( | 34 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl( |
| 33 LayerTreeImpl* tree_impl) { | 35 LayerTreeImpl* tree_impl) { |
| 34 return PictureImageLayerImpl::Create(tree_impl, id(), is_mask()); | 36 return PictureImageLayerImpl::Create(tree_impl, id(), is_mask()); |
| 35 } | 37 } |
| 36 | 38 |
| 37 bool PictureImageLayer::HasDrawableContent() const { | 39 bool PictureImageLayer::HasDrawableContent() const { |
| 38 return image_ && PictureLayer::HasDrawableContent(); | 40 return image_ && PictureLayer::HasDrawableContent(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void PictureImageLayer::SetImage(skia::RefPtr<const SkImage> image) { | 43 void PictureImageLayer::SetImage(skia::RefPtr<const SkImage> image, |
| 44 skia::RefPtr<SkColorFilter> transform) { |
| 45 // SetImage() may be called when color transforms change: usually |
| 46 // the image has not changed, but its rendered paint should. |
| 47 if (transform_.get() != transform.get()) { |
| 48 transform_ = std::move(transform); |
| 49 FilterOperations filters; |
| 50 if (transform_.get()) { |
| 51 skia::RefPtr<SkImageFilter> color_transform_filter = |
| 52 skia::AdoptRef(SkColorFilterImageFilter::Create(transform_.get())); |
| 53 FilterOperation color_transform_operation = |
| 54 FilterOperation::CreateReferenceFilter(color_transform_filter); |
| 55 filters.Append(color_transform_operation); |
| 56 } |
| 57 this->Layer::SetFilters(filters); |
| 58 } |
| 59 |
| 42 // SetImage() currently gets called whenever there is any | 60 // SetImage() currently gets called whenever there is any |
| 43 // style change that affects the layer even if that change doesn't | 61 // style change that affects the layer even if that change doesn't |
| 44 // affect the actual contents of the image (e.g. a CSS animation). | 62 // affect the actual contents of the image (e.g. a CSS animation). |
| 45 // With this check in place we avoid unecessary texture uploads. | 63 // With this check in place we avoid unecessary texture uploads. |
| 46 if (image_.get() == image.get()) | 64 if (image_.get() == image.get()) |
| 47 return; | 65 return; |
| 48 | 66 |
| 49 image_ = std::move(image); | 67 image_ = std::move(image); |
| 50 UpdateDrawsContent(HasDrawableContent()); | 68 UpdateDrawsContent(HasDrawableContent()); |
| 51 SetNeedsDisplay(); | 69 SetNeedsDisplay(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 112 |
| 95 bool PictureImageLayer::FillsBoundsCompletely() const { | 113 bool PictureImageLayer::FillsBoundsCompletely() const { |
| 96 return false; | 114 return false; |
| 97 } | 115 } |
| 98 | 116 |
| 99 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { | 117 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { |
| 100 return 0; | 118 return 0; |
| 101 } | 119 } |
| 102 | 120 |
| 103 } // namespace cc | 121 } // namespace cc |
| OLD | NEW |