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

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

Issue 463493002: SkCanvas::drawPatch param SkPoint[12] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Removed GPU headers from GM Created 6 years, 4 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/core/SkPictureRecord.h ('k') | src/core/SkReadBuffer.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 * 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 "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkTSearch.h" 9 #include "SkBBoxHierarchy.h"
10 #include "SkDevice.h"
11 #include "SkPatchUtils.h"
12 #include "SkPictureStateTree.h"
10 #include "SkPixelRef.h" 13 #include "SkPixelRef.h"
11 #include "SkRRect.h" 14 #include "SkRRect.h"
12 #include "SkBBoxHierarchy.h" 15 #include "SkTSearch.h"
13 #include "SkDevice.h"
14 #include "SkPictureStateTree.h"
15 16
16 #define HEAP_BLOCK_SIZE 4096 17 #define HEAP_BLOCK_SIZE 4096
17 18
18 // If SK_RECORD_LITERAL_PICTURES is defined, record our inputs as literally as p ossible. 19 // If SK_RECORD_LITERAL_PICTURES is defined, record our inputs as literally as p ossible.
19 // Otherwise, we can be clever and record faster equivalents. kBeClever is norm ally true. 20 // Otherwise, we can be clever and record faster equivalents. kBeClever is norm ally true.
20 static const bool kBeClever = 21 static const bool kBeClever =
21 #ifdef SK_RECORD_LITERAL_PICTURES 22 #ifdef SK_RECORD_LITERAL_PICTURES
22 false; 23 false;
23 #else 24 #else
24 true; 25 true;
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1263 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1263 } 1264 }
1264 if (flags & DRAW_VERTICES_HAS_XFER) { 1265 if (flags & DRAW_VERTICES_HAS_XFER) {
1265 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; 1266 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1266 (void)xfer->asMode(&mode); 1267 (void)xfer->asMode(&mode);
1267 this->addInt(mode); 1268 this->addInt(mode);
1268 } 1269 }
1269 this->validate(initialOffset, size); 1270 this->validate(initialOffset, size);
1270 } 1271 }
1271 1272
1272 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { 1273 void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors [4],
1273 // op + paint index + patch 12 control points + patch 4 colors 1274 const SkPoint texCoords[4], SkXfermode* xmode,
1274 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + 1275 const SkPaint& paint) {
1275 SkPatch::kNumColors * sizeof(SkColor); 1276 // op + paint index + patch 12 control points + flag + patch 4 colors + 4 te xture coordinates
1277 size_t size = 2 * kUInt32Size + SkPatchUtils::kNumCtrlPts * sizeof(SkPoint) + kUInt32Size;
1278 uint32_t flag = 0;
1279 if (NULL != colors) {
1280 flag |= DRAW_VERTICES_HAS_COLORS;
1281 size += SkPatchUtils::kNumCorners * sizeof(SkColor);
1282 }
1283 if (NULL != texCoords) {
1284 flag |= DRAW_VERTICES_HAS_TEXS;
1285 size += SkPatchUtils::kNumCorners * sizeof(SkPoint);
1286 }
1287 if (NULL != xmode) {
1288 SkXfermode::Mode mode;
1289 if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1290 flag |= DRAW_VERTICES_HAS_XFER;
1291 size += kUInt32Size;
1292 }
1293 }
1294
1276 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); 1295 size_t initialOffset = this->addDraw(DRAW_PATCH, &size);
1277 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten()); 1296 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten());
1278 this->addPaint(paint); 1297 this->addPaint(paint);
1279 this->addPatch(patch); 1298 this->addPatch(cubics);
1299 this->addInt(flag);
1300
1301 // write optional parameters
1302 if (NULL != colors) {
1303 fWriter.write(colors, SkPatchUtils::kNumCorners * sizeof(SkColor));
1304 }
1305 if (NULL != texCoords) {
1306 fWriter.write(texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint));
1307 }
1308 if (flag & DRAW_VERTICES_HAS_XFER) {
1309 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1310 xmode->asMode(&mode);
1311 this->addInt(mode);
1312 }
1280 this->validate(initialOffset, size); 1313 this->validate(initialOffset, size);
1281 } 1314 }
1282 1315
1283 void SkPictureRecord::drawData(const void* data, size_t length) { 1316 void SkPictureRecord::drawData(const void* data, size_t length) {
1284 // op + length + 'length' worth of data 1317 // op + length + 'length' worth of data
1285 size_t size = 2 * kUInt32Size + SkAlign4(length); 1318 size_t size = 2 * kUInt32Size + SkAlign4(length);
1286 size_t initialOffset = this->addDraw(DRAW_DATA, &size); 1319 size_t initialOffset = this->addDraw(DRAW_DATA, &size);
1287 this->addInt(SkToInt(length)); 1320 this->addInt(SkToInt(length));
1288 fWriter.writePad(data, length); 1321 fWriter.writePad(data, length);
1289 this->validate(initialOffset, size); 1322 this->validate(initialOffset, size);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 return fPathHeap->insert(path); 1432 return fPathHeap->insert(path);
1400 #else 1433 #else
1401 return fPathHeap->append(path); 1434 return fPathHeap->append(path);
1402 #endif 1435 #endif
1403 } 1436 }
1404 1437
1405 void SkPictureRecord::addPath(const SkPath& path) { 1438 void SkPictureRecord::addPath(const SkPath& path) {
1406 this->addInt(this->addPathToHeap(path)); 1439 this->addInt(this->addPathToHeap(path));
1407 } 1440 }
1408 1441
1409 void SkPictureRecord::addPatch(const SkPatch& patch) { 1442 void SkPictureRecord::addPatch(const SkPoint cubics[12]) {
1410 fWriter.writePatch(patch); 1443 fWriter.write(cubics, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint));
1411 } 1444 }
1412 1445
1413 void SkPictureRecord::addPicture(const SkPicture* picture) { 1446 void SkPictureRecord::addPicture(const SkPicture* picture) {
1414 int index = fPictureRefs.find(picture); 1447 int index = fPictureRefs.find(picture);
1415 if (index < 0) { // not found 1448 if (index < 0) { // not found
1416 index = fPictureRefs.count(); 1449 index = fPictureRefs.count();
1417 *fPictureRefs.append() = picture; 1450 *fPictureRefs.append() = picture;
1418 picture->ref(); 1451 picture->ref();
1419 } 1452 }
1420 // follow the convention of recording a 1-based index 1453 // follow the convention of recording a 1-based index
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 } 1496 }
1464 1497
1465 void SkPictureRecord::addText(const void* text, size_t byteLength) { 1498 void SkPictureRecord::addText(const void* text, size_t byteLength) {
1466 fContentInfo.onDrawText(); 1499 fContentInfo.onDrawText();
1467 addInt(SkToInt(byteLength)); 1500 addInt(SkToInt(byteLength));
1468 fWriter.writePad(text, byteLength); 1501 fWriter.writePad(text, byteLength);
1469 } 1502 }
1470 1503
1471 /////////////////////////////////////////////////////////////////////////////// 1504 ///////////////////////////////////////////////////////////////////////////////
1472 1505
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkReadBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698