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

Side by Side Diff: dm/DMSKPTask.cpp

Issue 492023002: Install a hook to swap between SkPicture backends with a single define. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment 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
« no previous file with comments | « no previous file | dm/DMSerializeTask.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 #include "DMSKPTask.h" 1 #include "DMSKPTask.h"
2 #include "DMUtil.h" 2 #include "DMUtil.h"
3 #include "DMWriteTask.h" 3 #include "DMWriteTask.h"
4 4
5 #include "SkCommandLineFlags.h" 5 #include "SkCommandLineFlags.h"
6 #include "SkPictureRecorder.h" 6 #include "SkPictureRecorder.h"
7 7
8 DEFINE_bool(skr, true, "Test that SKPs draw the same when re-recorded with SkRec ord backend.");
9 DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width."); 8 DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width.");
10 DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height."); 9 DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height.");
11 10
12 namespace DM { 11 namespace DM {
13 12
14 // Test that an SkPicture plays back the same when re-recorded into an
15 // SkPicture backed by SkRecord.
16 class SkrComparisonTask : public CpuTask {
17 public:
18 SkrComparisonTask(const Task& parent, const SkPicture* picture, SkBitmap ref erence)
19 : CpuTask(parent)
20 , fPicture(SkRef(picture))
21 , fReference(reference)
22 , fName(UnderJoin(parent.name().c_str(), "skr")) {}
23
24 virtual bool shouldSkip() const SK_OVERRIDE { return !FLAGS_skr; }
25 virtual SkString name() const SK_OVERRIDE { return fName; }
26
27 virtual void draw() SK_OVERRIDE {
28 SkPictureRecorder recorder;
29 fPicture->draw(recorder.EXPERIMENTAL_beginRecording(fPicture->width(), f Picture->height()));
30 SkAutoTDelete<const SkPicture> skrPicture(recorder.endRecording());
31
32 SkBitmap bitmap;
33 AllocatePixels(kN32_SkColorType, fReference.width(), fReference.height() , &bitmap);
34 DrawPicture(*skrPicture, &bitmap);
35
36 if (!BitmapsEqual(fReference, bitmap)) {
37 this->fail();
38 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
39 }
40 }
41
42 private:
43 SkAutoTUnref<const SkPicture> fPicture;
44 const SkBitmap fReference;
45 const SkString fName;
46 };
47
48
49 SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString fil ename) 13 SKPTask::SKPTask(Reporter* r, TaskRunner* tr, const SkPicture* pic, SkString fil ename)
50 : CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {} 14 : CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
51 15
52 void SKPTask::draw() { 16 void SKPTask::draw() {
53 const int width = SkTMin(fPicture->width(), FLAGS_skpMaxWidth), 17 const int width = SkTMin(fPicture->width(), FLAGS_skpMaxWidth),
54 height = SkTMin(fPicture->height(), FLAGS_skpMaxHeight); 18 height = SkTMin(fPicture->height(), FLAGS_skpMaxHeight);
55 SkBitmap bitmap; 19 SkBitmap bitmap;
56 AllocatePixels(kN32_SkColorType, width, height, &bitmap); 20 AllocatePixels(kN32_SkColorType, width, height, &bitmap);
57 DrawPicture(*fPicture, &bitmap); 21 DrawPicture(*fPicture, &bitmap);
58 22
59 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); 23 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
60 this->spawnChild(SkNEW_ARGS(SkrComparisonTask, (*this, fPicture.get(), bitma p)));
61 } 24 }
62 25
63 } // namespace DM 26 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | dm/DMSerializeTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698