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

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

Issue 664193002: Oval and stroke AA rect now batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more gms added to ignore Created 6 years, 2 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/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
167 void GrGpu::clear(const SkIRect* rect, 200 void GrGpu::clear(const SkIRect* rect,
168 GrColor color, 201 GrColor color,
169 bool canIgnoreRect, 202 bool canIgnoreRect,
170 GrRenderTarget* renderTarget) { 203 GrRenderTarget* renderTarget) {
171 if (NULL == renderTarget) { 204 if (NULL == renderTarget) {
172 renderTarget = this->getDrawState().getRenderTarget(); 205 renderTarget = this->getDrawState().getRenderTarget();
173 } 206 }
174 if (NULL == renderTarget) { 207 if (NULL == renderTarget) {
175 SkASSERT(0); 208 SkASSERT(0);
176 return; 209 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 fClipMaskManager.adjustPathStencilParams(outStencilSettings); 272 fClipMaskManager.adjustPathStencilParams(outStencilSettings);
240 } 273 }
241 274
242 275
243 //////////////////////////////////////////////////////////////////////////////// 276 ////////////////////////////////////////////////////////////////////////////////
244 277
245 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; 278 static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
246 279
247 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); 280 GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535);
248 281
249 static inline void fill_indices(uint16_t* indices, int quadCount) { 282 static const uint16_t gQuadIndexPattern[] = {
250 for (int i = 0; i < quadCount; ++i) { 283 0, 1, 2, 0, 2, 3
251 indices[6 * i + 0] = 4 * i + 0; 284 };
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 }
259 285
260 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { 286 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
261 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) { 287 if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
262 SkSafeUnref(fQuadIndexBuffer); 288 SkSafeUnref(fQuadIndexBuffer);
263 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
264 GrGpu* me = const_cast<GrGpu*>(this); 289 GrGpu* me = const_cast<GrGpu*>(this);
265 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false); 290 fQuadIndexBuffer = me->createInstancedIndexBuffer(gQuadIndexPattern,
266 if (fQuadIndexBuffer) { 291 6,
267 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map(); 292 MAX_QUADS,
268 if (indices) { 293 4);
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 }
282 } 294 }
283 295
284 return fQuadIndexBuffer; 296 return fQuadIndexBuffer;
285 } 297 }
286 298
287 //////////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////////////
288 300
289 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy, 301 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds tCopy,
290 GrDrawState::AutoRestoreEffects* are, 302 GrDrawState::AutoRestoreEffects* are,
291 const SkRect* devBounds) { 303 const SkRect* devBounds) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 524 }
513 525
514 void GrGpu::releaseIndexArray() { 526 void GrGpu::releaseIndexArray() {
515 // if index source was array, we stowed data in the pool 527 // if index source was array, we stowed data in the pool
516 const GeometrySrcState& geoSrc = this->getGeomSrc(); 528 const GeometrySrcState& geoSrc = this->getGeomSrc();
517 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); 529 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc);
518 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); 530 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
519 fIndexPool->putBack(bytes); 531 fIndexPool->putBack(bytes);
520 --fIndexPoolUseCnt; 532 --fIndexPoolUseCnt;
521 } 533 }
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