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/paint/paint_canvas.h" |
| 11 #include "cc/paint/paint_recorder.h" |
10 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
11 #include "cc/trees/layer_tree_host.h" | 13 #include "cc/trees/layer_tree_host.h" |
12 #include "cc/trees/layer_tree_settings.h" | 14 #include "cc/trees/layer_tree_settings.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | |
14 #include "third_party/skia/include/core/SkImage.h" | |
15 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
16 #include "ui/gfx/skia_util.h" | |
17 | 15 |
18 namespace cc { | 16 namespace cc { |
19 | 17 |
20 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { | 18 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { |
21 return make_scoped_refptr(new PictureImageLayer()); | 19 return make_scoped_refptr(new PictureImageLayer()); |
22 } | 20 } |
23 | 21 |
24 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} | 22 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} |
25 | 23 |
26 PictureImageLayer::~PictureImageLayer() { | 24 PictureImageLayer::~PictureImageLayer() { |
(...skipping 30 matching lines...) Expand all Loading... |
57 | 55 |
58 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( | 56 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( |
59 ContentLayerClient::PaintingControlSetting painting_control) { | 57 ContentLayerClient::PaintingControlSetting painting_control) { |
60 DCHECK(image_); | 58 DCHECK(image_); |
61 DCHECK_GT(image_->width(), 0); | 59 DCHECK_GT(image_->width(), 0); |
62 DCHECK_GT(image_->height(), 0); | 60 DCHECK_GT(image_->height(), 0); |
63 DCHECK(layer_tree_host()); | 61 DCHECK(layer_tree_host()); |
64 | 62 |
65 auto display_list = make_scoped_refptr(new DisplayItemList); | 63 auto display_list = make_scoped_refptr(new DisplayItemList); |
66 | 64 |
67 SkPictureRecorder recorder; | 65 PaintRecorder recorder; |
68 SkCanvas* canvas = | 66 PaintCanvas* canvas = |
69 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 67 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); |
70 | 68 |
71 SkScalar content_to_layer_scale_x = | 69 SkScalar content_to_layer_scale_x = |
72 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); | 70 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); |
73 SkScalar content_to_layer_scale_y = | 71 SkScalar content_to_layer_scale_y = |
74 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); | 72 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); |
75 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); | 73 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); |
76 | 74 |
77 // Because Android WebView resourceless software draw mode rasters directly | 75 // Because Android WebView resourceless software draw mode rasters directly |
78 // to the root canvas, this draw must use the kSrcOver_Mode so that | 76 // to the root canvas, this draw must use the kSrcOver_Mode so that |
79 // transparent images blend correctly. | 77 // transparent images blend correctly. |
80 canvas->drawImage(image_.get(), 0, 0); | 78 canvas->drawImage(image_.get(), 0, 0); |
81 | 79 |
82 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 80 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
83 PaintableRegion(), recorder.finishRecordingAsPicture()); | 81 PaintableRegion(), recorder.finishRecordingAsPicture()); |
84 | 82 |
85 display_list->Finalize(); | 83 display_list->Finalize(); |
86 return display_list; | 84 return display_list; |
87 } | 85 } |
88 | 86 |
89 bool PictureImageLayer::FillsBoundsCompletely() const { | 87 bool PictureImageLayer::FillsBoundsCompletely() const { |
90 return false; | 88 return false; |
91 } | 89 } |
92 | 90 |
93 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { | 91 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { |
94 return 0; | 92 return 0; |
95 } | 93 } |
96 | 94 |
97 } // namespace cc | 95 } // namespace cc |
OLD | NEW |