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

Unified Diff: tests/QuickRejectTest.cpp

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments 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
« no previous file with comments | « 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..ef145525e910f515556fd98541d3ada4d7bda1fd 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,20 +15,12 @@
*/
class TestLooper : public SkDrawLooper {
public:
- bool fOnce;
- virtual void init(SkCanvas*) SK_OVERRIDE {
- fOnce = true;
+ virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE {
+ return SkNEW_PLACEMENT(storage, TestDrawLooperContext);
}
- virtual bool next(SkCanvas* canvas, SkPaint*) SK_OVERRIDE {
- if (fOnce) {
- fOnce = false;
- canvas->translate(SkIntToScalar(10), 0);
- return true;
- }
- return false;
- }
+ virtual size_t contextSize() const SK_OVERRIDE { return sizeof(TestDrawLooperContext); }
#ifdef SK_DEVELOPER
virtual void toString(SkString* str) const SK_OVERRIDE {
@@ -35,6 +28,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()
};
« no previous file with comments | « tests/LayerDrawLooperTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698