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

Side by Side Diff: dm/DMSrcSink.h

Issue 922293003: DM: don't leak the null canvas in NullSink. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | dm/DMSrcSink.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 DMSrcSink_DEFINED 1 #ifndef DMSrcSink_DEFINED
2 #define DMSrcSink_DEFINED 2 #define DMSrcSink_DEFINED
3 3
4 #include "DMGpuSupport.h" 4 #include "DMGpuSupport.h"
5 #include "SkBBHFactory.h" 5 #include "SkBBHFactory.h"
6 #include "SkBBoxHierarchy.h" 6 #include "SkBBoxHierarchy.h"
7 #include "SkBitmap.h" 7 #include "SkBitmap.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkGPipe.h" 10 #include "SkGPipe.h"
11 #include "SkNullCanvas.h"
12 #include "SkPicture.h" 11 #include "SkPicture.h"
13 #include "gm.h" 12 #include "gm.h"
14 13
15 namespace DM { 14 namespace DM {
16 15
17 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...). 16 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...).
18 struct ImplicitString : public SkString { 17 struct ImplicitString : public SkString {
19 template <typename T> 18 template <typename T>
20 ImplicitString(const T& s) : SkString(s) {} 19 ImplicitString(const T& s) : SkString(s) {}
21 }; 20 };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 78
80 Error draw(SkCanvas*) const SK_OVERRIDE; 79 Error draw(SkCanvas*) const SK_OVERRIDE;
81 SkISize size() const SK_OVERRIDE; 80 SkISize size() const SK_OVERRIDE;
82 Name name() const SK_OVERRIDE; 81 Name name() const SK_OVERRIDE;
83 private: 82 private:
84 Path fPath; 83 Path fPath;
85 }; 84 };
86 85
87 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 86 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
88 87
88 class NullSink : public Sink {
89 public:
90 NullSink() {}
91
92 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const SK_OVERRI DE;
93 int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; }
94 const char* fileExtension() const SK_OVERRIDE { return ""; }
95 };
96
97
89 class GPUSink : public Sink { 98 class GPUSink : public Sink {
90 public: 99 public:
91 GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfT ext, bool threaded); 100 GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfT ext, bool threaded);
92 101
93 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE; 102 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE;
94 int enclave() const SK_OVERRIDE; 103 int enclave() const SK_OVERRIDE;
95 const char* fileExtension() const SK_OVERRIDE { return "png"; } 104 const char* fileExtension() const SK_OVERRIDE { return "png"; }
96 private: 105 private:
97 GrContextFactory::GLContextType fContextType; 106 GrContextFactory::GLContextType fContextType;
98 GrGLStandard fGpuAPI; 107 GrGLStandard fGpuAPI;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 191
183 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE; 192 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE;
184 int enclave() const SK_OVERRIDE { return fSink->enclave(); } 193 int enclave() const SK_OVERRIDE { return fSink->enclave(); }
185 const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension( ); } 194 const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension( ); }
186 private: 195 private:
187 const int fW, fH; 196 const int fW, fH;
188 SkAutoTDelete<SkBBHFactory> fFactory; 197 SkAutoTDelete<SkBBHFactory> fFactory;
189 SkAutoTDelete<Sink> fSink; 198 SkAutoTDelete<Sink> fSink;
190 }; 199 };
191 200
192 class NullSink : public Sink {
193 public:
194 Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const SK_OVERRI DE {
195 return src.draw(SkCreateNullCanvas());
196 }
197 int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; }
198 const char* fileExtension() const SK_OVERRIDE { return ""; }
199 };
200
201 } // namespace DM 201 } // namespace DM
202 202
203 #endif//DMSrcSink_DEFINED 203 #endif//DMSrcSink_DEFINED
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698