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

Unified Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 818233002: Remove coordchanges from drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@coord-change-off-paint
Patch Set: cleanup Created 6 years 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
Index: src/gpu/GrInOrderDrawBuffer.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 6e5c1fe778d7b19d140a277c746e62868a52ad7e..db114678b4da164fe2d1b1fbc2b957bc7f472f8f 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -120,11 +120,26 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
const SkMatrix* localMatrix) {
GrDrawState::AutoRestoreEffects are(ds);
+ // Go to device coords to allow batching across matrix changes
+ SkMatrix matrix = ds->getViewMatrix();
+ SkMatrix invert = SkMatrix::I();
+
+ // if we have explicit local coords then we do not use the localmatrix at all
bool hasExplicitLocalCoords = SkToBool(localRect);
bsalomon 2014/12/23 20:18:40 I don't think this comment is quite right... if we
- SkAutoTUnref<const GrGeometryProcessor> gp(
- create_rect_gp(hasExplicitLocalCoords,
- color,
- hasExplicitLocalCoords ? NULL : localMatrix));
+ if (!hasExplicitLocalCoords) {
+ if (!matrix.isIdentity() && !matrix.invert(&invert)) {
+ SkDebugf("Could not invert\n");
+ return;
+ }
+
+ if (localMatrix) {
+ invert.preConcat(*localMatrix);
+ }
+ }
+
+ SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCoords,
+ color,
+ &invert));
size_t vstride = gp->getVertexStride();
SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
@@ -135,16 +150,10 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
return;
}
- // Go to device coords to allow batching across matrix changes
- SkMatrix matrix = ds->getViewMatrix();
-
// When the caller has provided an explicit source rect for a stage then we don't want to
// modify that stage's matrix. Otherwise if the effect is generating its source rect from
// the vertex positions then we have to account for the view matrix change.
- GrDrawState::AutoViewMatrixRestore avmr;
- if (!avmr.setIdentity(ds)) {
- return;
- }
+ GrDrawState::AutoViewMatrixRestore avmr(ds);
geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vstride);
matrix.mapPointsWithStride(geo.positions(), vstride, 4);

Powered by Google App Engine
This is Rietveld 408576698