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

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 112913005: reenable vertices gm, adding picture support (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('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 2011 Google Inc. 3 * Copyright 2011 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 #include "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkTSearch.h" 9 #include "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 void SkPictureRecord::drawPicture(SkPicture& picture) { 1182 void SkPictureRecord::drawPicture(SkPicture& picture) {
1183 // op + picture index 1183 // op + picture index
1184 uint32_t size = 2 * kUInt32Size; 1184 uint32_t size = 2 * kUInt32Size;
1185 size_t initialOffset = this->addDraw(DRAW_PICTURE, &size); 1185 size_t initialOffset = this->addDraw(DRAW_PICTURE, &size);
1186 addPicture(picture); 1186 addPicture(picture);
1187 this->validate(initialOffset, size); 1187 this->validate(initialOffset, size);
1188 } 1188 }
1189 1189
1190 void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, 1190 void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount,
1191 const SkPoint vertices[], const SkPoint texs[], 1191 const SkPoint vertices[], const SkPoint texs[],
1192 const SkColor colors[], SkXfermode*, 1192 const SkColor colors[], SkXfermode* xfer,
1193 const uint16_t indices[], int indexCount, 1193 const uint16_t indices[], int indexCount,
1194 const SkPaint& paint) { 1194 const SkPaint& paint) {
1195 uint32_t flags = 0; 1195 uint32_t flags = 0;
1196 if (texs) { 1196 if (texs) {
1197 flags |= DRAW_VERTICES_HAS_TEXS; 1197 flags |= DRAW_VERTICES_HAS_TEXS;
1198 } 1198 }
1199 if (colors) { 1199 if (colors) {
1200 flags |= DRAW_VERTICES_HAS_COLORS; 1200 flags |= DRAW_VERTICES_HAS_COLORS;
1201 } 1201 }
1202 if (indexCount > 0) { 1202 if (indexCount > 0) {
1203 flags |= DRAW_VERTICES_HAS_INDICES; 1203 flags |= DRAW_VERTICES_HAS_INDICES;
1204 } 1204 }
1205 if (NULL != xfer) {
1206 SkXfermode::Mode mode;
1207 if (xfer->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1208 flags |= DRAW_VERTICES_HAS_XFER;
1209 }
1210 }
1205 1211
1206 // op + paint index + flags + vmode + vCount + vertices 1212 // op + paint index + flags + vmode + vCount + vertices
1207 uint32_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint); 1213 uint32_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint);
1208 if (flags & DRAW_VERTICES_HAS_TEXS) { 1214 if (flags & DRAW_VERTICES_HAS_TEXS) {
1209 size += vertexCount * sizeof(SkPoint); // + uvs 1215 size += vertexCount * sizeof(SkPoint); // + uvs
1210 } 1216 }
1211 if (flags & DRAW_VERTICES_HAS_COLORS) { 1217 if (flags & DRAW_VERTICES_HAS_COLORS) {
1212 size += vertexCount * sizeof(SkColor); // + vert colors 1218 size += vertexCount * sizeof(SkColor); // + vert colors
1213 } 1219 }
1214 if (flags & DRAW_VERTICES_HAS_INDICES) { 1220 if (flags & DRAW_VERTICES_HAS_INDICES) {
1215 // + num indices + indices 1221 // + num indices + indices
1216 size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t)); 1222 size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t));
1217 } 1223 }
1224 if (flags & DRAW_VERTICES_HAS_XFER) {
1225 size += kUInt32Size; // mode enum
1226 }
1218 1227
1219 size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); 1228 size_t initialOffset = this->addDraw(DRAW_VERTICES, &size);
1220 SkASSERT(initialOffset+getPaintOffset(DRAW_VERTICES, size) == fWriter.bytesW ritten()); 1229 SkASSERT(initialOffset+getPaintOffset(DRAW_VERTICES, size) == fWriter.bytesW ritten());
1221 addPaint(paint); 1230 addPaint(paint);
1222 addInt(flags); 1231 addInt(flags);
1223 addInt(vmode); 1232 addInt(vmode);
1224 addInt(vertexCount); 1233 addInt(vertexCount);
1225 addPoints(vertices, vertexCount); 1234 addPoints(vertices, vertexCount);
1226 if (flags & DRAW_VERTICES_HAS_TEXS) { 1235 if (flags & DRAW_VERTICES_HAS_TEXS) {
1227 addPoints(texs, vertexCount); 1236 addPoints(texs, vertexCount);
1228 } 1237 }
1229 if (flags & DRAW_VERTICES_HAS_COLORS) { 1238 if (flags & DRAW_VERTICES_HAS_COLORS) {
1230 fWriter.writeMul4(colors, vertexCount * sizeof(SkColor)); 1239 fWriter.writeMul4(colors, vertexCount * sizeof(SkColor));
1231 } 1240 }
1232 if (flags & DRAW_VERTICES_HAS_INDICES) { 1241 if (flags & DRAW_VERTICES_HAS_INDICES) {
1233 addInt(indexCount); 1242 addInt(indexCount);
1234 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1243 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1235 } 1244 }
1245 if (flags & DRAW_VERTICES_HAS_XFER) {
1246 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1247 (void)xfer->asMode(&mode);
1248 addInt(mode);
1249 }
1236 this->validate(initialOffset, size); 1250 this->validate(initialOffset, size);
1237 } 1251 }
1238 1252
1239 void SkPictureRecord::drawData(const void* data, size_t length) { 1253 void SkPictureRecord::drawData(const void* data, size_t length) {
1240 // op + length + 'length' worth of data 1254 // op + length + 'length' worth of data
1241 uint32_t size = 2 * kUInt32Size + SkAlign4(length); 1255 uint32_t size = 2 * kUInt32Size + SkAlign4(length);
1242 size_t initialOffset = this->addDraw(DRAW_DATA, &size); 1256 size_t initialOffset = this->addDraw(DRAW_DATA, &size);
1243 addInt(length); 1257 addInt(length);
1244 fWriter.writePad(data, length); 1258 fWriter.writePad(data, length);
1245 this->validate(initialOffset, size); 1259 this->validate(initialOffset, size);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 void SkPictureRecord::validateRegions() const { 1530 void SkPictureRecord::validateRegions() const {
1517 int count = fRegions.count(); 1531 int count = fRegions.count();
1518 SkASSERT((unsigned) count < 0x1000); 1532 SkASSERT((unsigned) count < 0x1000);
1519 for (int index = 0; index < count; index++) { 1533 for (int index = 0; index < count; index++) {
1520 const SkFlatData* region = fRegions[index]; 1534 const SkFlatData* region = fRegions[index];
1521 SkASSERT(region); 1535 SkASSERT(region);
1522 // region->validate(); 1536 // region->validate();
1523 } 1537 }
1524 } 1538 }
1525 #endif 1539 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698