SkAndroidFrameworkUtils.h 1.5 KB

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