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 "cc/layers/picture_image_layer_impl.h" | 7 #include "cc/layers/picture_image_layer_impl.h" |
8 #include "cc/playback/display_item_list_settings.h" | 8 #include "cc/playback/display_item_list_settings.h" |
9 #include "cc/playback/drawing_display_item.h" | 9 #include "cc/playback/drawing_display_item.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // With this check in place we avoid unecessary texture uploads. | 43 // With this check in place we avoid unecessary texture uploads. |
44 if (image_.get() == image.get()) | 44 if (image_.get() == image.get()) |
45 return; | 45 return; |
46 | 46 |
47 image_ = image.Pass(); | 47 image_ = image.Pass(); |
48 UpdateDrawsContent(HasDrawableContent()); | 48 UpdateDrawsContent(HasDrawableContent()); |
49 SetNeedsDisplay(); | 49 SetNeedsDisplay(); |
50 } | 50 } |
51 | 51 |
52 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( | 52 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( |
53 const gfx::Rect& clip, | 53 ContentLayerClient::PaintingControlSetting painting_control, |
54 ContentLayerClient::PaintingControlSetting painting_control) { | 54 gfx::Rect* recording_viewport) { |
55 DCHECK(image_); | 55 DCHECK(image_); |
56 DCHECK_GT(image_->width(), 0); | 56 DCHECK_GT(image_->width(), 0); |
57 DCHECK_GT(image_->height(), 0); | 57 DCHECK_GT(image_->height(), 0); |
58 | 58 |
59 // Picture image layers can be used with GatherPixelRefs, so cached SkPictures | 59 // Picture image layers can be used with GatherPixelRefs, so cached SkPictures |
60 // are currently required. | 60 // are currently required. |
61 DisplayItemListSettings settings; | 61 DisplayItemListSettings settings; |
62 settings.use_cached_picture = true; | 62 settings.use_cached_picture = true; |
63 scoped_refptr<DisplayItemList> display_list = | 63 scoped_refptr<DisplayItemList> display_list = |
64 DisplayItemList::Create(clip, settings); | 64 DisplayItemList::Create(*recording_viewport, settings); |
65 | 65 |
66 SkPictureRecorder recorder; | 66 SkPictureRecorder recorder; |
67 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip)); | 67 SkCanvas* canvas = |
| 68 recorder.beginRecording(gfx::RectToSkRect(*recording_viewport)); |
68 | 69 |
69 SkScalar content_to_layer_scale_x = | 70 SkScalar content_to_layer_scale_x = |
70 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); | 71 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); |
71 SkScalar content_to_layer_scale_y = | 72 SkScalar content_to_layer_scale_y = |
72 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); | 73 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); |
73 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); | 74 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); |
74 | 75 |
75 // Because Android WebView resourceless software draw mode rasters directly | 76 // Because Android WebView resourceless software draw mode rasters directly |
76 // to the root canvas, this draw must use the kSrcOver_Mode so that | 77 // to the root canvas, this draw must use the kSrcOver_Mode so that |
77 // transparent images blend correctly. | 78 // transparent images blend correctly. |
(...skipping 10 matching lines...) Expand all Loading... |
88 | 89 |
89 bool PictureImageLayer::FillsBoundsCompletely() const { | 90 bool PictureImageLayer::FillsBoundsCompletely() const { |
90 return false; | 91 return false; |
91 } | 92 } |
92 | 93 |
93 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { | 94 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { |
94 return 0; | 95 return 0; |
95 } | 96 } |
96 | 97 |
97 } // namespace cc | 98 } // namespace cc |
OLD | NEW |