From f87da67df90968adcddb2404ff20a41fe49a0315 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Wed, 2 Nov 2016 11:34:27 -0400 Subject: [PATCH] Adding changes required by the master-skia merge. Test: compile only Change-Id: I39637a20da439edbf2831952df9bfa12da78e9b9 --- libs/hwui/pipeline/skia/LayerDrawable.cpp | 5 +++-- .../hwui/pipeline/skia/RenderNodeDrawable.cpp | 2 +- .../pipeline/skia/ReorderBarrierDrawables.cpp | 22 +++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp index f8a181fa385e8..13a0ed852816d 100644 --- a/libs/hwui/pipeline/skia/LayerDrawable.cpp +++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp @@ -15,6 +15,7 @@ */ #include "LayerDrawable.h" +#include "SkColorFilter.h" #include "gl/GrGLTypes.h" namespace android { @@ -40,12 +41,12 @@ void LayerDrawable::onDraw(SkCanvas* canvas) { textureDescription.fConfig = kRGBA_8888_GrPixelConfig; textureDescription.fOrigin = kTopLeft_GrSurfaceOrigin; textureDescription.fTextureHandle = reinterpret_cast(&externalTexture); - sk_sp layerImage(SkImage::NewFromTexture(context, textureDescription)); + sk_sp layerImage = SkImage::MakeFromTexture(context, textureDescription); if (layerImage) { SkPaint paint; paint.setAlpha(mLayer->getAlpha()); paint.setBlendMode(mLayer->getMode()); - paint.setColorFilter(mLayer->getColorFilter()); + paint.setColorFilter(sk_ref_sp(mLayer->getColorFilter())); canvas->drawImage(layerImage, 0, 0, &paint); } // restore the original matrix diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp index cefa893f28648..b656d6737ab32 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -130,7 +130,7 @@ static bool layerNeedsPaint(const LayerProperties& properties, || properties.colorFilter() != nullptr) { paint->setAlpha(properties.alpha() * alphaMultiplier); paint->setBlendMode(properties.xferMode()); - paint->setColorFilter(properties.colorFilter()); + paint->setColorFilter(sk_ref_sp(properties.colorFilter())); return true; } return false; diff --git a/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp b/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp index 8d77938ad1b9a..ac185878b9cac 100644 --- a/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp +++ b/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace android { namespace uirenderer { @@ -341,7 +341,7 @@ static void DrawRRectShadows(const SkRect& casterRect, SkScalar casterCornerRadi paint.setAntiAlias(true); // If the area of the stroked geometry is larger than the fill geometry, just fill it. - if (strokedArea > filledArea || casterAlpha < 1.0f) { + if (strokedArea > filledArea || casterAlpha < 1.0f || insetAmount < 0.0f) { paint.setStyle(SkPaint::kStrokeAndFill_Style); paint.setStrokeWidth(srcSpaceSpotRadius); } else { @@ -433,8 +433,8 @@ static void DrawRRectShadowsWithClip(const SkRect& casterRect, SkScalar casterCo SkPaint paint; paint.setColor(SkColorSetARGB((unsigned char) ambientAlpha, 0, 0, 0)); - paint.setShader(SkRRectsGaussianEdgeShader::Make(devSpaceAmbientRRect, - devSpaceAmbientClipRR, devSpaceAmbientRadius)); + paint.setMaskFilter(SkRRectsGaussianEdgeMaskFilter::Make(devSpaceAmbientRRect, + devSpaceAmbientClipRR, devSpaceAmbientRadius)); canvas->drawRect(cover, paint); } @@ -514,8 +514,8 @@ static void DrawRRectShadowsWithClip(const SkRect& casterRect, SkScalar casterCo devSpaceSpotClipRR = SkRRect::MakeRect(devSpaceScaledClipRect); } - paint.setShader(SkRRectsGaussianEdgeShader::Make(devSpaceSpotRRect, devSpaceSpotClipRR, - devSpaceSpotRadius)); + paint.setMaskFilter(SkRRectsGaussianEdgeMaskFilter::Make(devSpaceSpotRRect, + devSpaceSpotClipRR, devSpaceSpotRadius)); SkRect cover = srcSpaceScaledClipRect; if (!cover.intersect(srcSpaceSpotRRect.rect())) { @@ -556,8 +556,8 @@ static bool DrawShadowsAsRRects(const SkRect& casterRect, SkScalar casterCornerR return false; } - // The casterClipRect will contain the casterRect when bounds clipping is disabled - bool casterIsClippedByRect = !casterClipRect.contains(casterRect); + // The casterClipRect will be empty when bounds clipping is disabled + bool casterIsClippedByRect = !casterClipRect.isEmpty(); bool uniformScale = scaleFactors[0] == scaleFactors[1]; if (revealClip.willClip()) { @@ -639,11 +639,15 @@ void EndReorderBarrierDrawable::drawShadow(SkCanvas* canvas, RenderNodeDrawable* bool clippedToBounds = casterProperties.getClippingFlags() & CLIP_TO_CLIP_BOUNDS; - SkRect casterClipRect = SkRect::MakeLargest(); + SkRect casterClipRect = SkRect::MakeEmpty(); if (clippedToBounds) { Rect clipBounds; casterProperties.getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds); casterClipRect = clipBounds.toSkRect(); + if (casterClipRect.isEmpty()) { + // An empty clip rect means nothing is drawn + return; + } } SkAutoCanvasRestore acr(canvas, true);