Index: src/gpu/GrTextureParamsAdjuster.cpp |
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp |
index b30731acece588c106691d9c4f87d8b592b1059f..7155249daec0a5417c31793ab1e87a89082f4c46 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,18 +60,16 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, |
} |
} |
- SkAutoTUnref<GrTexture> copy(context->textureProvider()->createTexture(rtDesc, |
- SkBudgeted::kYes)); |
- if (!copy) { |
+ sk_sp<GrDrawContext> 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 |
+ // Initializing these values for no reason cause the compiler is complaining |
robertphillips
2016/07/19 14:41:17
SK_INIT_TO_AVOID_WARNING ?
bsalomon
2016/07/19 14:52:44
Done. Didn't know about that. The fact that it als
|
SkScalar sx = 0.f; |
SkScalar sy = 0.f; |
if (subset) { |
@@ -115,14 +108,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, |
localRect = SkRect::MakeWH(1.f, 1.f); |
} |
- sk_sp<GrDrawContext> 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, |