Fix unbalanced Shader set/endContext calls in drawVertices
Review URL: https://codereview.appspot.com/7309047 git-svn-id: http://skia.googlecode.com/svn/trunk@7588 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
e7767cfca6
commit
19376b8047
@ -2531,14 +2531,23 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
|
|||||||
savedLocalM = shader->getLocalMatrix();
|
savedLocalM = shader->getLocalMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setContext has already been called and verified to return true
|
||||||
|
// by the constructor of SkAutoBlitterChoose
|
||||||
|
bool prevContextSuccess = true;
|
||||||
while (vertProc(&state)) {
|
while (vertProc(&state)) {
|
||||||
if (NULL != textures) {
|
if (NULL != textures) {
|
||||||
if (texture_to_matrix(state, vertices, textures, &tempM)) {
|
if (texture_to_matrix(state, vertices, textures, &tempM)) {
|
||||||
tempM.postConcat(savedLocalM);
|
tempM.postConcat(savedLocalM);
|
||||||
shader->setLocalMatrix(tempM);
|
shader->setLocalMatrix(tempM);
|
||||||
// need to recal setContext since we changed the local matrix
|
// Need to recall setContext since we changed the local matrix.
|
||||||
shader->endContext();
|
// However, we also need to balance the calls this with a
|
||||||
if (!shader->setContext(*fBitmap, p, *fMatrix)) {
|
// call to endContext which requires tracking the result of
|
||||||
|
// the previous call to setContext.
|
||||||
|
if (prevContextSuccess) {
|
||||||
|
shader->endContext();
|
||||||
|
}
|
||||||
|
prevContextSuccess = shader->setContext(*fBitmap, p, *fMatrix);
|
||||||
|
if (!prevContextSuccess) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2555,10 +2564,18 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
|
|||||||
};
|
};
|
||||||
SkScan::FillTriangle(tmp, *fRC, blitter.get());
|
SkScan::FillTriangle(tmp, *fRC, blitter.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// now restore the shader's original local matrix
|
// now restore the shader's original local matrix
|
||||||
if (NULL != shader) {
|
if (NULL != shader) {
|
||||||
shader->setLocalMatrix(savedLocalM);
|
shader->setLocalMatrix(savedLocalM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the final call to setContext fails we must make it suceed so that the
|
||||||
|
// call to endContext in the destructor for SkAutoBlitterChoose is balanced.
|
||||||
|
if (!prevContextSuccess) {
|
||||||
|
prevContextSuccess = shader->setContext(*fBitmap, paint, SkMatrix::I());
|
||||||
|
SkASSERT(prevContextSuccess);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// no colors[] and no texture
|
// no colors[] and no texture
|
||||||
HairProc hairProc = ChooseHairProc(paint.isAntiAlias());
|
HairProc hairProc = ChooseHairProc(paint.isAntiAlias());
|
||||||
|
Loading…
Reference in New Issue
Block a user