Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: src/gpu/GrContext.cpp

Issue 2165523003: Convert readSurfacePixels to use a draw context instead of a texture (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrGpu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 4a2b2b022862dfab775c0d5eca0fbb40e94194af..4cb90c658e1b3346d9220812a202332d7970a6f2 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -437,21 +437,20 @@ bool GrContext::readSurfacePixels(GrSurface* src,
SkAutoTUnref<GrSurface> surfaceToRead(SkRef(src));
bool didTempDraw = false;
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
- if (tempDrawInfo.fUseExactScratch) {
+ if (SkBackingFit::kExact == tempDrawInfo.fTempSurfaceFit) {
// We only respect this when the entire src is being read. Otherwise we can trigger too
// many odd ball texture sizes and trash the cache.
if (width != src->width() || height != src->height()) {
- tempDrawInfo.fUseExactScratch = false;
+ tempDrawInfo.fTempSurfaceFit= SkBackingFit::kApprox;
}
}
- SkAutoTUnref<GrTexture> temp;
- if (tempDrawInfo.fUseExactScratch) {
- temp.reset(this->textureProvider()->createTexture(tempDrawInfo.fTempSurfaceDesc,
- SkBudgeted::kYes));
- } else {
- temp.reset(this->textureProvider()->createApproxTexture(tempDrawInfo.fTempSurfaceDesc));
- }
- if (temp) {
+ sk_sp<GrDrawContext> tempDC = this->newDrawContext(tempDrawInfo.fTempSurfaceFit,
+ tempDrawInfo.fTempSurfaceDesc.fWidth,
+ tempDrawInfo.fTempSurfaceDesc.fHeight,
+ tempDrawInfo.fTempSurfaceDesc.fConfig,
+ tempDrawInfo.fTempSurfaceDesc.fSampleCnt,
+ tempDrawInfo.fTempSurfaceDesc.fOrigin);
+ if (tempDC) {
SkMatrix textureMatrix;
textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
textureMatrix.postIDiv(src->width(), src->height());
@@ -464,10 +463,10 @@ bool GrContext::readSurfacePixels(GrSurface* src,
} else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
// We only wanted to do the draw in order to perform the unpremul so don't
// bother.
- temp.reset(nullptr);
+ tempDC.reset(nullptr);
}
}
- if (!fp && temp) {
+ if (!fp && tempDC) {
fp = GrConfigConversionEffect::Make(src->asTexture(), tempDrawInfo.fSwizzle,
GrConfigConversionEffect::kNone_PMConversion,
textureMatrix);
@@ -478,10 +477,8 @@ bool GrContext::readSurfacePixels(GrSurface* src,
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
paint.setAllowSRGBInputs(true);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- sk_sp<GrDrawContext> drawContext(
- this->drawContext(sk_ref_sp(temp->asRenderTarget())));
- drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullptr);
- surfaceToRead.reset(SkRef(temp.get()));
+ tempDC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullptr);
+ surfaceToRead.reset(tempDC->asTexture().release());
left = 0;
top = 0;
didTempDraw = true;
« no previous file with comments | « no previous file | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698