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

Unified Diff: tests/QuickRejectTest.cpp

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use SkSmallAllocator Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« src/core/SkCanvas.cpp ('K') | « tests/LayerDrawLooperTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/QuickRejectTest.cpp
diff --git a/tests/QuickRejectTest.cpp b/tests/QuickRejectTest.cpp
index 2d367389bb81f1e82d0c5cfcd951914270540e63..b1f4215dac12771a0d817480ea212668da1fae69 100644
--- a/tests/QuickRejectTest.cpp
+++ b/tests/QuickRejectTest.cpp
@@ -7,6 +7,7 @@
#include "SkCanvas.h"
#include "SkDrawLooper.h"
+#include "SkTypes.h"
#include "Test.h"
/*
@@ -14,19 +15,12 @@
*/
class TestLooper : public SkDrawLooper {
public:
- bool fOnce;
- virtual void init(SkCanvas*) SK_OVERRIDE {
- fOnce = true;
- }
-
- virtual bool next(SkCanvas* canvas, SkPaint*) SK_OVERRIDE {
- if (fOnce) {
- fOnce = false;
- canvas->translate(SkIntToScalar(10), 0);
- return true;
- }
- return false;
+ virtual SkDrawLooper::Context* init(SkCanvas*, SkDrawLooper::ContextAllocator* allocator) const
+ SK_OVERRIDE {
+ int tp=sizeof(TestDrawLooperContext);
scroggo 2014/03/10 19:41:32 Shouldn't the return value of sizeof be a size_t?
+ if (tp < 0) return NULL;
scroggo 2014/03/10 19:41:32 I don't think this should ever happen.
Dominik Grewe 2014/03/10 21:54:07 Sorry, please ignore those two lines. I just added
+ return allocator->createT<TestDrawLooperContext>();
}
#ifdef SK_DEVELOPER
@@ -35,6 +29,24 @@ public:
}
#endif
+private:
+ class TestDrawLooperContext : public SkDrawLooper::Context {
+ public:
+ TestDrawLooperContext() : fOnce(true) {}
+ virtual ~TestDrawLooperContext() {}
+
+ virtual bool next(SkCanvas* canvas, SkPaint*) SK_OVERRIDE {
+ if (fOnce) {
+ fOnce = false;
+ canvas->translate(SkIntToScalar(10), 0);
+ return true;
+ }
+ return false;
+ }
+ private:
+ bool fOnce;
+ };
+
SK_DECLARE_UNFLATTENABLE_OBJECT()
};
« src/core/SkCanvas.cpp ('K') | « tests/LayerDrawLooperTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698