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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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 | « debugger/QT/SkDebuggerGUI.cpp ('k') | fuzz/fuzz.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 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 896
897 static const SkRect kSKPViewport = {0,0, 1000,1000}; 897 static const SkRect kSKPViewport = {0,0, 1000,1000};
898 898
899 SKPSrc::SKPSrc(Path path) : fPath(path) {} 899 SKPSrc::SKPSrc(Path path) : fPath(path) {}
900 900
901 Error SKPSrc::draw(SkCanvas* canvas) const { 901 Error SKPSrc::draw(SkCanvas* canvas) const {
902 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 902 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
903 if (!stream) { 903 if (!stream) {
904 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 904 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
905 } 905 }
906 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream)); 906 sk_sp<SkPicture> pic(SkPicture::MakeFromStream(stream));
907 if (!pic) { 907 if (!pic) {
908 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 908 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
909 } 909 }
910 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it. 910 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it.
911 911
912 canvas->clipRect(kSKPViewport); 912 canvas->clipRect(kSKPViewport);
913 canvas->drawPicture(pic); 913 canvas->drawPicture(pic);
914 return ""; 914 return "";
915 } 915 }
916 916
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 SKPSink::SKPSink() {} 1109 SKPSink::SKPSink() {}
1110 1110
1111 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1111 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1112 SkSize size; 1112 SkSize size;
1113 size = src.size(); 1113 size = src.size();
1114 SkPictureRecorder recorder; 1114 SkPictureRecorder recorder;
1115 Error err = src.draw(recorder.beginRecording(size.width(), size.height())); 1115 Error err = src.draw(recorder.beginRecording(size.width(), size.height()));
1116 if (!err.isEmpty()) { 1116 if (!err.isEmpty()) {
1117 return err; 1117 return err;
1118 } 1118 }
1119 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1119 recorder.finishRecordingAsPicture()->serialize(dst);
1120 pic->serialize(dst);
1121 return ""; 1120 return "";
1122 } 1121 }
1123 1122
1124 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1123 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1125 1124
1126 SVGSink::SVGSink() {} 1125 SVGSink::SVGSink() {}
1127 1126
1128 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1127 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1129 SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst)); 1128 SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
1130 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create( 1129 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 Error ViaSerialization::draw( 1265 Error ViaSerialization::draw(
1267 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t { 1266 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t {
1268 // Record our Src into a picture. 1267 // Record our Src into a picture.
1269 auto size = src.size(); 1268 auto size = src.size();
1270 SkPictureRecorder recorder; 1269 SkPictureRecorder recorder;
1271 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 1270 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
1272 SkIntToScalar(size.height()))); 1271 SkIntToScalar(size.height())));
1273 if (!err.isEmpty()) { 1272 if (!err.isEmpty()) {
1274 return err; 1273 return err;
1275 } 1274 }
1276 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1275 sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
1277 1276
1278 // Serialize it and then deserialize it. 1277 // Serialize it and then deserialize it.
1279 SkDynamicMemoryWStream wStream; 1278 SkDynamicMemoryWStream wStream;
1280 pic->serialize(&wStream); 1279 pic->serialize(&wStream);
1281 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1280 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1282 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream)); 1281 sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rStream));
1283 1282
1284 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1283 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1285 canvas->drawPicture(deserialized); 1284 canvas->drawPicture(deserialized);
1286 return check_against_reference(bitmap, src, fSink); 1285 return check_against_reference(bitmap, src, fSink);
1287 }); 1286 });
1288 } 1287 }
1289 1288
1290 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1289 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1291 1290
1292 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1291 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
1293 : Via(sink) 1292 : Via(sink)
1294 , fW(w) 1293 , fW(w)
1295 , fH(h) 1294 , fH(h)
1296 , fFactory(factory) {} 1295 , fFactory(factory) {}
1297 1296
1298 Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const { 1297 Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const {
1299 auto size = src.size(); 1298 auto size = src.size();
1300 SkPictureRecorder recorder; 1299 SkPictureRecorder recorder;
1301 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 1300 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
1302 SkIntToScalar(size.height()), 1301 SkIntToScalar(size.height()),
1303 fFactory.get())); 1302 fFactory.get()));
1304 if (!err.isEmpty()) { 1303 if (!err.isEmpty()) {
1305 return err; 1304 return err;
1306 } 1305 }
1307 SkAutoTUnref<SkPicture> pic(recorder.endRecordingAsPicture()); 1306 sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
1308 1307
1309 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) { 1308 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
1310 const int xTiles = (size.width() + fW - 1) / fW, 1309 const int xTiles = (size.width() + fW - 1) / fW,
1311 yTiles = (size.height() + fH - 1) / fH; 1310 yTiles = (size.height() + fH - 1) / fH;
1312 SkMultiPictureDraw mpd(xTiles*yTiles); 1311 SkMultiPictureDraw mpd(xTiles*yTiles);
1313 SkTDArray<SkSurface*> surfaces; 1312 SkTDArray<SkSurface*> surfaces;
1314 surfaces.setReserve(xTiles*yTiles); 1313 surfaces.setReserve(xTiles*yTiles);
1315 1314
1316 SkImageInfo info = canvas->imageInfo().makeWH(fW, fH); 1315 SkImageInfo info = canvas->imageInfo().makeWH(fW, fH);
1317 for (int j = 0; j < yTiles; j++) { 1316 for (int j = 0; j < yTiles; j++) {
1318 for (int i = 0; i < xTiles; i++) { 1317 for (int i = 0; i < xTiles; i++) {
1319 // This lets our ultimate Sink determine the best kind of surfac e. 1318 // This lets our ultimate Sink determine the best kind of surfac e.
1320 // E.g., if it's a GpuSink, the surfaces and images are textures . 1319 // E.g., if it's a GpuSink, the surfaces and images are textures .
1321 SkSurface* s = canvas->newSurface(info); 1320 SkSurface* s = canvas->newSurface(info);
1322 if (!s) { 1321 if (!s) {
1323 s = SkSurface::NewRaster(info); // Some canvases can't crea te surfaces. 1322 s = SkSurface::NewRaster(info); // Some canvases can't crea te surfaces.
1324 } 1323 }
1325 surfaces.push(s); 1324 surfaces.push(s);
1326 SkCanvas* c = s->getCanvas(); 1325 SkCanvas* c = s->getCanvas();
1327 c->translate(SkIntToScalar(-i * fW), 1326 c->translate(SkIntToScalar(-i * fW),
1328 SkIntToScalar(-j * fH)); // Line up the canvas wit h this tile. 1327 SkIntToScalar(-j * fH)); // Line up the canvas wit h this tile.
1329 mpd.add(c, pic); 1328 mpd.add(c, pic.get());
1330 } 1329 }
1331 } 1330 }
1332 mpd.draw(); 1331 mpd.draw();
1333 for (int j = 0; j < yTiles; j++) { 1332 for (int j = 0; j < yTiles; j++) {
1334 for (int i = 0; i < xTiles; i++) { 1333 for (int i = 0; i < xTiles; i++) {
1335 sk_sp<SkImage> image(surfaces[i+xTiles*j]->makeImageSnapshot()); 1334 sk_sp<SkImage> image(surfaces[i+xTiles*j]->makeImageSnapshot());
1336 canvas->drawImage(image, SkIntToScalar(i*fW), SkIntToScalar(j*fH )); 1335 canvas->drawImage(image, SkIntToScalar(i*fW), SkIntToScalar(j*fH ));
1337 } 1336 }
1338 } 1337 }
1339 surfaces.unrefAll(); 1338 surfaces.unrefAll();
1340 return ""; 1339 return "";
1341 }); 1340 });
1342 } 1341 }
1343 1342
1344 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1343 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1345 1344
1346 Error ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt ring* log) const { 1345 Error ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt ring* log) const {
1347 auto size = src.size(); 1346 auto size = src.size();
1348 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) -> Error { 1347 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) -> Error {
1349 SkPictureRecorder recorder; 1348 SkPictureRecorder recorder;
1350 SkAutoTUnref<SkPicture> pic; 1349 sk_sp<SkPicture> pic;
1351 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()) , 1350 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()) ,
1352 SkIntToScalar(size.height() ))); 1351 SkIntToScalar(size.height() )));
1353 if (!err.isEmpty()) { 1352 if (!err.isEmpty()) {
1354 return err; 1353 return err;
1355 } 1354 }
1356 pic.reset(recorder.endRecordingAsPicture()); 1355 pic = recorder.finishRecordingAsPicture();
1357 canvas->drawPicture(pic); 1356 canvas->drawPicture(pic);
1358 return check_against_reference(bitmap, src, fSink); 1357 return check_against_reference(bitmap, src, fSink);
1359 }); 1358 });
1360 } 1359 }
1361 1360
1362 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1361 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1363 1362
1364 // Draw the Src into two pictures, then draw the second picture into the wrapped Sink. 1363 // Draw the Src into two pictures, then draw the second picture into the wrapped Sink.
1365 // This tests that any shortcuts we may take while recording that second picture are legal. 1364 // This tests that any shortcuts we may take while recording that second picture are legal.
1366 Error ViaSecondPicture::draw( 1365 Error ViaSecondPicture::draw(
1367 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t { 1366 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t {
1368 auto size = src.size(); 1367 auto size = src.size();
1369 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) -> Error { 1368 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) -> Error {
1370 SkPictureRecorder recorder; 1369 SkPictureRecorder recorder;
1371 SkAutoTUnref<SkPicture> pic; 1370 sk_sp<SkPicture> pic;
1372 for (int i = 0; i < 2; i++) { 1371 for (int i = 0; i < 2; i++) {
1373 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.widt h()), 1372 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.widt h()),
1374 SkIntToScalar(size.heig ht()))); 1373 SkIntToScalar(size.heig ht())));
1375 if (!err.isEmpty()) { 1374 if (!err.isEmpty()) {
1376 return err; 1375 return err;
1377 } 1376 }
1378 pic.reset(recorder.endRecordingAsPicture()); 1377 pic = recorder.finishRecordingAsPicture();
1379 } 1378 }
1380 canvas->drawPicture(pic); 1379 canvas->drawPicture(pic);
1381 return check_against_reference(bitmap, src, fSink); 1380 return check_against_reference(bitmap, src, fSink);
1382 }); 1381 });
1383 } 1382 }
1384 1383
1385 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1384 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1386 1385
1387 // Draw the Src twice. This can help exercise caching. 1386 // Draw the Src twice. This can help exercise caching.
1388 Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const { 1387 Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri ng* log) const {
(...skipping 13 matching lines...) Expand all
1402 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1401 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1403 1402
1404 #ifdef SK_MOJO 1403 #ifdef SK_MOJO
1405 Error ViaMojo::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkS tring* log) const { 1404 Error ViaMojo::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkS tring* log) const {
1406 SkPictureRecorder recorder; 1405 SkPictureRecorder recorder;
1407 SkRect size = SkRect::Make(SkIRect::MakeSize(src.size())); 1406 SkRect size = SkRect::Make(SkIRect::MakeSize(src.size()));
1408 Error err = src.draw(recorder.beginRecording(size)); 1407 Error err = src.draw(recorder.beginRecording(size));
1409 if (!err.isEmpty()) { 1408 if (!err.isEmpty()) {
1410 return err; 1409 return err;
1411 } 1410 }
1412 SkAutoTUnref<SkPicture> skPicture(recorder.endRecording()); 1411 sk_sp<SkPicture> skPicture(recorder.finishRecordingAsPicture());
1413 1412
1414 SkASSERT(skPicture); 1413 SkASSERT(skPicture);
1415 SkDynamicMemoryWStream buffer; 1414 SkDynamicMemoryWStream buffer;
1416 skPicture->serialize(&buffer); 1415 skPicture->serialize(&buffer);
1417 skPicture.reset(); 1416 skPicture.reset();
1418 SkMojo::FlattenedPicturePtr mojoPicture = SkMojo::FlattenedPicture::New( ); 1417 SkMojo::FlattenedPicturePtr mojoPicture = SkMojo::FlattenedPicture::New( );
1419 mojoPicture->data.resize(buffer.bytesWritten()); 1418 mojoPicture->data.resize(buffer.bytesWritten());
1420 buffer.copyTo(mojoPicture->data.data()); 1419 buffer.copyTo(mojoPicture->data.data());
1421 buffer.reset(); 1420 buffer.reset();
1422 SkASSERT(mojoPicture.get() && mojoPicture->data); 1421 SkASSERT(mojoPicture.get() && mojoPicture->data);
1423 1422
1424 size_t flatSize = mojoPicture->GetSerializedSize(); 1423 size_t flatSize = mojoPicture->GetSerializedSize();
1425 SkAutoMalloc storage(flatSize); 1424 SkAutoMalloc storage(flatSize);
1426 if (!mojoPicture->Serialize(storage.get(), flatSize)) { 1425 if (!mojoPicture->Serialize(storage.get(), flatSize)) {
1427 return "SkMojo::FlattenedPicture::Serialize failed"; 1426 return "SkMojo::FlattenedPicture::Serialize failed";
1428 } 1427 }
1429 mojoPicture = SkMojo::FlattenedPicture::New(); 1428 mojoPicture = SkMojo::FlattenedPicture::New();
1430 mojoPicture->Deserialize(storage.get()); 1429 mojoPicture->Deserialize(storage.get());
1431 storage.reset(); 1430 storage.reset();
1432 if (!mojoPicture) { 1431 if (!mojoPicture) {
1433 return "SkMojo::FlattenedPicture::Deserialize failed"; 1432 return "SkMojo::FlattenedPicture::Deserialize failed";
1434 } 1433 }
1435 SkMemoryStream tmpStream(mojoPicture->data.data(), 1434 SkMemoryStream tmpStream(mojoPicture->data.data(),
1436 mojoPicture->data.size()); 1435 mojoPicture->data.size());
1437 skPicture.reset(SkPicture::CreateFromStream(&tmpStream)); 1436 skPicture = SkPicture::MakeFromStream(&tmpStream);
1438 mojoPicture.reset(); 1437 mojoPicture.reset();
1439 auto fn = [&](SkCanvas* canvas) -> Error { 1438 auto fn = [&](SkCanvas* canvas) -> Error {
1440 canvas->drawPicture(skPicture.get()); 1439 canvas->drawPicture(skPicture.get());
1441 return check_against_reference(bitmap, src, fSink); 1440 return check_against_reference(bitmap, src, fSink);
1442 }; 1441 };
1443 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), fn); 1442 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), fn);
1444 } 1443 }
1445 #else // not SK_MOJO 1444 #else // not SK_MOJO
1446 Error ViaMojo::draw(const Src&, SkBitmap*, SkWStream*, SkString*) const { 1445 Error ViaMojo::draw(const Src&, SkBitmap*, SkWStream*, SkString*) const {
1447 return "Mojo is missing!"; 1446 return "Mojo is missing!";
(...skipping 16 matching lines...) Expand all
1464 // which would have the funky effect of applying transforms over and ove r. 1463 // which would have the funky effect of applying transforms over and ove r.
1465 SkRecords::Draw d(canvas, nullptr, fDrawables.begin(), fDrawables.count( ), &SkMatrix::I()); 1464 SkRecords::Draw d(canvas, nullptr, fDrawables.begin(), fDrawables.count( ), &SkMatrix::I());
1466 d(op); 1465 d(op);
1467 } 1466 }
1468 1467
1469 // Draws get their own picture. 1468 // Draws get their own picture.
1470 template <typename T> 1469 template <typename T>
1471 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) { 1470 SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) {
1472 SkPictureRecorder rec; 1471 SkPictureRecorder rec;
1473 this->draw(op, rec.beginRecording(SkRect::MakeLargest())); 1472 this->draw(op, rec.beginRecording(SkRect::MakeLargest()));
1474 SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture()); 1473 sk_sp<SkPicture> pic(rec.finishRecordingAsPicture());
1475 fCanvas->drawPicture(pic); 1474 fCanvas->drawPicture(pic);
1476 } 1475 }
1477 1476
1478 // We'll just issue non-draws directly. 1477 // We'll just issue non-draws directly.
1479 template <typename T> 1478 template <typename T>
1480 skstd::enable_if_t<!(T::kTags & SkRecords::kDraw_Tag), void> operator()(cons t T& op) { 1479 skstd::enable_if_t<!(T::kTags & SkRecords::kDraw_Tag), void> operator()(cons t T& op) {
1481 this->draw(op, fCanvas); 1480 this->draw(op, fCanvas);
1482 } 1481 }
1483 }; 1482 };
1484 1483
(...skipping 19 matching lines...) Expand all
1504 SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList()); 1503 SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList());
1505 const SkDrawableList empty; 1504 const SkDrawableList empty;
1506 1505
1507 DrawsAsSingletonPictures drawsAsSingletonPictures = { 1506 DrawsAsSingletonPictures drawsAsSingletonPictures = {
1508 macroCanvas, 1507 macroCanvas,
1509 drawables ? *drawables : empty, 1508 drawables ? *drawables : empty,
1510 }; 1509 };
1511 for (int i = 0; i < skr.count(); i++) { 1510 for (int i = 0; i < skr.count(); i++) {
1512 skr.visit<void>(i, drawsAsSingletonPictures); 1511 skr.visit<void>(i, drawsAsSingletonPictures);
1513 } 1512 }
1514 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1513 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1515 1514
1516 canvas->drawPicture(macroPic); 1515 canvas->drawPicture(macroPic);
1517 return check_against_reference(bitmap, src, fSink); 1516 return check_against_reference(bitmap, src, fSink);
1518 }); 1517 });
1519 } 1518 }
1520 1519
1521 } // namespace DM 1520 } // namespace DM
OLDNEW
« no previous file with comments | « debugger/QT/SkDebuggerGUI.cpp ('k') | fuzz/fuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698