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