Index: dm/DMRecordTask.cpp |
diff --git a/dm/DMRecordTask.cpp b/dm/DMRecordTask.cpp |
index 531fe57f9476f489b1bd6157456b6eda28acd156..ce27aaa6f998e6ff6d31c6f371fee0550de61c48 100644 |
--- a/dm/DMRecordTask.cpp |
+++ b/dm/DMRecordTask.cpp |
@@ -11,21 +11,35 @@ DEFINE_bool(skr, true, "If true, run SKR tests."); |
namespace DM { |
-RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, bool optimize) |
+RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, Mode mode) |
: CpuTask(parent) |
- , fName(UnderJoin(parent.name().c_str(), optimize ? "skr" : "skr-noopt")) |
+ , fOptimize(mode == kOptimize_Mode) |
+ , fName(UnderJoin(parent.name().c_str(), fOptimize ? "skr" : "skr-noopt")) |
, fGM(gm) |
, fReference(reference) |
- , fOptimize(optimize) |
+ {} |
+ |
+RecordTask::RecordTask(const Task& parent, SkPicture* pic, SkBitmap reference, Mode mode) |
+ : CpuTask(parent) |
+ , fOptimize(mode == kOptimize_Mode) |
+ , fName(UnderJoin(parent.name().c_str(), fOptimize ? "skr" : "skr-noopt")) |
+ , fPicture(SkRef(pic)) |
+ , fReference(reference) |
{} |
void RecordTask::draw() { |
- // Record the GM into an SkRecord. |
+ // Record into an SkRecord. |
SkRecord record; |
SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, |
fReference.width(), fReference.height()); |
- recorder.concat(fGM->getInitialTransform()); |
- fGM->draw(&recorder); |
+ |
+ if (fGM.get()) { |
+ recorder.concat(fGM->getInitialTransform()); |
+ fGM->draw(&recorder); |
+ } else { |
+ fPicture->draw(&recorder); |
+ } |
+ |
if (fOptimize) { |
SkRecordOptimize(&record); |
@@ -33,7 +47,11 @@ void RecordTask::draw() { |
// Draw the SkRecord back into a bitmap. |
SkBitmap bitmap; |
- SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); |
+ if (fGM.get()) { |
+ SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); |
+ } else { |
+ SetupBitmap(fReference.colorType(), *fPicture, &bitmap); |
+ } |
SkCanvas target(bitmap); |
SkRecordDraw(record, &target); |