Chromium Code Reviews| 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 "base/command_line.h" | |
| 10 #include "cc/base/switches.h" | |
| 9 #include "cc/layers/picture_image_layer_impl.h" | 11 #include "cc/layers/picture_image_layer_impl.h" |
| 10 #include "cc/playback/display_item_list_settings.h" | 12 #include "cc/playback/display_item_list_settings.h" |
| 11 #include "cc/playback/drawing_display_item.h" | 13 #include "cc/playback/drawing_display_item.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 #include "third_party/skia/include/core/SkImage.h" | 15 #include "third_party/skia/include/core/SkImage.h" |
| 14 #include "third_party/skia/include/core/SkPictureRecorder.h" | 16 #include "third_party/skia/include/core/SkPictureRecorder.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 |
| 21 namespace { | |
| 22 | |
| 23 static bool UseCachedPictureRaster() { | |
|
vmpstr
2016/03/25 21:45:12
Is it possible to plumb this through layer tree se
Khushal
2016/03/25 21:53:48
Sure I can add a LayerTreeSetting for this. Yup, c
| |
| 24 static bool use = !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 25 switches::kDisableCachedPictureRaster); | |
| 26 return use; | |
| 27 } | |
| 28 } | |
| 29 | |
| 19 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { | 30 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { |
| 20 return make_scoped_refptr(new PictureImageLayer()); | 31 return make_scoped_refptr(new PictureImageLayer()); |
| 21 } | 32 } |
| 22 | 33 |
| 23 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} | 34 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} |
| 24 | 35 |
| 25 PictureImageLayer::~PictureImageLayer() { | 36 PictureImageLayer::~PictureImageLayer() { |
| 26 ClearClient(); | 37 ClearClient(); |
| 27 } | 38 } |
| 28 | 39 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 51 gfx::Rect PictureImageLayer::PaintableRegion() { | 62 gfx::Rect PictureImageLayer::PaintableRegion() { |
| 52 return gfx::Rect(bounds()); | 63 return gfx::Rect(bounds()); |
| 53 } | 64 } |
| 54 | 65 |
| 55 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( | 66 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( |
| 56 ContentLayerClient::PaintingControlSetting painting_control) { | 67 ContentLayerClient::PaintingControlSetting painting_control) { |
| 57 DCHECK(image_); | 68 DCHECK(image_); |
| 58 DCHECK_GT(image_->width(), 0); | 69 DCHECK_GT(image_->width(), 0); |
| 59 DCHECK_GT(image_->height(), 0); | 70 DCHECK_GT(image_->height(), 0); |
| 60 | 71 |
| 61 // Picture image layers can be used with GatherPixelRefs, so cached SkPictures | |
| 62 // are currently required. | |
| 63 DisplayItemListSettings settings; | 72 DisplayItemListSettings settings; |
| 64 settings.use_cached_picture = true; | 73 settings.use_cached_picture = UseCachedPictureRaster(); |
| 65 scoped_refptr<DisplayItemList> display_list = | 74 scoped_refptr<DisplayItemList> display_list = |
| 66 DisplayItemList::Create(PaintableRegion(), settings); | 75 DisplayItemList::Create(PaintableRegion(), settings); |
| 67 | 76 |
| 68 SkPictureRecorder recorder; | 77 SkPictureRecorder recorder; |
| 69 SkCanvas* canvas = | 78 SkCanvas* canvas = |
| 70 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 79 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); |
| 71 | 80 |
| 72 SkScalar content_to_layer_scale_x = | 81 SkScalar content_to_layer_scale_x = |
| 73 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); | 82 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); |
| 74 SkScalar content_to_layer_scale_y = | 83 SkScalar content_to_layer_scale_y = |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 89 | 98 |
| 90 bool PictureImageLayer::FillsBoundsCompletely() const { | 99 bool PictureImageLayer::FillsBoundsCompletely() const { |
| 91 return false; | 100 return false; |
| 92 } | 101 } |
| 93 | 102 |
| 94 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { | 103 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { |
| 95 return 0; | 104 return 0; |
| 96 } | 105 } |
| 97 | 106 |
| 98 } // namespace cc | 107 } // namespace cc |
| OLD | NEW |