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

Side by Side Diff: dm/DMReplayTask.cpp

Issue 32613003: DM: add --serialize (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: no-find-copies Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « dm/DMReplayTask.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 "DMReplayTask.h" 1 #include "DMReplayTask.h"
2 #include "DMWriteTask.h"
2 #include "DMUtil.h" 3 #include "DMUtil.h"
3 4
5 #include "SkCommandLineFlags.h"
4 #include "SkPicture.h" 6 #include "SkPicture.h"
5 7
8 DEFINE_bool(replay, false, "If true, run picture replay tests.");
9
6 namespace DM { 10 namespace DM {
7 11
8 ReplayTask::ReplayTask(const char* suffix, 12 ReplayTask::ReplayTask(const Task& parent,
9 const Task& parent,
10 skiagm::GM* gm, 13 skiagm::GM* gm,
11 SkBitmap reference) 14 SkBitmap reference)
12 : Task(parent) 15 : Task(parent)
13 , fName(underJoin(parent.name().c_str(), suffix)) 16 , fName(UnderJoin(parent.name().c_str(), "replay"))
14 , fGM(gm) 17 , fGM(gm)
15 , fReference(reference) 18 , fReference(reference)
16 {} 19 {}
17 20
18 void ReplayTask::draw() { 21 void ReplayTask::draw() {
19 SkPicture picture; 22 SkPicture recorded;
20 SkCanvas* canvas = picture.beginRecording(SkScalarCeilToInt(fGM->width()), 23 RecordPicture(fGM.get(), &recorded);
21 SkScalarCeilToInt(fGM->height()),
22 0 /*flags*/);
23
24 canvas->concat(fGM->getInitialTransform());
25 fGM->draw(canvas);
26 canvas->flush();
27
28 picture.endRecording();
29 24
30 SkBitmap bitmap; 25 SkBitmap bitmap;
31 bitmap.setConfig(fReference.config(), 26 SetupBitmap(fReference.config(), fGM.get(), &bitmap);
32 SkScalarCeilToInt(fGM->width()), 27 DrawPicture(&recorded, &bitmap);
33 SkScalarCeilToInt(fGM->height())); 28 if (!BitmapsEqual(bitmap, fReference)) {
34 bitmap.allocPixels();
35 bitmap.eraseColor(0x00000000);
36
37 SkCanvas replay(bitmap);
38 replay.drawPicture(picture);
39 replay.flush();
40
41 const SkAutoLockPixels mine(bitmap), theirs(fReference);
42 if (bitmap.getSize() != fReference.getSize() ||
43 0 != memcmp(bitmap.getPixels(), fReference.getPixels(), bitmap.getSize() ))
44 {
45 this->fail(); 29 this->fail();
30 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
46 } 31 }
47 } 32 }
48 33
49 bool ReplayTask::shouldSkip() const { 34 bool ReplayTask::shouldSkip() const {
50 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || 35 return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
51 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
52 } 36 }
53 37
54 } // namespace DM 38 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMSerializeTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698