aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text/GrTextUtils.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-10-27 11:30:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-30 15:07:59 +0000
commitf18b1d88aa98f81d2c115a59d887265fea63f876 (patch)
tree8f7052aba9358b6c28d8e22db2b1be326729ec36 /src/gpu/text/GrTextUtils.h
parent228da62fa791e1532826f8e17b945c3d8cbc1300 (diff)
Add GrTextUtils::Target
This abstracts the portion of GrRenderTargetContext that is used by GrAtlasTextContext and opens the door to creating alternative consumers of GrAtlasTextOps. Change-Id: Iaa48f93f4d7d49e231744d44427e9396c5d36fe7 Reviewed-on: https://skia-review.googlesource.com/64760 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/text/GrTextUtils.h')
-rw-r--r--src/gpu/text/GrTextUtils.h52
1 files changed, 36 insertions, 16 deletions
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index bd0a1ad2ea..d8d841f051 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -11,19 +11,18 @@
#include "GrColor.h"
#include "GrColorSpaceInfo.h"
#include "SkColorFilter.h"
-#include "SkGr.h"
#include "SkPaint.h"
#include "SkScalar.h"
#include "SkTLazy.h"
class GrAtlasGlyphCache;
class GrAtlasTextBlob;
+class GrAtlasTextOp;
class GrAtlasTextStrike;
class GrClip;
class GrColorSpaceXform;
class GrContext;
class GrPaint;
-class GrRenderTargetContext;
class GrShaderCaps;
class SkColorSpace;
class SkDrawFilter;
@@ -41,6 +40,32 @@ class SkSurfaceProps;
*/
class GrTextUtils {
public:
+ class Target {
+ public:
+ virtual ~Target() = default;
+
+ int width() const { return fWidth; }
+ int height() const { return fHeight; }
+ const GrColorSpaceInfo& colorSpaceInfo() const { return fColorSpaceInfo; }
+
+ virtual void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) = 0;
+
+ virtual void drawPath(const GrClip&, const SkPath&, const SkPaint&,
+ const SkMatrix& viewMatrix, const SkMatrix* pathMatrix,
+ const SkIRect& clipBounds) = 0;
+ virtual void makeGrPaint(GrMaskFormat, const SkPaint&, const SkMatrix& viewMatrix,
+ GrPaint*) = 0;
+
+ protected:
+ Target(int width, int height, const GrColorSpaceInfo& colorSpaceInfo)
+ : fWidth(width), fHeight(height), fColorSpaceInfo(colorSpaceInfo) {}
+
+ private:
+ int fWidth;
+ int fHeight;
+ const GrColorSpaceInfo& fColorSpaceInfo;
+ };
+
/**
* This is used to wrap a SkPaint and its post-color filter color. It is also used by RunPaint
* (below). This keeps a pointer to the SkPaint it is initialized with and expects it to remain
@@ -61,9 +86,6 @@ public:
const SkPaint& skPaint() const { return *fPaint; }
operator const SkPaint&() const { return this->skPaint(); }
- bool toGrPaint(GrMaskFormat, GrRenderTargetContext*, const SkMatrix& viewMatrix,
- GrPaint*) const;
-
// Just for RunPaint's constructor
const GrColorSpaceInfo* dstColorSpaceInfo() const { return fDstColorSpaceInfo; }
@@ -130,17 +152,15 @@ public:
int scalarsPerPosition, const SkPoint& offset);
// Functions for drawing text as paths
- static void DrawTextAsPath(GrContext*, GrRenderTargetContext*, const GrClip& clip,
- const SkPaint& paint, const SkMatrix& viewMatrix, const char text[],
- size_t byteLength, SkScalar x, SkScalar y,
- const SkIRect& clipBounds);
-
- static void DrawPosTextAsPath(GrContext* context, GrRenderTargetContext* rtc,
- const SkSurfaceProps& props, const GrClip& clip,
- const SkPaint& paint, const SkMatrix& viewMatrix,
- const char text[], size_t byteLength, const SkScalar pos[],
- int scalarsPerPosition, const SkPoint& offset,
- const SkIRect& clipBounds);
+ static void DrawTextAsPath(GrContext*, Target*, const GrClip& clip, const SkPaint& paint,
+ const SkMatrix& viewMatrix, const char text[], size_t byteLength,
+ SkScalar x, SkScalar y, const SkIRect& clipBounds);
+
+ static void DrawPosTextAsPath(GrContext* context, Target*, const SkSurfaceProps& props,
+ const GrClip& clip, const SkPaint& paint,
+ const SkMatrix& viewMatrix, const char text[], size_t byteLength,
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset, const SkIRect& clipBounds);
static bool ShouldDisableLCD(const SkPaint& paint);