From: bsalomon Date: Tue, 19 Jul 2016 15:12:30 +0000 (-0700) Subject: Start from DC rather than texture in GrTexutreParamsAdjuster copy code. X-Git-Tag: submit/tizen/20180928.044319~116^2~748 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=916e02a6d004af5b83a636d1507bfdf2da8543ce;p=platform%2Fupstream%2FlibSkiaSharp.git Start from DC rather than texture in GrTexutreParamsAdjuster copy code. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2158383002 Review-Url: https://codereview.chromium.org/2158383002 --- diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp index b30731acec..fe81beacd6 100644 --- a/src/gpu/GrTextureParamsAdjuster.cpp +++ b/src/gpu/GrTextureParamsAdjuster.cpp @@ -35,28 +35,23 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, SkASSERT(context); const GrCaps* caps = context->caps(); - // Either it's a cache miss or the original wasn't cached to begin with. - GrSurfaceDesc rtDesc = inputTexture->desc(); - rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; - rtDesc.fWidth = copyParams.fWidth; - rtDesc.fHeight = copyParams.fHeight; - rtDesc.fConfig = GrMakePixelConfigUncompressed(rtDesc.fConfig); + GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config()); // If the config isn't renderable try converting to either A8 or an 32 bit config. Otherwise, // fail. - if (!caps->isConfigRenderable(rtDesc.fConfig, false)) { - if (GrPixelConfigIsAlphaOnly(rtDesc.fConfig)) { + if (!caps->isConfigRenderable(config, false)) { + if (GrPixelConfigIsAlphaOnly(config)) { if (caps->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { - rtDesc.fConfig = kAlpha_8_GrPixelConfig; + config = kAlpha_8_GrPixelConfig; } else if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) { - rtDesc.fConfig = kSkia8888_GrPixelConfig; + config = kSkia8888_GrPixelConfig; } else { return nullptr; } } else if (kRGB_GrColorComponentFlags == - (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(rtDesc.fConfig))) { + (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(config))) { if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) { - rtDesc.fConfig = kSkia8888_GrPixelConfig; + config = kSkia8888_GrPixelConfig; } else { return nullptr; } @@ -65,20 +60,17 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, } } - SkAutoTUnref copy(context->textureProvider()->createTexture(rtDesc, - SkBudgeted::kYes)); - if (!copy) { + sk_sp copyDC = context->newDrawContext(SkBackingFit::kExact, copyParams.fWidth, + copyParams.fHeight, config); + if (!copyDC) { return nullptr; } - // TODO: If no scaling is being performed then use copySurface. - GrPaint paint; paint.setGammaCorrect(true); - // TODO: Initializing these values for no reason cause the compiler is complaining - SkScalar sx = 0.f; - SkScalar sy = 0.f; + SkScalar sx SK_INIT_TO_AVOID_WARNING; + SkScalar sy SK_INIT_TO_AVOID_WARNING; if (subset) { sx = 1.f / inputTexture->width(); sy = 1.f / inputTexture->height(); @@ -115,14 +107,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, localRect = SkRect::MakeWH(1.f, 1.f); } - sk_sp drawContext(context->drawContext(sk_ref_sp(copy->asRenderTarget()))); - if (!drawContext) { - return nullptr; - } - - SkRect dstRect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight)); - drawContext->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect); - return copy.release(); + SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight); + copyDC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect); + return copyDC->asTexture().release(); } GrTextureAdjuster::GrTextureAdjuster(GrTexture* original,