1 | /* |
2 | * Copyright 2017 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #include "include/android/SkAndroidFrameworkUtils.h" |
9 | #include "include/core/SkCanvas.h" |
10 | #include "include/utils/SkPaintFilterCanvas.h" |
11 | #include "src/core/SkDevice.h" |
12 | #include "src/image/SkSurface_Base.h" |
13 | |
14 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
15 | |
16 | #include <log/log.h> |
17 | |
18 | #if SK_SUPPORT_GPU |
19 | bool SkAndroidFrameworkUtils::clipWithStencil(SkCanvas* canvas) { |
20 | SkBaseDevice* device = canvas->getDevice(); |
21 | return device && device->android_utils_clipWithStencil(); |
22 | } |
23 | #endif |
24 | |
25 | void SkAndroidFrameworkUtils::SafetyNetLog(const char* bugNumber) { |
26 | android_errorWriteLog(0x534e4554, bugNumber); |
27 | } |
28 | |
29 | sk_sp<SkSurface> SkAndroidFrameworkUtils::getSurfaceFromCanvas(SkCanvas* canvas) { |
30 | sk_sp<SkSurface> surface(SkSafeRef(canvas->getSurfaceBase())); |
31 | return surface; |
32 | } |
33 | |
34 | int SkAndroidFrameworkUtils::SaveBehind(SkCanvas* canvas, const SkRect* subset) { |
35 | return canvas->only_axis_aligned_saveBehind(subset); |
36 | } |
37 | |
38 | SkCanvas* SkAndroidFrameworkUtils::getBaseWrappedCanvas(SkCanvas* canvas) { |
39 | auto pfc = canvas->internal_private_asPaintFilterCanvas(); |
40 | auto result = canvas; |
41 | while (pfc) { |
42 | result = pfc->proxy(); |
43 | pfc = result->internal_private_asPaintFilterCanvas(); |
44 | } |
45 | return result; |
46 | } |
47 | #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK |
48 | |
49 | |