aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/atlastext
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-12-13 10:59:33 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-20 14:00:44 +0000
commitb5086961f335d6757a88ce7507c445485aaba2e6 (patch)
treea635252858428f4f0f04144d532cc4ab96388d95 /include/atlastext
parente1367b4a064737cbcf78f2297fa89e0a032b2060 (diff)
Add matrix stack to SkAtlasTextTarget.
Makes SkAtlasTextRenderer::SDFVertex now has a 3 component position vector. Change-Id: I7ec1a8068fb84388a82e1748d6e9d02820d55abd Reviewed-on: https://skia-review.googlesource.com/84202 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'include/atlastext')
-rw-r--r--include/atlastext/SkAtlasTextRenderer.h6
-rw-r--r--include/atlastext/SkAtlasTextTarget.h34
2 files changed, 37 insertions, 3 deletions
diff --git a/include/atlastext/SkAtlasTextRenderer.h b/include/atlastext/SkAtlasTextRenderer.h
index a78e270edb..f5eb5240c9 100644
--- a/include/atlastext/SkAtlasTextRenderer.h
+++ b/include/atlastext/SkAtlasTextRenderer.h
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkPoint.h"
+#include "SkPoint3.h"
#include "SkRefCnt.h"
#ifndef SkAtlasTextRenderer_DEFINED
@@ -25,8 +25,8 @@ public:
};
struct SDFVertex {
- /** Position in device space (not normalized). */
- SkPoint fPosition;
+ /** Position in device space (not normalized). The third component is w (not z). */
+ SkPoint3 fPosition;
/** Color, same value for all four corners of a glyph quad. */
uint32_t fColor;
/** Texture coordinate (in texel units, not normalized). */
diff --git a/include/atlastext/SkAtlasTextTarget.h b/include/atlastext/SkAtlasTextTarget.h
index ff879617d8..c29f381dc8 100644
--- a/include/atlastext/SkAtlasTextTarget.h
+++ b/include/atlastext/SkAtlasTextTarget.h
@@ -9,11 +9,13 @@
#define SkAtlasTextTarget_DEFINED
#include <memory>
+#include "SkDeque.h"
#include "SkRefCnt.h"
#include "SkScalar.h"
class SkAtlasTextContext;
class SkAtlasTextFont;
+class SkMatrix;
struct SkPoint;
/** Represents a client-created renderable surface and is used to draw text into the surface. */
@@ -46,15 +48,47 @@ public:
SkAtlasTextContext* context() const { return fContext.get(); }
+ /** Saves the current matrix in a stack. Returns the prior depth of the saved matrix stack. */
+ int save();
+ /** Pops the top matrix on the stack if the stack is not empty. */
+ void restore();
+ /**
+ * Pops the matrix stack until the stack depth is count. Does nothing if the depth is already
+ * less than count.
+ */
+ void restoreToCount(int count);
+
+ /** Pre-translates the current CTM. */
+ void translate(SkScalar dx, SkScalar dy);
+ /** Pre-scales the current CTM. */
+ void scale(SkScalar sx, SkScalar sy);
+ /** Pre-rotates the current CTM about the origin. */
+ void rotate(SkScalar degrees);
+ /** Pre-rotates the current CTM about the (px, py). */
+ void rotate(SkScalar degrees, SkScalar px, SkScalar py);
+ /** Pre-skews the current CTM. */
+ void skew(SkScalar sx, SkScalar sy);
+ /** Pre-concats the current CTM. */
+ void concat(const SkMatrix& matrix);
+
protected:
SkAtlasTextTarget(sk_sp<SkAtlasTextContext>, int width, int height, void* handle);
+ const SkMatrix& ctm() const { return *static_cast<const SkMatrix*>(fMatrixStack.back()); }
+
void* const fHandle;
const sk_sp<SkAtlasTextContext> fContext;
const int fWidth;
const int fHeight;
private:
+ SkDeque fMatrixStack;
+ int fSaveCnt;
+
+ SkMatrix* accessCTM() const {
+ return static_cast<SkMatrix*>(const_cast<void*>(fMatrixStack.back()));
+ }
+
SkAtlasTextTarget() = delete;
SkAtlasTextTarget(const SkAtlasTextContext&) = delete;
SkAtlasTextTarget& operator=(const SkAtlasTextContext&) = delete;