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

Side by Side Diff: dm/DMSerializeTask.cpp

Issue 783393004: Revert of Replace EncodeBitmap with an interface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « no previous file | gm/gmmain.cpp » ('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 SkPic tureData."); 9 DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPic tureData.");
10 10
11 namespace DM { 11 namespace DM {
12 12
13 SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap refere nce) 13 SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap refere nce)
14 : CpuTask(parent) 14 : CpuTask(parent)
15 , fName(UnderJoin(parent.name().c_str(), "serialize")) 15 , fName(UnderJoin(parent.name().c_str(), "serialize"))
16 , fGM(gm) 16 , fGM(gm)
17 , fReference(reference) 17 , fReference(reference)
18 {} 18 {}
19 19
20 void SerializeTask::draw() { 20 void SerializeTask::draw() {
21 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/)); 21 SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/));
22 22
23 SkDynamicMemoryWStream wStream; 23 SkDynamicMemoryWStream wStream;
24 recorded->serialize(&wStream); 24 recorded->serialize(&wStream, NULL);
25 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream()); 25 SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
26 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream)); 26 SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
27 27
28 SkBitmap bitmap; 28 SkBitmap bitmap;
29 AllocatePixels(fReference, &bitmap); 29 AllocatePixels(fReference, &bitmap);
30 DrawPicture(*reconstructed, &bitmap); 30 DrawPicture(*reconstructed, &bitmap);
31 if (!BitmapsEqual(bitmap, fReference)) { 31 if (!BitmapsEqual(bitmap, fReference)) {
32 this->fail(); 32 this->fail();
33 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap))); 33 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
34 } 34 }
35 } 35 }
36 36
37 bool SerializeTask::shouldSkip() const { 37 bool SerializeTask::shouldSkip() const {
38 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { 38 if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
39 return true; 39 return true;
40 } 40 }
41 return !FLAGS_serialize; 41 return !FLAGS_serialize;
42 } 42 }
43 43
44 } // namespace DM 44 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698