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

Side by Side Diff: dm/DMSKPTask.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/DMSKPTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMRecordTask.h"
2 #include "DMSKPTask.h" 1 #include "DMSKPTask.h"
3 #include "DMUtil.h" 2 #include "DMUtil.h"
4 #include "DMWriteTask.h" 3 #include "DMWriteTask.h"
5 4
5 #include "SkCommandLineFlags.h"
6 #include "SkPictureRecorder.h"
7
8 DECLARE_bool(skr); // in DMReplayTask.cpp
9
6 namespace DM { 10 namespace DM {
7 11
8 SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename) 12 // Test that an SkPicture plays back the same when re-recorded into an
13 // SkPicture backed by SkRecord.
14 class SkrComparisonTask : public CpuTask {
15 public:
16 SkrComparisonTask(const Task& parent, const SkPicture* picture, SkBitmap ref erence)
17 : CpuTask(parent)
18 , fPicture(picture)
19 , fReference(reference)
20 , fName(UnderJoin(parent.name().c_str(), "skr")) {}
21
22 virtual bool shouldSkip() const SK_OVERRIDE { return !FLAGS_skr; }
23 virtual SkString name() const SK_OVERRIDE { return fName; }
24
25 virtual void draw() SK_OVERRIDE {
26 SkPictureRecorder recorder;
27 fPicture->draw(recorder.EXPERIMENTAL_beginRecording(fPicture->width(), f Picture->height()));
28 SkAutoTDelete<const SkPicture> skrPicture(recorder.endRecording());
29
30 SkBitmap bitmap;
31 AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
32 DrawPicture(*skrPicture, &bitmap);
33
34 if (!BitmapsEqual(fReference, bitmap)) {
35 this->fail();
36 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
37 }
38 }
39
40 private:
41 SkAutoTUnref<const SkPicture> fPicture;
42 const SkBitmap fReference;
43 const SkString fName;
44 };
45
46
47 SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString fil ename)
9 : CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {} 48 : CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
10 49
11 void SKPTask::draw() { 50 void SKPTask::draw() {
12 SkBitmap bitmap; 51 SkBitmap bitmap;
13 AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bit map); 52 AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bit map);
14 DrawPicture(fPicture, &bitmap); 53 DrawPicture(*fPicture, &bitmap);
15 54
16 this->spawnChild(SkNEW_ARGS(RecordTask,
17 (*this, fPicture, bitmap, RecordTask::kNoOptimiz e_Mode)));
18 this->spawnChild(SkNEW_ARGS(RecordTask,
19 (*this, fPicture, bitmap, RecordTask::kOptimize_ Mode)));
20 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); 55 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
56 this->spawnChild(SkNEW_ARGS(SkrComparisonTask, (*this, fPicture.get(), bitma p)));
21 } 57 }
22 58
23 } // namespace DM 59 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSKPTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698