aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Stan Iliev <stani@google.com>2017-08-02 15:36:24 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-02 19:56:07 +0000
commit73d8fd90653135bb1247f92ebc1d730a40b4f9d5 (patch)
tree5d13763f33e48082d5d616fd9dea0b06a16bf69c /include
parentdcba08e891f1766b047cf0dbe8bbd275d9f55d2b (diff)
Add a private API for writing the clip to the stencil
Add a private API used by Android framework, which writes the clip into a stencil buffer. This is used by HWUI to clip the WebView. Bug: 31489986 Change-Id: I94515f1539acd9d069c8aceb3300577feed9c94f Reviewed-on: https://skia-review.googlesource.com/29521 Commit-Queue: Stan Iliev <stani@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/android/SkAndroidFrameworkUtils.h38
-rw-r--r--include/core/SkCanvas.h2
2 files changed, 40 insertions, 0 deletions
diff --git a/include/android/SkAndroidFrameworkUtils.h b/include/android/SkAndroidFrameworkUtils.h
new file mode 100644
index 0000000000..0457d03534
--- /dev/null
+++ b/include/android/SkAndroidFrameworkUtils.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkAndroidFrameworkUtils_DEFINED
+#define SkAndroidFrameworkUtils_DEFINED
+
+#include "SkTypes.h"
+
+#ifdef SK_BUILD_FOR_ANDROID
+
+class SkCanvas;
+
+/**
+ * SkAndroidFrameworkUtils expose private APIs used only by Android framework.
+ */
+class SkAndroidFrameworkUtils {
+public:
+
+#if SK_SUPPORT_GPU
+ /**
+ * clipWithStencil draws the current clip into a stencil buffer with reference value and mask
+ * set to 0x1. This function works only on a GPU canvas.
+ *
+ * @param canvas A GPU canvas that has a non-empty clip.
+ *
+ * @return true on success or false if clip is empty or not a GPU canvas.
+ */
+ static bool clipWithStencil(SkCanvas* canvas);
+#endif //SK_SUPPORT_GPU
+};
+
+#endif // SK_BUILD_FOR_ANDROID
+
+#endif // SkAndroidFrameworkUtils_DEFINED
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 8fbca71624..c4cb1752d8 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -17,6 +17,7 @@
class GrContext;
class GrRenderTargetContext;
+class SkAndroidFrameworkUtils;
class SkBaseDevice;
class SkBitmap;
class SkClipStack;
@@ -1457,6 +1458,7 @@ private:
void checkForDeferredSave();
void internalSetMatrix(const SkMatrix&);
+ friend class SkAndroidFrameworkUtils;
friend class SkDrawIter; // needs setupDrawForLayerDevice()
friend class AutoDrawLooper;
friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip