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

Side by Side Diff: dm/DMReplayTask.cpp

Issue 27476007: DM: duh, don't calculate digests unless we're going to look at them. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/DMUtil.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 "DMUtil.h" 2 #include "DMUtil.h"
3 3
4 #include "SkPicture.h" 4 #include "SkPicture.h"
5 5
6 namespace DM { 6 namespace DM {
7 7
8 ReplayTask::ReplayTask(const char* suffix, 8 ReplayTask::ReplayTask(const char* suffix,
9 const Task& parent, 9 const Task& parent,
10 skiagm::GM* gm, 10 skiagm::GM* gm,
11 skiagm::GmResultDigest reference, 11 SkBitmap reference)
12 SkBitmap::Config config)
13 : Task(parent) 12 : Task(parent)
14 , fName(underJoin(parent.name().c_str(), suffix)) 13 , fName(underJoin(parent.name().c_str(), suffix))
15 , fGM(gm) 14 , fGM(gm)
16 , fReference(reference) 15 , fReference(reference)
17 , fConfig(config)
18 {} 16 {}
19 17
20 void ReplayTask::draw() { 18 void ReplayTask::draw() {
21 SkPicture picture; 19 SkPicture picture;
22 SkCanvas* canvas = picture.beginRecording(fGM->width(), fGM->height(), 0 /*f lags*/); 20 SkCanvas* canvas = picture.beginRecording(fGM->width(), fGM->height(), 0 /*f lags*/);
23 21
24 canvas->concat(fGM->getInitialTransform()); 22 canvas->concat(fGM->getInitialTransform());
25 fGM->draw(canvas); 23 fGM->draw(canvas);
26 canvas->flush(); 24 canvas->flush();
27 25
28 picture.endRecording(); 26 picture.endRecording();
29 27
30 SkBitmap bitmap; 28 SkBitmap bitmap;
31 bitmap.setConfig(fConfig, fGM->width(), fGM->height()); 29 bitmap.setConfig(fReference.config(), fGM->width(), fGM->height());
32 bitmap.allocPixels(); 30 bitmap.allocPixels();
33 bitmap.eraseColor(0x00000000); 31 bitmap.eraseColor(0x00000000);
34 32
35 SkCanvas replay(bitmap); 33 SkCanvas replay(bitmap);
36 replay.drawPicture(picture); 34 replay.drawPicture(picture);
37 replay.flush(); 35 replay.flush();
38 36
39 const skiagm::GmResultDigest replayDigest(bitmap); 37 const SkAutoLockPixels mine(bitmap), theirs(fReference);
40 if (!replayDigest.equals(fReference)) { 38 if (bitmap.getSize() != fReference.getSize() ||
39 0 != memcmp(bitmap.getPixels(), fReference.getPixels(), bitmap.getSize() )) {
bungeman-skia 2013/10/16 17:22:54 I know it isn't technically in the skia style guid
mtklein 2013/10/16 17:27:47 Done.
41 this->fail(); 40 this->fail();
42 } 41 }
43 } 42 }
44 43
45 bool ReplayTask::shouldSkip() const { 44 bool ReplayTask::shouldSkip() const {
46 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || 45 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag ||
47 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; 46 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag;
48 } 47 }
49 48
50 } // namespace 49 } // namespace
OLDNEW
« no previous file with comments | « dm/DMReplayTask.h ('k') | dm/DMUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698