aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDraw.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-13 21:39:56 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-13 21:39:56 +0000
commit1adcf8859cc9414591038e440e3f22382c8e4aa0 (patch)
tree9a7326ace2054faecd8ca907e90188b412be7b54 /src/core/SkDraw.cpp
parent9f13174da5295e88d447f29740318003b9cec9c3 (diff)
Goal: ensure we always balance lock/unlock pixels calls.
A big caller of lockPixels is setContext in the bitmapshader. This change replaces beginSession/endSession with adding endContext(), and adds debugging code to ensure that 1. setContext calls are never nested 2. endContext is always called after each setContext call. Review URL: https://codereview.appspot.com/6937046 git-svn-id: http://skia.googlecode.com/svn/trunk@6798 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r--src/core/SkDraw.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 3035afe1ef..f71187e74a 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1228,13 +1228,6 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
}
}
- // only lock the pixels if we passed the clip and bounder tests
- SkAutoLockPixels alp(bitmap);
- // after the lock, check if we are valid
- if (!bitmap.readyToDraw()) {
- return;
- }
-
if (bitmap.getConfig() != SkBitmap::kA8_Config &&
just_translate(matrix, bitmap)) {
int ix = SkScalarRound(matrix.getTranslateX());
@@ -2279,7 +2272,7 @@ public:
bool setup(const SkPoint pts[], const SkColor colors[], int, int, int);
- virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
+ virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
@@ -2406,7 +2399,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
if (NULL != colors) {
if (NULL == textures) {
// just colors (no texture)
- p.setShader(&triShader);
+ shader = p.setShader(&triShader);
} else {
// colors * texture
SkASSERT(shader);
@@ -2421,6 +2414,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
if (releaseMode) {
xmode->unref();
}
+ shader = compose;
}
}
@@ -2436,10 +2430,17 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
savedLocalM = shader->getLocalMatrix();
}
+ // do we need this? triShader should have been installed in p, either
+ // directly or indirectly (using compose shader), so its setContext
+ // should have already been called.
if (NULL != colors) {
+ SkASSERT(triShader.setContextHasBeenCalled());
+#if 0
+
if (!triShader.setContext(*fBitmap, p, *fMatrix)) {
colors = NULL;
}
+#endif
}
while (vertProc(&state)) {
@@ -2448,6 +2449,7 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
tempM.postConcat(savedLocalM);
shader->setLocalMatrix(tempM);
// need to recal setContext since we changed the local matrix
+ shader->endContext();
if (!shader->setContext(*fBitmap, p, *fMatrix)) {
continue;
}