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

Unified Diff: src/gpu/GrContext.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 8 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 | « src/gpu/GrCommandBuilder.cpp ('k') | src/gpu/GrDrawContext.cpp » ('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 bd4ca40a34b05139fa2ea39565c447bc07255456..37355a13ddac3259b42df0acca0a384270449d7e 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -22,6 +22,8 @@
#include "effects/GrConfigConversionEffect.h"
+class GrDrawTarget;
+
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
#define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return false; }
@@ -118,14 +120,14 @@ GrContext::~GrContext() {
void GrContext::abandonContext() {
fResourceProvider->abandon();
+
+ fDrawingManager->abandon();
// abandon first to so destructors
// don't try to free the resources in the API.
fResourceCache->abandonAll();
fGpu->contextAbandoned();
- fDrawingManager->abandon();
-
fBatchFontCache->freeAll();
fLayerCache->freeAll();
fTextBlobCache->freeAll();
@@ -138,6 +140,8 @@ void GrContext::resetContext(uint32_t state) {
void GrContext::freeGpuResources() {
this->flush();
+ //fDrawingMgr.purgeResources1();
+
fBatchFontCache->freeAll();
fLayerCache->freeAll();
@@ -210,7 +214,7 @@ bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t
return srcPI.convertPixelsTo(&dstPI, width, height);
}
-bool GrContext::writeSurfacePixels(GrSurface* surface,
+bool GrContext::writeSurfacePixels(GrDrawContext* surfaceDC, GrSurface* surface,
int left, int top, int width, int height,
GrPixelConfig srcConfig, const void* buffer, size_t rowBytes,
uint32_t pixelOpsFlags) {
@@ -275,8 +279,8 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
textureMatrix.setIDiv(tempTexture->width(), tempTexture->height());
GrPaint paint;
if (applyPremulToSrc) {
- fp.reset(this->createUPMToPMEffect(tempTexture, tempDrawInfo.fSwapRAndB,
- textureMatrix));
+ fp.reset(this->createUPMToPMEffect(tempTexture,
+ tempDrawInfo.fSwapRAndB, textureMatrix, surface->asRenderTarget()));
// If premultiplying was the only reason for the draw, fall back to a straight write.
if (!fp) {
if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -287,15 +291,16 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
}
}
if (tempTexture) {
+ GrRenderTarget* renderTarget = surface->asRenderTarget();
+ SkASSERT(renderTarget);
if (!fp) {
- fp.reset(GrConfigConversionEffect::Create(tempTexture, tempDrawInfo.fSwapRAndB,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp.reset(GrConfigConversionEffect::Create(
+ tempTexture, tempDrawInfo.fSwapRAndB,
+ GrConfigConversionEffect::kNone_PMConversion, textureMatrix, renderTarget));
if (!fp) {
return false;
}
}
- GrRenderTarget* renderTarget = surface->asRenderTarget();
- SkASSERT(renderTarget);
if (tempTexture->surfacePriv().hasPendingIO()) {
this->flush();
}
@@ -315,8 +320,13 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
rowBytes)) {
return false;
}
+ if (buffer) {
+ tempTexture->setFromRawPixels(true);
+ tempTexture->setException(true);
+ }
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
+
SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarget));
if (!drawContext) {
return false;
@@ -344,6 +354,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
}
return fGpu->writePixels(surface, left, top, width, height, srcConfig, buffer, rowBytes);
}
+
return true;
}
@@ -412,8 +423,9 @@ bool GrContext::readSurfacePixels(GrSurface* src,
GrPaint paint;
SkAutoTUnref<const GrFragmentProcessor> fp;
if (unpremul) {
- fp.reset(this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwapRAndB,
- textureMatrix));
+ fp.reset(this->createPMToUPMEffect(
+ src->asTexture(), tempDrawInfo.fSwapRAndB,
+ textureMatrix, temp->asRenderTarget()));
if (fp) {
unpremul = false; // we no longer need to do this on CPU after the read back.
} else if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -423,8 +435,9 @@ bool GrContext::readSurfacePixels(GrSurface* src,
}
}
if (!fp && temp) {
- fp.reset(GrConfigConversionEffect::Create(src->asTexture(), tempDrawInfo.fSwapRAndB,
- GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
+ fp.reset(GrConfigConversionEffect::Create(
+ src->asTexture(), tempDrawInfo.fSwapRAndB,
+ GrConfigConversionEffect::kNone_PMConversion, textureMatrix, temp->asRenderTarget()));
}
if (fp) {
paint.addColorFragmentProcessor(fp);
@@ -572,13 +585,15 @@ void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
bool swapRAndB,
- const SkMatrix& matrix) const {
+ const SkMatrix& matrix,
+ GrRenderTarget* dst) const {
// We should have already called this->testPMConversionsIfNecessary().
SkASSERT(fDidTestPMConversions);
GrConfigConversionEffect::PMConversion pmToUPM =
static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
- return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM, matrix);
+ return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM,
+ matrix, dst);
} else {
return nullptr;
}
@@ -586,13 +601,14 @@ const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
bool swapRAndB,
- const SkMatrix& matrix) const {
+ const SkMatrix& matrix, GrRenderTarget* dst) const {
// We should have already called this->testPMConversionsIfNecessary().
SkASSERT(fDidTestPMConversions);
GrConfigConversionEffect::PMConversion upmToPM =
static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
- return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, matrix);
+ return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM,
+ matrix, dst);
} else {
return nullptr;
}
« no previous file with comments | « src/gpu/GrCommandBuilder.cpp ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698