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

Side by Side Diff: dm/DMWriteTask.h

Issue 502193002: SkData to SkStreamAsset to avoid unneeded copying (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Another Patch Set Created 6 years, 3 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/DMPDFTask.cpp ('k') | dm/DMWriteTask.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 #ifndef DMWriteTask_DEFINED 1 #ifndef DMWriteTask_DEFINED
2 #define DMWriteTask_DEFINED 2 #define DMWriteTask_DEFINED
3 3
4 #include "DMExpectations.h" 4 #include "DMExpectations.h"
5 #include "DMTask.h" 5 #include "DMTask.h"
6 #include "SkBitmap.h" 6 #include "SkBitmap.h"
7 #include "SkString.h" 7 #include "SkString.h"
8 #include "SkTArray.h" 8 #include "SkTArray.h"
9 9
10 10
11 // Writes a bitmap to a file. 11 // Writes a bitmap to a file.
12 12
13 namespace DM { 13 namespace DM {
14 14
15 class WriteTask : public CpuTask { 15 class WriteTask : public CpuTask {
16 16
17 public: 17 public:
18 WriteTask(const Task& parent, // WriteTask must be a child task. 18 WriteTask(const Task& parent, // WriteTask must be a child task.
19 SkBitmap bitmap); // Bitmap to encode to PNG and write to disk. 19 SkBitmap bitmap); // Bitmap to encode to PNG and write to disk.
20 20
21 // Takes ownership of SkStreamAsset
21 WriteTask(const Task& parent, // WriteTask must be a child task. 22 WriteTask(const Task& parent, // WriteTask must be a child task.
22 SkData *data, // Pre-encoded data to write to disk. 23 SkStreamAsset* data, // Pre-encoded data to write to disk.
23 const char* ext); // File extension. 24 const char* ext); // File extension.
24 25
25 virtual void draw() SK_OVERRIDE; 26 virtual void draw() SK_OVERRIDE;
26 virtual bool shouldSkip() const SK_OVERRIDE; 27 virtual bool shouldSkip() const SK_OVERRIDE;
27 virtual SkString name() const SK_OVERRIDE; 28 virtual SkString name() const SK_OVERRIDE;
28 29
29 // Reads image files WriteTask wrote under root and compares them with bitma p. 30 // Reads image files WriteTask wrote under root and compares them with bitma p.
30 class Expectations : public DM::Expectations { 31 class Expectations : public DM::Expectations {
31 public: 32 public:
32 explicit Expectations(const char* root) : fRoot(root) {} 33 explicit Expectations(const char* root) : fRoot(root) {}
33 34
34 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE; 35 bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE;
35 private: 36 private:
36 const char* fRoot; 37 const char* fRoot;
37 }; 38 };
38 39
39 private: 40 private:
40 SkTArray<SkString> fSuffixes; 41 SkTArray<SkString> fSuffixes;
41 const SkString fGmName; 42 const SkString fGmName;
42 const SkBitmap fBitmap; 43 const SkBitmap fBitmap;
43 SkAutoTUnref<SkData> fData; 44 SkAutoTDelete<SkStreamAsset> fData;
44 const char* fExtension; 45 const char* fExtension;
45 46
46 void makeDirOrFail(SkString dir); 47 void makeDirOrFail(SkString dir);
47 }; 48 };
48 49
49 } // namespace DM 50 } // namespace DM
50 51
51 #endif // DMWriteTask_DEFINED 52 #endif // DMWriteTask_DEFINED
OLDNEW
« no previous file with comments | « dm/DMPDFTask.cpp ('k') | dm/DMWriteTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698