summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2018-12-13 16:40:14 -0800
committerJohn Reck <jreck@google.com>2018-12-14 14:07:18 -0800
commit283bb46846ad161045efc4650d3cbc40abf5f24b (patch)
tree732e431c7f704282c3ae5a669f22999520f2507e /libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
parent832c17330e2d0ce52f1471404ef539a63f120ca2 (diff)
New WebViewFunctor API
Should function alongside existing functor API. Bug: 120997728 Test: hwuiunit passes Change-Id: I8f6143d0be1111431b55016f34de319f6b8c8910
Diffstat (limited to 'libs/hwui/pipeline/skia/GLFunctorDrawable.cpp')
-rw-r--r--libs/hwui/pipeline/skia/GLFunctorDrawable.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
index 4a87e7502c6f..240efb41285c 100644
--- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp
@@ -17,29 +17,28 @@
#include "GLFunctorDrawable.h"
#include <GrContext.h>
#include <private/hwui/DrawGlInfo.h>
+#include "FunctorDrawable.h"
#include "GlFunctorLifecycleListener.h"
+#include "GrBackendSurface.h"
+#include "GrRenderTarget.h"
+#include "GrRenderTargetContext.h"
#include "RenderNode.h"
#include "SkAndroidFrameworkUtils.h"
#include "SkClipStack.h"
#include "SkRect.h"
-#include "GrBackendSurface.h"
-#include "GrRenderTarget.h"
-#include "GrRenderTargetContext.h"
namespace android {
namespace uirenderer {
namespace skiapipeline {
GLFunctorDrawable::~GLFunctorDrawable() {
- if (mListener.get() != nullptr) {
- mListener->onGlFunctorReleased(mFunctor);
+ if (auto lp = std::get_if<LegacyFunctor>(&mAnyFunctor)) {
+ if (lp->listener) {
+ lp->listener->onGlFunctorReleased(lp->functor);
+ }
}
}
-void GLFunctorDrawable::syncFunctor() const {
- (*mFunctor)(DrawGlInfo::kModeSync, nullptr);
-}
-
static void setScissor(int viewportHeight, const SkIRect& clip) {
SkASSERT(!clip.isEmpty());
// transform to Y-flipped GL space, and prevent negatives
@@ -49,14 +48,14 @@ static void setScissor(int viewportHeight, const SkIRect& clip) {
}
static bool GetFboDetails(SkCanvas* canvas, GLuint* outFboID, SkISize* outFboSize) {
- GrRenderTargetContext *renderTargetContext =
+ GrRenderTargetContext* renderTargetContext =
canvas->internal_private_accessTopLayerRenderTargetContext();
if (!renderTargetContext) {
ALOGW("Unable to extract renderTarget info from canvas; aborting GLFunctor draw");
return false;
}
- GrRenderTarget *renderTarget = renderTargetContext->accessRenderTarget();
+ GrRenderTarget* renderTarget = renderTargetContext->accessRenderTarget();
if (!renderTarget) {
ALOGW("Unable to extract renderTarget info from canvas; aborting GLFunctor draw");
return false;
@@ -94,16 +93,16 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
sk_sp<SkSurface> tmpSurface;
// we are in a state where there is an unclipped saveLayer
if (fboID != 0 && !surfaceBounds.contains(clipBounds)) {
-
// create an offscreen layer and clear it
- SkImageInfo surfaceInfo = canvas->imageInfo().makeWH(clipBounds.width(), clipBounds.height());
- tmpSurface = SkSurface::MakeRenderTarget(canvas->getGrContext(), SkBudgeted::kYes,
- surfaceInfo);
+ SkImageInfo surfaceInfo =
+ canvas->imageInfo().makeWH(clipBounds.width(), clipBounds.height());
+ tmpSurface =
+ SkSurface::MakeRenderTarget(canvas->getGrContext(), SkBudgeted::kYes, surfaceInfo);
tmpSurface->getCanvas()->clear(SK_ColorTRANSPARENT);
GrGLFramebufferInfo fboInfo;
if (!tmpSurface->getBackendRenderTarget(SkSurface::kFlushWrite_BackendHandleAccess)
- .getGLFramebufferInfo(&fboInfo)) {
+ .getGLFramebufferInfo(&fboInfo)) {
ALOGW("Unable to extract renderTarget info from offscreen canvas; aborting GLFunctor");
return;
}
@@ -144,7 +143,7 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
bool clearStencilAfterFunctor = false;
if (CC_UNLIKELY(clipRegion.isComplex())) {
// clear the stencil
- //TODO: move stencil clear and canvas flush to SkAndroidFrameworkUtils::clipWithStencil
+ // TODO: move stencil clear and canvas flush to SkAndroidFrameworkUtils::clipWithStencil
glDisable(GL_SCISSOR_TEST);
glStencilMask(0x1);
glClearStencil(0);
@@ -163,7 +162,7 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
// GL ops get inserted here if previous flush is missing, which could dirty the stencil
bool stencilWritten = SkAndroidFrameworkUtils::clipWithStencil(tmpCanvas);
- tmpCanvas->flush(); //need this flush for the single op that draws into the stencil
+ tmpCanvas->flush(); // need this flush for the single op that draws into the stencil
// ensure that the framebuffer that the webview will render into is bound before after we
// draw into the stencil
@@ -188,7 +187,11 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) {
setScissor(info.height, clipRegion.getBounds());
}
- (*mFunctor)(DrawGlInfo::kModeDraw, &info);
+ if (mAnyFunctor.index() == 0) {
+ std::get<0>(mAnyFunctor).handle->drawGl(info);
+ } else {
+ (*(std::get<1>(mAnyFunctor).functor))(DrawGlInfo::kModeDraw, &info);
+ }
if (clearStencilAfterFunctor) {
// clear stencil buffer as it may be used by Skia