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 "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 22 matching lines...) Expand all Loading... | |
33 // style change that affects the layer even if that change doesn't | 33 // style change that affects the layer even if that change doesn't |
34 // affect the actual contents of the image (e.g. a CSS animation). | 34 // affect the actual contents of the image (e.g. a CSS animation). |
35 // With this check in place we avoid unecessary texture uploads. | 35 // With this check in place we avoid unecessary texture uploads. |
36 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) | 36 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) |
37 return; | 37 return; |
38 | 38 |
39 bitmap_ = bitmap; | 39 bitmap_ = bitmap; |
40 SetNeedsDisplay(); | 40 SetNeedsDisplay(); |
41 } | 41 } |
42 | 42 |
43 void PictureImageLayer::PaintContents(SkCanvas* canvas, | 43 void PictureImageLayer::PaintContents( |
44 const gfx::Rect& clip, | 44 SkCanvas* canvas, |
45 gfx::RectF* opaque) { | 45 const gfx::Rect& clip, |
46 if (!canvas || !bitmap_.width() || !bitmap_.height()) | 46 gfx::RectF* opaque, |
47 ContentLayerClient::GraphicsContextStatus) { | |
48 if (!bitmap_.width() || !bitmap_.height()) | |
danakj
2014/05/01 17:07:11
Do you want to early out here based on the Graphic
Stephen Chennney
2014/05/01 19:12:26
Sami added the !canvas check during the previous a
danakj
2014/05/01 19:15:14
No, I don't want to early out on canvas if it's ne
| |
47 return; | 49 return; |
48 | 50 |
49 SkScalar content_to_layer_scale_x = | 51 SkScalar content_to_layer_scale_x = |
50 SkFloatToScalar(static_cast<float>(bounds().width()) / bitmap_.width()); | 52 SkFloatToScalar(static_cast<float>(bounds().width()) / bitmap_.width()); |
51 SkScalar content_to_layer_scale_y = | 53 SkScalar content_to_layer_scale_y = |
52 SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height()); | 54 SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height()); |
53 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); | 55 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); |
54 | 56 |
55 // Because PictureImageLayer always FillsBoundsCompletely it will not clear | 57 // Because PictureImageLayer always FillsBoundsCompletely it will not clear |
56 // before painting on playback. As a result we must configure the paint to | 58 // before painting on playback. As a result we must configure the paint to |
57 // copy over the uncleared destination, rather than blending with it. | 59 // copy over the uncleared destination, rather than blending with it. |
58 SkPaint paint; | 60 SkPaint paint; |
59 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 61 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
60 canvas->drawBitmap(bitmap_, 0, 0, &paint); | 62 canvas->drawBitmap(bitmap_, 0, 0, &paint); |
61 } | 63 } |
62 | 64 |
63 bool PictureImageLayer::FillsBoundsCompletely() const { | 65 bool PictureImageLayer::FillsBoundsCompletely() const { |
64 // PictureImageLayer will always paint to the entire layer bounds. | 66 // PictureImageLayer will always paint to the entire layer bounds. |
65 return true; | 67 return true; |
66 } | 68 } |
67 | 69 |
68 } // namespace cc | 70 } // namespace cc |
OLD | NEW |