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

Unified Diff: include/effects/SkLayerDrawLooper.h

Issue 1362253002: Simplify SkLayerDrawLooper Base URL: https://chromium.googlesource.com/skia.git@flat
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkLayerDrawLooper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/effects/SkLayerDrawLooper.h
diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h
index 76172dfd4b1dfcfb45296bac51a36dcff101d344..8918f83a9964f4fd1b95156843fda6744a979b2f 100644
--- a/include/effects/SkLayerDrawLooper.h
+++ b/include/effects/SkLayerDrawLooper.h
@@ -9,10 +9,13 @@
#define SkLayerDrawLooper_DEFINED
#include "SkDrawLooper.h"
-#include "SkPaint.h"
-#include "SkPoint.h"
#include "SkXfermode.h"
+#include <stddef.h>
+#include <vector>
mtklein 2015/09/25 11:47:21 We don't use std::vector in Skia (yet?) but SkTArr
mdempsky 2015/09/25 16:40:17 Hm, right. Somehow I thought I saw STL usage else
+
+class SkPaint;
+
class SK_API SkLayerDrawLooper : public SkDrawLooper {
public:
virtual ~SkLayerDrawLooper();
@@ -88,13 +91,8 @@ protected:
void flatten(SkWriteBuffer&) const override;
private:
- struct Rec {
- Rec* fNext;
- SkPaint fPaint;
- LayerInfo fInfo;
- };
- Rec* fRecs;
- int fCount;
+ struct Rec;
+ std::vector<Rec> fRecs;
// state-machine during the init/next cycle
class LayerDrawLooperContext : public SkDrawLooper::Context {
@@ -105,7 +103,8 @@ private:
bool next(SkCanvas*, SkPaint* paint) override;
private:
- Rec* fCurrRec;
+ std::vector<Rec>::const_iterator fCurr;
+ const std::vector<Rec>::const_iterator fEnd;
static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&);
};
@@ -119,35 +118,35 @@ public:
~Builder();
/**
- * Call for each layer you want to add (from top to bottom).
+ * Requests that the builder reserve space for at least n layers.
+ */
+ void reserve(size_t n);
+
+ /**
+ * Call for each layer you want to add (from bottom to top).
* This returns a paint you can modify, but that ptr is only valid until
- * the next call made to addLayer().
+ * the next call made to addLayerOnTop().
*/
- SkPaint* addLayer(const LayerInfo&);
+ SkPaint* addLayerOnTop(const LayerInfo&);
mtklein 2015/09/25 11:47:21 Can we keep the API oriented top to bottom while k
mdempsky 2015/09/25 16:40:17 Yeah that's possible too if you think that's bette
/**
* This layer will draw with the original paint, at the specified offset
*/
- void addLayer(SkScalar dx, SkScalar dy);
+ void addLayerOnTop(SkScalar dx, SkScalar dy);
/**
* This layer will with the original paint and no offset.
*/
- void addLayer() { this->addLayer(0, 0); }
-
- /// Similar to addLayer, but adds a layer to the top.
- SkPaint* addLayerOnTop(const LayerInfo&);
+ void addLayerOnTop() { this->addLayerOnTop(0, 0); }
/**
- * Pass list of layers on to newly built looper and return it. This will
- * also reset the builder, so it can be used to build another looper.
- */
+ * Pass list of layers on to newly built looper and return it. This will
+ * also reset the builder, so it can be used to build another looper.
+ */
SkLayerDrawLooper* detachLooper();
private:
- Rec* fRecs;
- Rec* fTopRec;
- int fCount;
+ std::vector<Rec> fRecs;
};
};
« no previous file with comments | « no previous file | src/effects/SkLayerDrawLooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698