blob: a7ea2ea4122eb834c14f16cd1eaabe1795572406 [file] [log] [blame]
Stan Iliev73d8fd92017-08-02 15:36:24 -04001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#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"
Stan Iliev73d8fd92017-08-02 15:36:24 -040013
Leon Scroggins III44764002018-11-13 10:26:34 -050014#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
15
16#include <log/log.h>
Stan Iliev73d8fd92017-08-02 15:36:24 -040017
18#if SK_SUPPORT_GPU
19bool SkAndroidFrameworkUtils::clipWithStencil(SkCanvas* canvas) {
Stan Iliev73d8fd92017-08-02 15:36:24 -040020 SkBaseDevice* device = canvas->getDevice();
Mike Reedaebe4392019-12-20 14:59:49 -050021 return device && device->android_utils_clipWithStencil();
Stan Iliev73d8fd92017-08-02 15:36:24 -040022}
Mike Reedaebe4392019-12-20 14:59:49 -050023#endif
Stan Iliev73d8fd92017-08-02 15:36:24 -040024
Leon Scroggins III44764002018-11-13 10:26:34 -050025void SkAndroidFrameworkUtils::SafetyNetLog(const char* bugNumber) {
26 android_errorWriteLog(0x534e4554, bugNumber);
27}
28
Derek Sollenberger1958e5d2018-11-27 15:33:38 -050029sk_sp<SkSurface> SkAndroidFrameworkUtils::getSurfaceFromCanvas(SkCanvas* canvas) {
30 sk_sp<SkSurface> surface(SkSafeRef(canvas->getSurfaceBase()));
31 return surface;
32}
Mike Reed148b7fd2018-12-18 17:38:18 -050033
34int SkAndroidFrameworkUtils::SaveBehind(SkCanvas* canvas, const SkRect* subset) {
35 return canvas->only_axis_aligned_saveBehind(subset);
36}
Stan Ilievb0a86842019-03-28 16:39:58 -040037
38SkCanvas* 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}
Leon Scroggins III44764002018-11-13 10:26:34 -050047#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
Stan Iliev73d8fd92017-08-02 15:36:24 -040048