forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskip_image_canvas.cc
33 lines (24 loc) · 1.05 KB
/
skip_image_canvas.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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