| Index: cc/playback/skip_image_canvas.cc
|
| diff --git a/cc/playback/skip_image_canvas.cc b/cc/playback/skip_image_canvas.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..badaf10714511e5327231705d532d651c9131c37
|
| --- /dev/null
|
| +++ b/cc/playback/skip_image_canvas.cc
|
| @@ -0,0 +1,33 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "cc/playback/skip_image_canvas.h"
|
| +
|
| +#include "third_party/skia/include/core/SkShader.h"
|
| +
|
| +namespace cc {
|
| +
|
| +SkipImageCanvas::SkipImageCanvas(SkCanvas* canvas)
|
| + : SkPaintFilterCanvas(canvas) {}
|
| +
|
| +bool SkipImageCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint,
|
| + Type type) const {
|
| + if (type == kBitmap_Type)
|
| + return false;
|
| +
|
| + SkShader* shader = (*paint) ? (*paint)->getShader() : nullptr;
|
| + return !shader || !shader->isABitmap();
|
| +}
|
| +
|
| +void SkipImageCanvas::onDrawPicture(const SkPicture* picture,
|
| + const SkMatrix* matrix,
|
| + const SkPaint* paint) {
|
| + SkTCopyOnFirstWrite<SkPaint> filteredPaint(paint);
|
| +
|
| + // To filter nested draws, we must unfurl pictures at this stage.
|
| + if (onFilter(&filteredPaint, kPicture_Type))
|
| + SkCanvas::onDrawPicture(picture, matrix, filteredPaint);
|
| +}
|
| +
|
| +} // namespace cc
|
|
|