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

Side by Side Diff: dm/DMSerializeTask.cpp

Issue 788243008: Sketch DM refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better failure messages, disable a few things temporarily to try to go green Created 5 years, 11 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/DMSrcSink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "DMSerializeTask.h"
2 #include "DMUtil.h"
3 #include "DMWriteTask.h"
4
5 #include "SkCommandLineFlags.h"
6 #include "SkPicture.h"
7 #include "SkPixelRef.h"
8
9 DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPic tureData.");
10
11 namespace DM {
12
13 SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap refere nce)
14 : CpuTask(parent)
15 , fName(UnderJoin(parent.name().c_str(), "serialize"))
16 , fGM(gm)
17 , fReference(reference)
18 {}
19
20 void SerializeTask::draw() {
21 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/));
22
23 SkDynamicMemoryWStream wStream;
24 recorded->serialize(&wStream);
25 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
26 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
27
28 SkBitmap bitmap;
29 AllocatePixels(fReference, &bitmap);
30 DrawPicture(*reconstructed, &bitmap);
31 if (!BitmapsEqual(bitmap, fReference)) {
32 this->fail();
33 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
34 }
35 }
36
37 bool SerializeTask::shouldSkip() const {
38 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
39 return true;
40 }
41 return !FLAGS_serialize;
42 }
43
44 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSerializeTask.h ('k') | dm/DMSrcSink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698