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

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: adding test to ignore 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
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrInOrderDrawBuffer.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 6e5c1fe778d7b19d140a277c746e62868a52ad7e..1f4903591924b1e4dee4be321c4e7ab6f5bfb819 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -120,11 +120,27 @@ 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 a local rect, then we apply the localMatrix directly to the localRect to generate
+ // vertex local coords
bool hasExplicitLocalCoords = SkToBool(localRect);
- 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 +151,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);
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698