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