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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 1f01e124bf74a973348ad62706454482aaef2af6..489e51f4ad741e5dacb7bd85e06dcfa770650bc5 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -164,6 +164,40 @@ GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
return this->onCreateIndexBuffer(size, dynamic);
}
+GrIndexBuffer* GrGpu::createIndexBufferPattern(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ bool isDynamic) {
+ size_t bufferSize = patternSize * reps * sizeof(uint16_t);
+ GrIndexBuffer* buffer = this->createIndexBuffer(bufferSize, isDynamic);
+ if (buffer) {
+ uint16_t* data = (uint16_t*) buffer->map();
+ bool useTempData = (NULL == data);
+ if (useTempData) {
+ data = SkNEW_ARRAY(uint16_t, reps * patternSize);
+ }
+ for (int i = 0; i < reps; ++i) {
robertphillips 2014/10/21 19:12:37 Fix comment ?
+ // Each AA filled rect is drawn with 8 vertices and 10 triangles (8 around
+ // the inner rect (for AA) and 2 for the inner rect.
+ int baseIdx = i * patternSize;
+ uint16_t baseVert = (uint16_t)(i * vertCount);
+ for (int j = 0; j < patternSize; ++j) {
+ data[baseIdx+j] = baseVert + pattern[j];
+ }
+ }
+ if (useTempData) {
+ if (!buffer->updateData(data, bufferSize)) {
+ SkFAIL("Can't get indices into buffer!");
+ }
+ SkDELETE_ARRAY(data);
+ } else {
+ buffer->unmap();
+ }
+ }
+ return buffer;
+}
+
void GrGpu::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
« src/gpu/GrGpu.h ('K') | « src/gpu/GrGpu.h ('k') | src/gpu/GrOvalRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698