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

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

Issue 671993003: Revert of Oval and stroke AA rect now batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/GrGpu.h ('k') | src/gpu/GrOvalRenderer.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) { 157 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) {
158 this->handleDirtyContext(); 158 this->handleDirtyContext();
159 return this->onCreateVertexBuffer(size, dynamic); 159 return this->onCreateVertexBuffer(size, dynamic);
160 } 160 }
161 161
162 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) { 162 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
163 this->handleDirtyContext(); 163 this->handleDirtyContext();
164 return this->onCreateIndexBuffer(size, dynamic); 164 return this->onCreateIndexBuffer(size, dynamic);
165 } 165 }
166 166
167 GrIndexBuffer* GrGpu::createInstancedIndexBuffer(const uint16_t* pattern,
168 int patternSize,
169 int reps,
170 int vertCount,
171 bool isDynamic) {
172 size_t bufferSize = patternSize * reps * sizeof(uint16_t);
173 GrGpu* me = const_cast<GrGpu*>(this);
174 GrIndexBuffer* buffer = me->createIndexBuffer(bufferSize, isDynamic);
175 if (buffer) {
176 uint16_t* data = (uint16_t*) buffer->map();
177 bool useTempData = (NULL == data);
178 if (useTempData) {
179 data = SkNEW_ARRAY(uint16_t, reps * patternSize);
180 }
181 for (int i = 0; i < reps; ++i) {
182 int baseIdx = i * patternSize;
183 uint16_t baseVert = (uint16_t)(i * vertCount);
184 for (int j = 0; j < patternSize; ++j) {
185 data[baseIdx+j] = baseVert + pattern[j];
186 }
187 }
188 if (useTempData) {
189 if (!buffer->updateData(data, bufferSize)) {
190 SkFAIL("Can't get indices into buffer!");
191 }
192 SkDELETE_ARRAY(data);
193 } else {
194 buffer->unmap();
195 }
196 }
197 return buffer;
198 }
199
200 void GrGpu::clear(const SkIRect* rect, 167 void GrGpu::clear(const SkIRect* rect,
201 GrColor color, 168 GrColor color,
202 bool canIgnoreRect, 169 bool canIgnoreRect,
203 GrRenderTarget* renderTarget) { 170 GrRenderTarget* renderTarget) {
204 if (NULL == renderTarget) { 171 if (NULL == renderTarget) {
205 renderTarget = this->getDrawState().getRenderTarget(); 172 renderTarget = this->getDrawState().getRenderTarget();
206 } 173 }
207 if (NULL == renderTarget) { 174 if (NULL == renderTarget) {
208 SkASSERT(0); 175 SkASSERT(0);
209 return; 176 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 fClipMaskManager.adjustPathStencilParams(outStencilSettings); 239 fClipMaskManager.adjustPathStencilParams(outStencilSettings);
273 } 240 }
274 241
275 242
276 //////////////////////////////////////////////////////////////////////////////// 243 ////////////////////////////////////////////////////////////////////////////////
277 244
278 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; 245 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
279 246
280 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); 247 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535);
281 248
282 static const uint16_t gQuadIndexPattern[] = { 249 static inline void fill_indices(uint16_t* indices, int quadCount) {
283 0, 1, 2, 0, 2, 3 250 for (int i = 0; i < quadCount; ++i) {
284 }; 251 indices[6 * i + 0] = 4 * i + 0;
252 indices[6 * i + 1] = 4 * i + 1;
253 indices[6 * i + 2] = 4 * i + 2;
254 indices[6 * i + 3] = 4 * i + 0;
255 indices[6 * i + 4] = 4 * i + 2;
256 indices[6 * i + 5] = 4 * i + 3;
257 }
258 }
285 259
286 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { 260 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
287 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) { 261 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
288 SkSafeUnref(fQuadIndexBuffer); 262 SkSafeUnref(fQuadIndexBuffer);
263 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
289 GrGpu* me = const_cast<GrGpu*>(this); 264 GrGpu* me = const_cast<GrGpu*>(this);
290 fQuadIndexBuffer = me->createInstancedIndexBuffer(gQuadIndexPattern, 265 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
291 6, 266 if (fQuadIndexBuffer) {
292 MAX_QUADS, 267 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map();
293 4); 268 if (indices) {
269 fill_indices(indices, MAX_QUADS);
270 fQuadIndexBuffer->unmap();
271 } else {
272 indices = (uint16_t*)sk_malloc_throw(SIZE);
273 fill_indices(indices, MAX_QUADS);
274 if (!fQuadIndexBuffer->updateData(indices, SIZE)) {
275 fQuadIndexBuffer->unref();
276 fQuadIndexBuffer = NULL;
277 SkFAIL("Can't get indices into buffer!");
278 }
279 sk_free(indices);
280 }
281 }
294 } 282 }
295 283
296 return fQuadIndexBuffer; 284 return fQuadIndexBuffer;
297 } 285 }
298 286
299 //////////////////////////////////////////////////////////////////////////////// 287 ////////////////////////////////////////////////////////////////////////////////
300 288
301 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy, 289 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy,
302 GrDrawState::AutoRestoreEffects* are, 290 GrDrawState::AutoRestoreEffects* are,
303 const SkRect* devBounds) { 291 const SkRect* devBounds) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 512 }
525 513
526 void GrGpu::releaseIndexArray() { 514 void GrGpu::releaseIndexArray() {
527 // if index source was array, we stowed data in the pool 515 // if index source was array, we stowed data in the pool
528 const GeometrySrcState& geoSrc = this->getGeomSrc(); 516 const GeometrySrcState& geoSrc = this->getGeomSrc();
529 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); 517 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc);
530 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 518 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
531 fIndexPool->putBack(bytes); 519 fIndexPool->putBack(bytes);
532 --fIndexPoolUseCnt; 520 --fIndexPoolUseCnt;
533 } 521 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrOvalRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698