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

Side by Side Diff: dm/DMSKPTask.cpp

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

Powered by Google App Engine
This is Rietveld 408576698