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 #ifndef SkAndroidFrameworkUtils_DEFINED 9 #define SkAndroidFrameworkUtils_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/core/SkTypes.h" 13 14 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 15 16 class SkCanvas; 17 struct SkIRect; 18 struct SkRect; 19 class SkSurface; 20 21 /** 22 * SkAndroidFrameworkUtils expose private APIs used only by Android framework. 23 */ 24 class SkAndroidFrameworkUtils { 25 public: 26 27 #if SK_SUPPORT_GPU 28 /** 29 * clipWithStencil draws the current clip into a stencil buffer with reference value and mask 30 * set to 0x1. This function works only on a GPU canvas. 31 * 32 * @param canvas A GPU canvas that has a non-empty clip. 33 * 34 * @return true on success or false if clip is empty or not a GPU canvas. 35 */ 36 static bool clipWithStencil(SkCanvas* canvas); 37 #endif //SK_SUPPORT_GPU 38 39 static void SafetyNetLog(const char*); 40 41 static sk_sp<SkSurface> getSurfaceFromCanvas(SkCanvas* canvas); 42 43 static int SaveBehind(SkCanvas* canvas, const SkRect* subset); 44 45 // Operating within the canvas' clip stack, this resets the geometry of the clip to be wide 46 // open modula any device clip restriction that was set outside of the clip stack. 47 static void ResetClip(SkCanvas* canvas); 48 49 /** 50 * Unrolls a chain of nested SkPaintFilterCanvas to return the base wrapped canvas. 51 * 52 * @param canvas A SkPaintFilterCanvas or any other SkCanvas subclass. 53 * 54 * @return SkCanvas that was found in the innermost SkPaintFilterCanvas. 55 */ 56 static SkCanvas* getBaseWrappedCanvas(SkCanvas* canvas); 57 }; 58 59 #endif // SK_BUILD_FOR_ANDROID_ANDROID 60 61 #endif // SkAndroidFrameworkUtils_DEFINED 62