| 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_layer_impl.h" | 9 #include "cc/layers/picture_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 "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 13 #include "cc/trees/layer_tree_settings.h" | 13 #include "cc/trees/layer_tree_settings.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkImage.h" | 15 #include "third_party/skia/include/core/SkImage.h" |
| 16 #include "third_party/skia/include/core/SkPictureRecorder.h" | 16 #include "skia/ext/cdl_picture_recorder.h" |
| 17 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { | 21 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { |
| 22 return make_scoped_refptr(new PictureImageLayer()); | 22 return make_scoped_refptr(new PictureImageLayer()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} | 25 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} |
| 26 | 26 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DCHECK_GT(image_->width(), 0); | 62 DCHECK_GT(image_->width(), 0); |
| 63 DCHECK_GT(image_->height(), 0); | 63 DCHECK_GT(image_->height(), 0); |
| 64 DCHECK(layer_tree_host()); | 64 DCHECK(layer_tree_host()); |
| 65 | 65 |
| 66 DisplayItemListSettings settings; | 66 DisplayItemListSettings settings; |
| 67 settings.use_cached_picture = | 67 settings.use_cached_picture = |
| 68 layer_tree_host()->GetSettings().use_cached_picture_raster; | 68 layer_tree_host()->GetSettings().use_cached_picture_raster; |
| 69 scoped_refptr<DisplayItemList> display_list = | 69 scoped_refptr<DisplayItemList> display_list = |
| 70 DisplayItemList::Create(settings); | 70 DisplayItemList::Create(settings); |
| 71 | 71 |
| 72 SkPictureRecorder recorder; | 72 CdlPictureRecorder recorder; |
| 73 SkCanvas* canvas = | 73 CdlCanvas* canvas = |
| 74 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 74 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); |
| 75 | 75 |
| 76 SkScalar content_to_layer_scale_x = | 76 SkScalar content_to_layer_scale_x = |
| 77 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); | 77 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); |
| 78 SkScalar content_to_layer_scale_y = | 78 SkScalar content_to_layer_scale_y = |
| 79 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); | 79 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); |
| 80 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); | 80 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); |
| 81 | 81 |
| 82 // Because Android WebView resourceless software draw mode rasters directly | 82 // Because Android WebView resourceless software draw mode rasters directly |
| 83 // to the root canvas, this draw must use the kSrcOver_Mode so that | 83 // to the root canvas, this draw must use the kSrcOver_Mode so that |
| 84 // transparent images blend correctly. | 84 // transparent images blend correctly. |
| 85 canvas->drawImage(image_.get(), 0, 0); | 85 canvas->drawImage(image_.get(), 0, 0); |
| 86 | 86 |
| 87 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 87 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 88 PaintableRegion(), recorder.finishRecordingAsPicture()); | 88 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 89 | 89 |
| 90 display_list->Finalize(); | 90 display_list->Finalize(); |
| 91 return display_list; | 91 return display_list; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool PictureImageLayer::FillsBoundsCompletely() const { | 94 bool PictureImageLayer::FillsBoundsCompletely() const { |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 | 97 |
| 98 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { | 98 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { |
| 99 return 0; | 99 return 0; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace cc | 102 } // namespace cc |
| OLD | NEW |