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

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 761563002: First step to moving vertex attributes to the geometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrGeometryProcessor.h ('k') | src/gpu/GrOptDrawState.h » ('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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 The color param is used to determine whether the opaque hint can be set on t he draw state. 60 The color param is used to determine whether the opaque hint can be set on t he draw state.
61 The caller must populate the vertex colors itself. 61 The caller must populate the vertex colors itself.
62 62
63 The vertex attrib order is always pos, color, [local coords]. 63 The vertex attrib order is always pos, color, [local coords].
64 */ 64 */
65 static void set_vertex_attributes(GrDrawState* drawState, bool hasLocalCoords, G rColor color) { 65 static void set_vertex_attributes(GrDrawState* drawState, bool hasLocalCoords, G rColor color) {
66 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | 66 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
67 GrDefaultGeoProcFactory::kColor_GPType; 67 GrDefaultGeoProcFactory::kColor_GPType;
68 flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0; 68 flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
69 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::CreateAndSetAttribs (drawState, 69 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags))->unr ef();
70 flags))->unref();
71 if (0xFF == GrColorUnpackA(color)) { 70 if (0xFF == GrColorUnpackA(color)) {
72 drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true); 71 drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
73 } 72 }
74 } 73 }
75 74
76 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin gs) { 75 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin gs) {
77 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa ce; 76 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa ce;
78 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace); 77 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace);
79 if (isWinding) { 78 if (isWinding) {
80 // Double check that it is in fact winding. 79 // Double check that it is in fact winding.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 111
113 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, 112 void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
114 const SkRect& rect, 113 const SkRect& rect,
115 const SkRect* localRect, 114 const SkRect* localRect,
116 const SkMatrix* localMatrix) { 115 const SkMatrix* localMatrix) {
117 GrDrawState::AutoRestoreEffects are(ds); 116 GrDrawState::AutoRestoreEffects are(ds);
118 117
119 GrColor color = ds->getColor(); 118 GrColor color = ds->getColor();
120 set_vertex_attributes(ds, SkToBool(localRect), color); 119 set_vertex_attributes(ds, SkToBool(localRect), color);
121 120
122 AutoReleaseGeometry geo(this, 4, ds->getVertexStride(), 0); 121 size_t vstride = ds->getGeometryProcessor()->getVertexStride();
122 SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
123 0));
124 AutoReleaseGeometry geo(this, 4, vstride, 0);
123 if (!geo.succeeded()) { 125 if (!geo.succeeded()) {
124 SkDebugf("Failed to get space for vertices!\n"); 126 SkDebugf("Failed to get space for vertices!\n");
125 return; 127 return;
126 } 128 }
127 129
128 // Go to device coords to allow batching across matrix changes 130 // Go to device coords to allow batching across matrix changes
129 SkMatrix matrix = ds->getViewMatrix(); 131 SkMatrix matrix = ds->getViewMatrix();
130 132
131 // When the caller has provided an explicit source rect for a stage then we don't want to 133 // When the caller has provided an explicit source rect for a stage then we don't want to
132 // modify that stage's matrix. Otherwise if the effect is generating its sou rce rect from 134 // modify that stage's matrix. Otherwise if the effect is generating its sou rce rect from
133 // the vertex positions then we have to account for the view matrix change. 135 // the vertex positions then we have to account for the view matrix change.
134 GrDrawState::AutoViewMatrixRestore avmr; 136 GrDrawState::AutoViewMatrixRestore avmr;
135 if (!avmr.setIdentity(ds)) { 137 if (!avmr.setIdentity(ds)) {
136 return; 138 return;
137 } 139 }
138 140
139 size_t vstride = ds->getVertexStride();
140
141 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride); 141 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom , vstride);
142 matrix.mapPointsWithStride(geo.positions(), vstride, 4); 142 matrix.mapPointsWithStride(geo.positions(), vstride, 4);
143 143
144 SkRect devBounds; 144 SkRect devBounds;
145 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid 145 // since we already computed the dev verts, set the bounds hint. This will h elp us avoid
146 // unnecessary clipping in our onDraw(). 146 // unnecessary clipping in our onDraw().
147 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds); 147 get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds);
148 148
149 if (localRect) { 149 if (localRect) {
150 static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor); 150 static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 502
503 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 503 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
504 SkASSERT(!fCmdBuffer.empty()); 504 SkASSERT(!fCmdBuffer.empty());
505 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 505 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
506 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 506 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
507 if (activeTraceMarkers.count() > 0) { 507 if (activeTraceMarkers.count() > 0) {
508 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 508 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
509 fGpuCmdMarkers.push_back(activeTraceMarkers); 509 fGpuCmdMarkers.push_back(activeTraceMarkers);
510 } 510 }
511 } 511 }
OLDNEW
« no previous file with comments | « src/gpu/GrGeometryProcessor.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698