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

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: cleanup Created 5 years, 12 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
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 explicit local coords then we do not use the localmatrix at al l
123 bool hasExplicitLocalCoords = SkToBool(localRect); 128 bool hasExplicitLocalCoords = SkToBool(localRect);
bsalomon 2014/12/23 20:18:40 I don't think this comment is quite right... if we
124 SkAutoTUnref<const GrGeometryProcessor> gp( 129 if (!hasExplicitLocalCoords) {
125 create_rect_gp(hasExplicitLocalCoords, 130 if (!matrix.isIdentity() && !matrix.invert(&invert)) {
126 color, 131 SkDebugf("Could not invert\n");
127 hasExplicitLocalCoords ? NULL : localMatrix)); 132 return;
133 }
134
135 if (localMatrix) {
136 invert.preConcat(*localMatrix);
137 }
138 }
139
140 SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCo ords,
141 color,
142 &invert));
128 143
129 size_t vstride = gp->getVertexStride(); 144 size_t vstride = gp->getVertexStride();
130 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : 145 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
131 0)); 146 0));
132 AutoReleaseGeometry geo(this, 4, vstride, 0); 147 AutoReleaseGeometry geo(this, 4, vstride, 0);
133 if (!geo.succeeded()) { 148 if (!geo.succeeded()) {
134 SkDebugf("Failed to get space for vertices!\n"); 149 SkDebugf("Failed to get space for vertices!\n");
135 return; 150 return;
136 } 151 }
137 152
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 153 // 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 154 // 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. 155 // the vertex positions then we have to account for the view matrix change.
144 GrDrawState::AutoViewMatrixRestore avmr; 156 GrDrawState::AutoViewMatrixRestore avmr(ds);
145 if (!avmr.setIdentity(ds)) {
146 return;
147 }
148 157
149 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride); 158 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride);
150 matrix.mapPointsWithStride(geo.positions(), vstride, 4); 159 matrix.mapPointsWithStride(geo.positions(), vstride, 4);
151 160
152 SkRect devBounds; 161 SkRect devBounds;
153 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid 162 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid
154 // unnecessary clipping in our onDraw(). 163 // unnecessary clipping in our onDraw().
155 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds); 164 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds);
156 165
157 if (localRect) { 166 if (localRect) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 535
527 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 536 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
528 SkASSERT(!fCmdBuffer.empty()); 537 SkASSERT(!fCmdBuffer.empty());
529 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 538 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
530 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 539 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
531 if (activeTraceMarkers.count() > 0) { 540 if (activeTraceMarkers.count() > 0) {
532 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 541 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
533 fGpuCmdMarkers.push_back(activeTraceMarkers); 542 fGpuCmdMarkers.push_back(activeTraceMarkers);
534 } 543 }
535 } 544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698