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

Side by Side 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 5 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTr aceCmdBit); } 114 static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTr aceCmdBit); }
115 115
116 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, 116 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
117 GrColor color, 117 GrColor color,
118 const SkRect& rect, 118 const SkRect& rect,
119 const SkRect* localRect, 119 const SkRect* localRect,
120 const SkMatrix* localMatrix) { 120 const SkMatrix* localMatrix) {
121 GrDrawState::AutoRestoreEffects are(ds); 121 GrDrawState::AutoRestoreEffects are(ds);
122 122
123 // Go to device coords to allow batching across matrix changes
124 SkMatrix matrix = ds->getViewMatrix();
125 SkMatrix invert = SkMatrix::I();
126
127 // if we have a local rect, then we apply the localMatrix directly to the lo calRect to generate
128 // vertex local coords
123 bool hasExplicitLocalCoords = SkToBool(localRect); 129 bool hasExplicitLocalCoords = SkToBool(localRect);
124 SkAutoTUnref<const GrGeometryProcessor> gp( 130 if (!hasExplicitLocalCoords) {
125 create_rect_gp(hasExplicitLocalCoords, 131 if (!matrix.isIdentity() && !matrix.invert(&invert)) {
126 color, 132 SkDebugf("Could not invert\n");
127 hasExplicitLocalCoords ? NULL : localMatrix)); 133 return;
134 }
135
136 if (localMatrix) {
137 invert.preConcat(*localMatrix);
138 }
139 }
140
141 SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCo ords,
142 color,
143 &invert));
128 144
129 size_t vstride = gp->getVertexStride(); 145 size_t vstride = gp->getVertexStride();
130 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : 146 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
131 0)); 147 0));
132 AutoReleaseGeometry geo(this, 4, vstride, 0); 148 AutoReleaseGeometry geo(this, 4, vstride, 0);
133 if (!geo.succeeded()) { 149 if (!geo.succeeded()) {
134 SkDebugf("Failed to get space for vertices!\n"); 150 SkDebugf("Failed to get space for vertices!\n");
135 return; 151 return;
136 } 152 }
137 153
138 // Go to device coords to allow batching across matrix changes
139 SkMatrix matrix = ds->getViewMatrix();
140
141 // When the caller has provided an explicit source rect for a stage then we don't want to 154 // When the caller has provided an explicit source rect for a stage then we don't want to
142 // modify that stage's matrix. Otherwise if the effect is generating its sou rce rect from 155 // modify that stage's matrix. Otherwise if the effect is generating its sou rce rect from
143 // the vertex positions then we have to account for the view matrix change. 156 // the vertex positions then we have to account for the view matrix change.
144 GrDrawState::AutoViewMatrixRestore avmr; 157 GrDrawState::AutoViewMatrixRestore avmr(ds);
145 if (!avmr.setIdentity(ds)) {
146 return;
147 }
148 158
149 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride); 159 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride);
150 matrix.mapPointsWithStride(geo.positions(), vstride, 4); 160 matrix.mapPointsWithStride(geo.positions(), vstride, 4);
151 161
152 SkRect devBounds; 162 SkRect devBounds;
153 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid 163 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid
154 // unnecessary clipping in our onDraw(). 164 // unnecessary clipping in our onDraw().
155 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds); 165 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds);
156 166
157 if (localRect) { 167 if (localRect) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 536
527 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 537 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
528 SkASSERT(!fCmdBuffer.empty()); 538 SkASSERT(!fCmdBuffer.empty());
529 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 539 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
530 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 540 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
531 if (activeTraceMarkers.count() > 0) { 541 if (activeTraceMarkers.count() > 0) {
532 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 542 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
533 fGpuCmdMarkers.push_back(activeTraceMarkers); 543 fGpuCmdMarkers.push_back(activeTraceMarkers);
534 } 544 }
535 } 545 }
OLDNEW
« 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