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

Unified Diff: src/core/SkDeviceLooper.h

Issue 23618005: fix state machine so we know simple only loops once, but we can call maprect in debug mode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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
Index: src/core/SkDeviceLooper.h
diff --git a/src/core/SkDeviceLooper.h b/src/core/SkDeviceLooper.h
new file mode 100644
index 0000000000000000000000000000000000000000..8acde979e6e21f32cc34b2b021df9b3c99947a4a
--- /dev/null
+++ b/src/core/SkDeviceLooper.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDeviceLooper_DEFINED
+#define SkDeviceLooper_DEFINED
+
+#include "SkBitmap.h"
+#include "SkMatrix.h"
+#include "SkRasterClip.h"
+
+/**
+ * Helper class to manage "tiling" are large coordinate space into managable
tomhudson 2013/08/28 14:27:50 Nit: are?
reed1 2013/08/28 14:38:33 Done.
+ * chunks, where managable means areas that are <= some max critical coordinate
+ * size.
+ *
+ * The constructor takes an antialiasing bool, which affects what this maximum
+ * allowable size is: If we're drawing BW, then we need coordinates to stay
+ * safely within fixed-point range (we use +- 16K, to give ourselves room to
+ * add/subtract two fixed values and still be in range. If we're drawing AA,
+ * then we reduce that size by the amount that the supersampler scan converter
+ * needs (at the moment, that is 4X, so the effect "safe" range is +- 4K).
tomhudson 2013/08/28 14:27:50 Nit: effect -> effective Or just drop that word, a
reed1 2013/08/28 14:38:33 Done.
+ *
+ * For performance reasons, the class first checks to see if any help is needed
+ * at all, and if not (i.e. the specified bounds and base bitmap area already
+ * in the safe-zone, then the class does nothing (effectively).
+ */
+class SkDeviceLooper {
+public:
+ SkDeviceLooper(const SkBitmap& base, const SkRasterClip&,
+ const SkIRect& bounds, bool aa);
+ ~SkDeviceLooper();
+
+ const SkBitmap& getBitmap() const {
+ SkASSERT(kDone_State != fState);
+ return *fCurrBitmap;
+ }
+
+ const SkRasterClip& getRC() const {
+ SkASSERT(kDone_State != fState);
+ return *fCurrRC;
+ }
+
+ void mapRect(SkRect* dst, const SkRect& src) const;
+ void mapMatrix(SkMatrix* dst, const SkMatrix& src) const;
+
+ bool next();
tomhudson 2013/08/28 14:27:50 Even after reading the code I don't know what the
reed1 2013/08/28 14:38:33 Same as all of skia's interators that just use a n
+
+private:
+ const SkBitmap& fBaseBitmap;
+ const SkRasterClip& fBaseRC;
+
+ enum State {
+ kDone_State, // iteration is complete, getters will assert
+ kPreSimple_State, // no translate/clip mods needed
+ kPostSimple_State,
+ kComplex_State
+ };
+
+ // storage for our tiled versions. Perhaps could use SkTLazy
+ SkBitmap fSubsetBitmap;
+ SkRasterClip fSubsetRC;
+
+ const SkBitmap* fCurrBitmap;
+ const SkRasterClip* fCurrRC;
+ SkIRect fClippedBounds;
+ SkIPoint fCurrOffset;
+ int fDelta;
+ State fState;
+
+ enum Delta {
+ kBW_Delta = 1 << 14, // 16K, gives room to spare for fixedpoint
+ kAA_Delta = kBW_Delta >> 2 // supersample 4x
+ };
+
+ bool fitsInDelta(const SkIRect& r) const {
+ return r.right() < fDelta && r.bottom() < fDelta;
+ }
+
+ bool computeCurrBitmapAndClip();
+};
+
+#endif
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkDeviceLooper.cpp » ('j') | src/core/SkDeviceLooper.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698