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

Unified Diff: src/gpu/GrContext.cpp

Issue 15821008: Make GrContext track the current matrix, render target, and clip directly rather than using GrDrawS… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: put back wideopen check Created 7 years, 7 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 | « include/gpu/GrEffectStage.h ('k') | src/gpu/GrDrawState.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 d25709f0ea8c544017a258ff9a6f79e2c1912dce..f4bb7156415e0710709e3a506bdfd6e77074e44b 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -91,6 +91,7 @@ GrContext::GrContext() {
++THREAD_INSTANCE_COUNT;
fDrawState = NULL;
fGpu = NULL;
+ fClip = NULL;
fPathRendererChain = NULL;
fSoftwarePathRenderer = NULL;
fTextureCache = NULL;
@@ -100,6 +101,7 @@ GrContext::GrContext() {
fDrawBufferIBAllocPool = NULL;
fAARectRenderer = NULL;
fOvalRenderer = NULL;
jvanverth1 2013/05/28 15:28:59 Any init for RenderTarget needed?
bsalomon 2013/05/28 15:33:29 SkAutoTUnref defaults to NULL.
+ fViewMatrix.reset();
}
bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
@@ -594,18 +596,6 @@ bool GrContext::supportsIndex8PixelConfig(const GrTextureParams* params,
return true;
}
-////////////////////////////////////////////////////////////////////////////////
-
-const GrClipData* GrContext::getClip() const {
- return fGpu->getClip();
-}
-
-void GrContext::setClip(const GrClipData* clipData) {
- fGpu->setClip(clipData);
-
- fDrawState->setState(GrDrawState::kClip_StateBit,
- clipData && clipData->fClipStack && !clipData->fClipStack->isWideOpen());
-}
////////////////////////////////////////////////////////////////////////////////
@@ -630,7 +620,7 @@ void GrContext::drawPaint(const GrPaint& origPaint) {
// map the four corners and bound them with a new rect. This will not
// produce a correct result for some perspective matrices.
if (!this->getMatrix().hasPerspective()) {
- if (!fDrawState->getViewInverse(&inverse)) {
+ if (!fViewMatrix.invert(&inverse)) {
GrPrintf("Could not invert matrix\n");
return;
}
@@ -782,7 +772,7 @@ void GrContext::drawRect(const GrPaint& paint,
SkMatrix combinedMatrix;
bool useVertexCoverage;
bool needAA = paint.isAntiAlias() &&
- !this->getRenderTarget()->isMultisampled();
+ !target->getDrawState().getRenderTarget()->isMultisampled();
bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix,
&combinedMatrix, &devRect,
&useVertexCoverage);
@@ -966,7 +956,7 @@ void GrContext::drawRRect(const GrPaint& paint,
GrDrawState::AutoStageDisable atr(fDrawState);
bool useAA = paint.isAntiAlias() &&
- !this->getRenderTarget()->isMultisampled() &&
+ !target->getDrawState().getRenderTarget()->isMultisampled() &&
!disable_coverage_aa_for_blend(target);
if (!fOvalRenderer->drawSimpleRRect(target, this, useAA, rect, stroke)) {
@@ -986,7 +976,7 @@ void GrContext::drawOval(const GrPaint& paint,
GrDrawState::AutoStageDisable atr(fDrawState);
bool useAA = paint.isAntiAlias() &&
- !this->getRenderTarget()->isMultisampled() &&
+ !target->getDrawState().getRenderTarget()->isMultisampled() &&
!disable_coverage_aa_for_blend(target);
if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) {
@@ -1142,7 +1132,9 @@ void GrContext::flush(int flagsBitfield) {
} else {
this->flushDrawBuffer();
}
+ // TODO: Remove this flag
if (kForceCurrentRenderTarget_FlushBit & flagsBitfield) {
+ fGpu->drawState()->setRenderTarget(this->getRenderTarget());
fGpu->forceRenderTargetFlush();
}
}
@@ -1256,7 +1248,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
ASSERT_OWNED_RESOURCE(target);
if (NULL == target) {
- target = fDrawState->getRenderTarget();
+ target = fRenderTarget.get();
if (NULL == target) {
return false;
}
@@ -1443,7 +1435,7 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
ASSERT_OWNED_RESOURCE(target);
if (NULL == target) {
- target = fDrawState->getRenderTarget();
+ target = fRenderTarget.get();
if (NULL == target) {
return false;
}
@@ -1560,24 +1552,35 @@ GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, BufferedDraw buffer
this->flushDrawBuffer();
fLastDrawWasBuffered = kNo_BufferedDraw;
}
+ ASSERT_OWNED_RESOURCE(fRenderTarget.get());
if (NULL != paint) {
GrAssert(fDrawState->stagesDisabled());
- fDrawState->setFromPaint(*paint);
+ fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get());
#if GR_DEBUG_PARTIAL_COVERAGE_CHECK
if ((paint->hasMask() || 0xff != paint->fCoverage) &&
!fGpu->canApplyCoverage()) {
GrPrintf("Partial pixel coverage will be incorrectly blended.\n");
}
#endif
+ } else {
+ fDrawState->reset();
+ *fDrawState->viewMatrix() = fViewMatrix;
jvanverth1 2013/05/28 15:28:59 While legal this seems a bit squirrely to me. Add
bsalomon 2013/05/28 15:33:29 My next CL removes this viewMatrix() function and
+ fDrawState->setRenderTarget(fRenderTarget.get());
}
+ GrDrawTarget* target;
if (kYes_BufferedDraw == buffered) {
- fDrawBuffer->setClip(fGpu->getClip());
fLastDrawWasBuffered = kYes_BufferedDraw;
- return fDrawBuffer;
+ target = fDrawBuffer;
} else {
GrAssert(kNo_BufferedDraw == buffered);
- return fGpu;
+ fLastDrawWasBuffered = kNo_BufferedDraw;
+ target = fGpu;
}
+ fDrawState->setState(GrDrawState::kClip_StateBit, NULL != fClip &&
+ !fClip->fClipStack->isWideOpen());
+ target->setClip(fClip);
+ GrAssert(fDrawState == target->drawState());
+ return target;
}
/*
@@ -1615,39 +1618,10 @@ GrPathRenderer* GrContext::getPathRenderer(const SkPath& path,
////////////////////////////////////////////////////////////////////////////////
-void GrContext::setRenderTarget(GrRenderTarget* target) {
- ASSERT_OWNED_RESOURCE(target);
- fDrawState->setRenderTarget(target);
-}
-
-GrRenderTarget* GrContext::getRenderTarget() {
- return fDrawState->getRenderTarget();
-}
-
-const GrRenderTarget* GrContext::getRenderTarget() const {
- return fDrawState->getRenderTarget();
-}
-
bool GrContext::isConfigRenderable(GrPixelConfig config) const {
return fGpu->isConfigRenderable(config);
}
-const SkMatrix& GrContext::getMatrix() const {
- return fDrawState->getViewMatrix();
-}
-
-void GrContext::setMatrix(const SkMatrix& m) {
- fDrawState->setViewMatrix(m);
-}
-
-void GrContext::setIdentityMatrix() {
- fDrawState->viewMatrix()->reset();
-}
-
-void GrContext::concatMatrix(const SkMatrix& m) const {
- fDrawState->preConcatViewMatrix(m);
-}
-
static inline intptr_t setOrClear(intptr_t bits, int shift, intptr_t pred) {
intptr_t mask = 1 << shift;
if (pred) {
« no previous file with comments | « include/gpu/GrEffectStage.h ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698