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/resources/drawing_display_item.h" | 8 #include "cc/resources/drawing_display_item.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 return; | 40 return; |
41 | 41 |
42 bitmap_ = bitmap; | 42 bitmap_ = bitmap; |
43 UpdateDrawsContent(HasDrawableContent()); | 43 UpdateDrawsContent(HasDrawableContent()); |
44 SetNeedsDisplay(); | 44 SetNeedsDisplay(); |
45 } | 45 } |
46 | 46 |
47 void PictureImageLayer::PaintContents( | 47 void PictureImageLayer::PaintContents( |
48 SkCanvas* canvas, | 48 SkCanvas* canvas, |
49 const gfx::Rect& clip, | 49 const gfx::Rect& clip, |
50 ContentLayerClient::GraphicsContextStatus gc_status) { | 50 ContentLayerClient::PaintingControlSetting painting_control) { |
51 if (!bitmap_.width() || !bitmap_.height()) | 51 if (!bitmap_.width() || !bitmap_.height()) |
52 return; | 52 return; |
53 | 53 |
54 SkScalar content_to_layer_scale_x = | 54 SkScalar content_to_layer_scale_x = |
55 SkFloatToScalar(static_cast<float>(bounds().width()) / bitmap_.width()); | 55 SkFloatToScalar(static_cast<float>(bounds().width()) / bitmap_.width()); |
56 SkScalar content_to_layer_scale_y = | 56 SkScalar content_to_layer_scale_y = |
57 SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height()); | 57 SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height()); |
58 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); | 58 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); |
59 | 59 |
60 // Because Android WebView resourceless software draw mode rasters directly | 60 // Because Android WebView resourceless software draw mode rasters directly |
61 // to the root canvas, this draw must use the kSrcOver_Mode so that | 61 // to the root canvas, this draw must use the kSrcOver_Mode so that |
62 // transparent images blend correctly. | 62 // transparent images blend correctly. |
63 canvas->drawBitmap(bitmap_, 0, 0); | 63 canvas->drawBitmap(bitmap_, 0, 0); |
64 } | 64 } |
65 | 65 |
66 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( | 66 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( |
67 const gfx::Rect& clip, | 67 const gfx::Rect& clip, |
68 GraphicsContextStatus gc_status) { | 68 ContentLayerClient::PaintingControlSetting painting_control) { |
69 scoped_refptr<DisplayItemList> display_item_list = DisplayItemList::Create(); | 69 scoped_refptr<DisplayItemList> display_item_list = DisplayItemList::Create(); |
70 | 70 |
71 SkPictureRecorder recorder; | 71 SkPictureRecorder recorder; |
72 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip)); | 72 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip)); |
73 PaintContents(canvas, clip, gc_status); | 73 PaintContents(canvas, clip, painting_control); |
74 | 74 |
75 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 75 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
76 display_item_list->AppendItem( | 76 display_item_list->AppendItem( |
77 DrawingDisplayItem::Create(picture, gfx::Point())); | 77 DrawingDisplayItem::Create(picture, gfx::Point())); |
78 return display_item_list; | 78 return display_item_list; |
79 } | 79 } |
80 | 80 |
81 bool PictureImageLayer::FillsBoundsCompletely() const { | 81 bool PictureImageLayer::FillsBoundsCompletely() const { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 } // namespace cc | 85 } // namespace cc |
OLD | NEW |