Filter out draws to non-PMA configs that won't blend correctly
Review URL: http://codereview.appspot.com/5376059/
git-svn-id: http://skia.googlecode.com/svn/trunk@2665 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 1986a4e..e5908de 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -269,7 +269,9 @@
/**
* Pixel configurations.
* Unpremultiplied configs are intended for conversion out from skia. They are
- * not supported as input (e.g. drawBitmap or a bitmap shader).
+ * not supported as input (e.g. drawBitmap or a bitmap shader). When used a
+ * render target config only draws that use blend coeffs 1,0 (AKA src-mode)
+ * will succeed.
*/
enum GrPixelConfig {
kUnknown_GrPixelConfig,
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 6b51ca2..03a68dd 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -800,6 +800,15 @@
}
}
#endif
+ if (NULL == this->getRenderTarget()) {
+ return false;
+ }
+ if (GrPixelConfigIsUnpremultiplied(this->getRenderTarget()->config())) {
+ if (kOne_BlendCoeff != fCurrDrawState.fSrcBlend ||
+ kZero_BlendCoeff != fCurrDrawState.fDstBlend) {
+ return false;
+ }
+ }
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (this->isStageEnabled(s) &&
GrPixelConfigIsUnpremultiplied(fCurrDrawState.fTextures[s]->config())) {
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 2753cf0..1baf42e 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -230,6 +230,9 @@
}
void GrGpu::clear(const GrIRect* rect, GrColor color) {
+ if (NULL == this->getRenderTarget()) {
+ return;
+ }
this->handleDirtyContext();
this->onClear(rect, color);
}
@@ -516,13 +519,8 @@
const GrIRect* r = NULL;
GrIRect clipRect;
- // we check this early because we need a valid
- // render target to setup stencil clipping
- // before even going into flushGraphicsState
- if (NULL == fCurrDrawState.fRenderTarget) {
- GrAssert(!"No render target bound.");
- return false;
- }
+ // GrDrawTarget should have filtered this for us
+ GrAssert(NULL != fCurrDrawState.fRenderTarget);
if (fCurrDrawState.fFlagBits & kClip_StateBit) {
GrRenderTarget& rt = *fCurrDrawState.fRenderTarget;
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index ebf33f4..dc6ace7 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -1416,9 +1416,9 @@
}
void GrGpuGL::onClear(const GrIRect* rect, GrColor color) {
- if (NULL == fCurrDrawState.fRenderTarget) {
- return;
- }
+ // parent class should never let us get here with no RT
+ GrAssert(NULL != fCurrDrawState.fRenderTarget);
+
GrIRect r;
if (NULL != rect) {
// flushScissor expects rect to be clipped to the target.