OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/playback/skip_image_canvas.h" | 5 #include "cc/raster/skip_image_canvas.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkShader.h" | 7 #include "third_party/skia/include/core/SkShader.h" |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
11 SkipImageCanvas::SkipImageCanvas(SkCanvas* canvas) | 11 SkipImageCanvas::SkipImageCanvas(SkCanvas* canvas) |
12 : SkPaintFilterCanvas(canvas) {} | 12 : SkPaintFilterCanvas(canvas) {} |
13 | 13 |
14 bool SkipImageCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, | 14 bool SkipImageCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, |
15 Type type) const { | 15 Type type) const { |
16 if (type == kBitmap_Type) | 16 if (type == kBitmap_Type) |
17 return false; | 17 return false; |
18 | 18 |
19 SkShader* shader = (*paint) ? (*paint)->getShader() : nullptr; | 19 SkShader* shader = (*paint) ? (*paint)->getShader() : nullptr; |
20 return !shader || !shader->isAImage(); | 20 return !shader || !shader->isAImage(); |
21 } | 21 } |
22 | 22 |
23 void SkipImageCanvas::onDrawPicture(const SkPicture* picture, | 23 void SkipImageCanvas::onDrawPicture(const SkPicture* picture, |
24 const SkMatrix* matrix, | 24 const SkMatrix* matrix, |
25 const SkPaint* paint) { | 25 const SkPaint* paint) { |
26 SkTCopyOnFirstWrite<SkPaint> filteredPaint(paint); | 26 SkTCopyOnFirstWrite<SkPaint> filteredPaint(paint); |
27 | 27 |
28 // To filter nested draws, we must unfurl pictures at this stage. | 28 // To filter nested draws, we must unfurl pictures at this stage. |
29 if (onFilter(&filteredPaint, kPicture_Type)) | 29 if (onFilter(&filteredPaint, kPicture_Type)) |
30 SkCanvas::onDrawPicture(picture, matrix, filteredPaint); | 30 SkCanvas::onDrawPicture(picture, matrix, filteredPaint); |
31 } | 31 } |
32 | 32 |
33 } // namespace cc | 33 } // namespace cc |
OLD | NEW |