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

Side by Side Diff: dm/DMSerializeTask.cpp

Issue 612603002: Don't test the old picture backend anymore. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « dm/DMSerializeTask.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 "DMSerializeTask.h" 1 #include "DMSerializeTask.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 "SkPicture.h" 6 #include "SkPicture.h"
7 #include "SkPixelRef.h" 7 #include "SkPixelRef.h"
8 8
9 DEFINE_bool(serialize, true, "If true, run picture serialization tests via S kPictureData."); 9 DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPic tureData.");
10 DEFINE_bool(serialize_skr, true, "If true, run picture serialization tests via S kRecord.");
11
12 static const char* kSuffixes[] = { "serialize", "serialize-skr" };
13 static const bool* kEnabled[] = { &FLAGS_serialize, &FLAGS_serialize_skr };
14 10
15 namespace DM { 11 namespace DM {
16 12
17 SerializeTask::SerializeTask(const Task& parent, 13 SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap refere nce)
18 skiagm::GM* gm,
19 SkBitmap reference,
20 SerializeTask::Mode mode)
21 : CpuTask(parent) 14 : CpuTask(parent)
22 , fMode(mode) 15 , fName(UnderJoin(parent.name().c_str(), "serialize"))
23 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
24 , fGM(gm) 16 , fGM(gm)
25 , fReference(reference) 17 , fReference(reference)
26 {} 18 {}
27 19
28 void SerializeTask::draw() { 20 void SerializeTask::draw() {
29 SkAutoTUnref<SkPicture> recorded( 21 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/));
30 RecordPicture(fGM.get(), NULL/*no BBH*/, kSkRecord_Mode == fMode));
31 22
32 SkDynamicMemoryWStream wStream; 23 SkDynamicMemoryWStream wStream;
33 recorded->serialize(&wStream, NULL); 24 recorded->serialize(&wStream, NULL);
34 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream()); 25 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
35 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream)); 26 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
36 27
37 SkBitmap bitmap; 28 SkBitmap bitmap;
38 AllocatePixels(fReference, &bitmap); 29 AllocatePixels(fReference, &bitmap);
39 DrawPicture(*reconstructed, &bitmap); 30 DrawPicture(*reconstructed, &bitmap);
40 if (!BitmapsEqual(bitmap, fReference)) { 31 if (!BitmapsEqual(bitmap, fReference)) {
41 this->fail(); 32 this->fail();
42 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); 33 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
43 } 34 }
44 } 35 }
45 36
46 bool SerializeTask::shouldSkip() const { 37 bool SerializeTask::shouldSkip() const {
47 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 38 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
48 return true; 39 return true;
49 } 40 }
50 return !*kEnabled[fMode]; 41 return !FLAGS_serialize;
51 } 42 }
52 43
53 } // namespace DM 44 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSerializeTask.h ('k') | dm/DMUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698