diff options
author | Stan Iliev <stani@google.com> | 2020-07-09 17:06:57 -0400 |
---|---|---|
committer | Stan Iliev <stani@google.com> | 2020-07-10 18:20:09 +0000 |
commit | 8a3b983f1dff5d5d6e6633fd47c3c26df7fbb1ea (patch) | |
tree | 1031a245404fed2b5e5007b6983b954afced6a1f /libs/hwui | |
parent | 0811c47412f627124f0e30b741435f5755073712 (diff) |
Fix for WebView not drawing in a layer
internal_private_accessTopLayerRenderTargetContext does not
guarantee that a GrRenderTarget is created. Moving flush before
internal_private_accessTopLayerRenderTargetContext resolves that
issue. GrRenderTarget was often nullptr, when drawing WebView in a
layer.
Test: Passed CtsUiRenderingTestCases. Ran two tests apps attached to the bug
Bug: 156413480
Change-Id: Ib3e23c4ab58eb3d02daa05979f545b75a8bfea07
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/pipeline/skia/GLFunctorDrawable.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp index aa8849b642b1..8f67f97fb4bc 100644 --- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp +++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp @@ -48,29 +48,20 @@ static void setScissor(int viewportHeight, const SkIRect& clip) { glScissor(clip.fLeft, y, clip.width(), height); } -static bool GetFboDetails(SkCanvas* canvas, GLuint* outFboID, SkISize* outFboSize) { +static void GetFboDetails(SkCanvas* canvas, GLuint* outFboID, SkISize* outFboSize) { GrRenderTargetContext* renderTargetContext = canvas->internal_private_accessTopLayerRenderTargetContext(); - if (!renderTargetContext) { - ALOGW("Unable to extract renderTarget info from canvas; aborting GLFunctor draw"); - return false; - } + LOG_ALWAYS_FATAL_IF(!renderTargetContext, "Failed to retrieve GrRenderTargetContext"); GrRenderTarget* renderTarget = renderTargetContext->accessRenderTarget(); - if (!renderTarget) { - ALOGW("Unable to extract renderTarget info from canvas; aborting GLFunctor draw"); - return false; - } + LOG_ALWAYS_FATAL_IF(!renderTarget, "accessRenderTarget failed"); GrGLFramebufferInfo fboInfo; - if (!renderTarget->getBackendRenderTarget().getGLFramebufferInfo(&fboInfo)) { - ALOGW("Unable to extract renderTarget info from canvas; aborting GLFunctor draw"); - return false; - } + LOG_ALWAYS_FATAL_IF(!renderTarget->getBackendRenderTarget().getGLFramebufferInfo(&fboInfo), + "getGLFrameBufferInfo failed"); *outFboID = fboInfo.fFBOID; *outFboSize = SkISize::Make(renderTargetContext->width(), renderTargetContext->height()); - return true; } void GLFunctorDrawable::onDraw(SkCanvas* canvas) { @@ -85,11 +76,12 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) { return; } + // flush will create a GrRenderTarget if not already present. + canvas->flush(); + GLuint fboID = 0; SkISize fboSize; - if (!GetFboDetails(canvas, &fboID, &fboSize)) { - return; - } + GetFboDetails(canvas, &fboID, &fboSize); SkIRect surfaceBounds = canvas->internal_private_getTopLayerBounds(); SkIRect clipBounds = canvas->getDeviceClipBounds(); @@ -143,7 +135,6 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) { // ensure that the framebuffer that the webview will render into is bound before we clear // the stencil and/or draw the functor. - canvas->flush(); glViewport(0, 0, info.width, info.height); glBindFramebuffer(GL_FRAMEBUFFER, fboID); |