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

Side by Side Diff: dm/DMRecordTask.cpp

Issue 345553003: Support serialization in SkRecord-backed SkPictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: robert Created 6 years, 6 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 | « dm/DMRecordTask.h ('k') | dm/DMReplayTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "DMRecordTask.h"
2 #include "DMUtil.h"
3 #include "DMWriteTask.h"
4 #include "SkCommandLineFlags.h"
5 #include "SkRecord.h"
6 #include "SkRecordDraw.h"
7 #include "SkRecordOpts.h"
8 #include "SkRecorder.h"
9
10 DEFINE_bool(skr, true, "If true, run SKR tests.");
11
12 namespace DM {
13
14 RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, M ode mode)
15 : CpuTask(parent)
16 , fOptimize(mode == kOptimize_Mode)
17 , fName(UnderJoin(parent.name().c_str(), fOptimize ? "skr" : "skr-noopt"))
18 , fGM(gm)
19 , fReference(reference)
20 {}
21
22 RecordTask::RecordTask(const Task& parent, SkPicture* pic, SkBitmap reference, M ode mode)
23 : CpuTask(parent)
24 , fOptimize(mode == kOptimize_Mode)
25 , fName(UnderJoin(parent.name().c_str(), fOptimize ? "skr" : "skr-noopt"))
26 , fPicture(SkRef(pic))
27 , fReference(reference)
28 {}
29
30 void RecordTask::draw() {
31 // Record into an SkRecord.
32 SkRecord record;
33 SkRecorder recorder(&record, fReference.width(), fReference.height());
34
35 if (fGM.get()) {
36 recorder.concat(fGM->getInitialTransform());
37 fGM->draw(&recorder);
38 } else {
39 fPicture->draw(&recorder);
40 }
41
42
43 if (fOptimize) {
44 SkRecordOptimize(&record);
45 }
46
47 // Draw the SkRecord back into a bitmap.
48 SkBitmap bitmap;
49 AllocatePixels(fReference, &bitmap);
50 SkCanvas target(bitmap);
51 SkRecordDraw(record, &target);
52
53 if (!BitmapsEqual(bitmap, fReference)) {
54 this->fail();
55 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
56 }
57 }
58
59 bool RecordTask::shouldSkip() const {
60 return !FLAGS_skr;
61 }
62
63 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMRecordTask.h ('k') | dm/DMReplayTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698