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

Side by Side Diff: dm/DMSerializeTask.cpp

Issue 345553003: Support serialization in SkRecord-backed SkPictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: robert Created 6 years, 5 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."); 9 DEFINE_bool(serialize, true, "If true, run picture serialization tests.");
10 DECLARE_bool(skr); // in DMReplayTask.cpp
11
12 static const char* kSuffixes[] = { "serialize", "serialize_skr" };
13 static const bool* kEnabled[] = { &FLAGS_serialize, &FLAGS_skr };
10 14
11 namespace DM { 15 namespace DM {
12 16
13 SerializeTask::SerializeTask(const Task& parent, 17 SerializeTask::SerializeTask(const Task& parent,
14 skiagm::GM* gm, 18 skiagm::GM* gm,
15 SkBitmap reference) 19 SkBitmap reference,
20 SerializeTask::Mode mode)
16 : CpuTask(parent) 21 : CpuTask(parent)
17 , fName(UnderJoin(parent.name().c_str(), "serialize")) 22 , fMode(mode)
23 , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
18 , fGM(gm) 24 , fGM(gm)
19 , fReference(reference) 25 , fReference(reference)
20 {} 26 {}
21 27
22 void SerializeTask::draw() { 28 void SerializeTask::draw() {
23 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get())); 29 SkAutoTUnref<SkPicture> recorded(
30 RecordPicture(fGM.get(), NULL/*no BBH*/, kSkRecord_Mode == fMode));
24 31
25 SkDynamicMemoryWStream wStream; 32 SkDynamicMemoryWStream wStream;
26 recorded->serialize(&wStream, NULL); 33 recorded->serialize(&wStream, NULL);
27 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream()); 34 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
28 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream)); 35 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
29 36
30 SkBitmap bitmap; 37 SkBitmap bitmap;
31 AllocatePixels(fReference, &bitmap); 38 AllocatePixels(fReference, &bitmap);
32 DrawPicture(reconstructed, &bitmap); 39 DrawPicture(*reconstructed, &bitmap);
33 if (!BitmapsEqual(bitmap, fReference)) { 40 if (!BitmapsEqual(bitmap, fReference)) {
34 this->fail(); 41 this->fail();
35 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); 42 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
36 } 43 }
37 } 44 }
38 45
39 bool SerializeTask::shouldSkip() const { 46 bool SerializeTask::shouldSkip() const {
40 return !FLAGS_serialize || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; 47 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
48 return true;
49 }
50 return !*kEnabled[fMode];
41 } 51 }
42 52
43 } // namespace DM 53 } // 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