aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-02-13 15:11:10 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-13 15:11:10 -0800
commitad66f9b15fd44468b5f013534ee333dc68d6bed6 (patch)
tree37bfc6995b4b27b4ed6e05fd784add645f25f6a6 /dm
parent694b0d115d5efcd663c422d316d2cf3abaa1d354 (diff)
DM: don't leak the null canvas in NullSink.
Also make NullSink a real boy: declared among the other Sinks, impl in .cpp. BUG=skia: Review URL: https://codereview.chromium.org/922293003
Diffstat (limited to 'dm')
-rw-r--r--dm/DMSrcSink.cpp8
-rw-r--r--dm/DMSrcSink.h20
2 files changed, 18 insertions, 10 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index b0df70b124..4e3668f15e 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -3,6 +3,7 @@
#include "SkCommonFlags.h"
#include "SkDocument.h"
#include "SkMultiPictureDraw.h"
+#include "SkNullCanvas.h"
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
@@ -132,6 +133,13 @@ Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const {
+ SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas());
+ return src.draw(canvas);
+}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?");
GPUSink::GPUSink(GrContextFactory::GLContextType ct,
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 48c572b1a7..4c15c92cb6 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -8,7 +8,6 @@
#include "SkCanvas.h"
#include "SkData.h"
#include "SkGPipe.h"
-#include "SkNullCanvas.h"
#include "SkPicture.h"
#include "gm.h"
@@ -86,6 +85,16 @@ private:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+class NullSink : public Sink {
+public:
+ NullSink() {}
+
+ Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE;
+ int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; }
+ const char* fileExtension() const SK_OVERRIDE { return ""; }
+};
+
+
class GPUSink : public Sink {
public:
GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfText, bool threaded);
@@ -189,15 +198,6 @@ private:
SkAutoTDelete<Sink> fSink;
};
-class NullSink : public Sink {
-public:
- Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE {
- return src.draw(SkCreateNullCanvas());
- }
- int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; }
- const char* fileExtension() const SK_OVERRIDE { return ""; }
-};
-
} // namespace DM
#endif//DMSrcSink_DEFINED