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/core/SkPictureRecord.cpp

Issue 463493002: SkCanvas::drawPatch param SkPoint[12] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebased for SkPictureRecord 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
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 "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1262 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1263 } 1263 }
1264 if (flags & DRAW_VERTICES_HAS_XFER) { 1264 if (flags & DRAW_VERTICES_HAS_XFER) {
1265 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; 1265 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1266 (void)xfer->asMode(&mode); 1266 (void)xfer->asMode(&mode);
1267 this->addInt(mode); 1267 this->addInt(mode);
1268 } 1268 }
1269 this->validate(initialOffset, size); 1269 this->validate(initialOffset, size);
1270 } 1270 }
1271 1271
1272 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { 1272 void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors [4],
1273 // op + paint index + patch 12 control points + patch 4 colors 1273 const SkPoint texCoords[4], SkXfermode* xmode,
1274 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + 1274 const SkPaint& paint) {
1275 SkPatch::kNumColors * sizeof(SkColor); 1275 // op + paint index + patch 12 control points + flag + patch 4 colors + 4 te xture coordinates
1276 size_t size = 2 * kUInt32Size + SkPatchUtils::kNumCtrlPts * sizeof(SkPoint) + kUInt32Size;
1277 uint32_t flag = 0;
1278 if (NULL != colors) {
1279 flag |= DRAW_VERTICES_HAS_COLORS;
1280 size += SkPatchUtils::kNumCorners * sizeof(SkColor);
1281 }
1282 if (NULL != texCoords) {
1283 flag |= DRAW_VERTICES_HAS_TEXS;
1284 size += SkPatchUtils::kNumCorners * sizeof(SkPoint);
1285 }
1286 if (NULL != xmode) {
1287 SkXfermode::Mode mode;
1288 if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1289 flag |= DRAW_VERTICES_HAS_XFER;
1290 size += kUInt32Size;
1291 }
1292 }
1293
1276 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); 1294 size_t initialOffset = this->addDraw(DRAW_PATCH, &size);
1277 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten()); 1295 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten());
1278 this->addPaint(paint); 1296 this->addPaint(paint);
1279 this->addPatch(patch); 1297 this->addPatch(cubics);
1298 this->addInt(flag);
1299
1300 // write optional parameters
1301 if (NULL != colors) {
1302 fWriter.write(colors, SkPatchUtils::kNumCorners * sizeof(SkColor));
1303 }
1304 if (NULL != texCoords) {
1305 fWriter.write(texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint));
1306 }
1307 if (flag & DRAW_VERTICES_HAS_XFER) {
1308 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1309 xmode->asMode(&mode);
1310 this->addInt(mode);
1311 }
1280 this->validate(initialOffset, size); 1312 this->validate(initialOffset, size);
1281 } 1313 }
1282 1314
1283 void SkPictureRecord::drawData(const void* data, size_t length) { 1315 void SkPictureRecord::drawData(const void* data, size_t length) {
1284 // op + length + 'length' worth of data 1316 // op + length + 'length' worth of data
1285 size_t size = 2 * kUInt32Size + SkAlign4(length); 1317 size_t size = 2 * kUInt32Size + SkAlign4(length);
1286 size_t initialOffset = this->addDraw(DRAW_DATA, &size); 1318 size_t initialOffset = this->addDraw(DRAW_DATA, &size);
1287 this->addInt(SkToInt(length)); 1319 this->addInt(SkToInt(length));
1288 fWriter.writePad(data, length); 1320 fWriter.writePad(data, length);
1289 this->validate(initialOffset, size); 1321 this->validate(initialOffset, size);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 return fPathHeap->insert(path); 1431 return fPathHeap->insert(path);
1400 #else 1432 #else
1401 return fPathHeap->append(path); 1433 return fPathHeap->append(path);
1402 #endif 1434 #endif
1403 } 1435 }
1404 1436
1405 void SkPictureRecord::addPath(const SkPath& path) { 1437 void SkPictureRecord::addPath(const SkPath& path) {
1406 this->addInt(this->addPathToHeap(path)); 1438 this->addInt(this->addPathToHeap(path));
1407 } 1439 }
1408 1440
1409 void SkPictureRecord::addPatch(const SkPatch& patch) { 1441 void SkPictureRecord::addPatch(const SkPoint cubics[12]) {
1410 fWriter.writePatch(patch); 1442 fWriter.write(cubics, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint));
1411 } 1443 }
1412 1444
1413 void SkPictureRecord::addPicture(const SkPicture* picture) { 1445 void SkPictureRecord::addPicture(const SkPicture* picture) {
1414 int index = fPictureRefs.find(picture); 1446 int index = fPictureRefs.find(picture);
1415 if (index < 0) { // not found 1447 if (index < 0) { // not found
1416 index = fPictureRefs.count(); 1448 index = fPictureRefs.count();
1417 *fPictureRefs.append() = picture; 1449 *fPictureRefs.append() = picture;
1418 picture->ref(); 1450 picture->ref();
1419 } 1451 }
1420 // follow the convention of recording a 1-based index 1452 // follow the convention of recording a 1-based index
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 } 1495 }
1464 1496
1465 void SkPictureRecord::addText(const void* text, size_t byteLength) { 1497 void SkPictureRecord::addText(const void* text, size_t byteLength) {
1466 fContentInfo.onDrawText(); 1498 fContentInfo.onDrawText();
1467 addInt(SkToInt(byteLength)); 1499 addInt(SkToInt(byteLength));
1468 fWriter.writePad(text, byteLength); 1500 fWriter.writePad(text, byteLength);
1469 } 1501 }
1470 1502
1471 /////////////////////////////////////////////////////////////////////////////// 1503 ///////////////////////////////////////////////////////////////////////////////
1472 1504
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698