blob: 0996f655a37a316d58fc741dba7bbd71d94e57e2 [file] [log] [blame]
joshualitt0a42e682015-12-10 13:20:58 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrTextUtils_DEFINED
9#define GrTextUtils_DEFINED
10
joshualitt29677982015-12-11 06:08:59 -080011#include "GrColor.h"
joshualitt0a42e682015-12-10 13:20:58 -080012#include "SkScalar.h"
13
joshualitt29677982015-12-11 06:08:59 -080014class GrAtlasTextBlob;
15class GrBatchFontCache;
16class GrBatchTextStrike;
joshualitt0a42e682015-12-10 13:20:58 -080017class GrClip;
18class GrContext;
19class GrDrawContext;
joshualitt29677982015-12-11 06:08:59 -080020class GrFontScaler;
21class SkGlyph;
joshualitt0a42e682015-12-10 13:20:58 -080022class SkMatrix;
23struct SkIRect;
24class SkPaint;
25struct SkPoint;
joshualitt29677982015-12-11 06:08:59 -080026class SkGlyphCache;
joshualitt0a42e682015-12-10 13:20:58 -080027class SkSurfaceProps;
28
29/*
30 * A class to house a bunch of common text utilities. This class should *ONLY* have static
31 * functions. It is not a namespace only because we wish to friend SkPaint
32 *
33 */
34class GrTextUtils {
35public:
joshualitt29677982015-12-11 06:08:59 -080036 // Functions for appending BMP text to GrAtlasTextBlob
37 static void DrawBmpText(GrAtlasTextBlob*, int runIndex,
joshualitte76b4bb32015-12-28 07:23:58 -080038 GrBatchFontCache*, const SkSurfaceProps&,
39 const SkPaint&,
joshualitt29677982015-12-11 06:08:59 -080040 GrColor, const SkMatrix& viewMatrix,
41 const char text[], size_t byteLength,
42 SkScalar x, SkScalar y);
joshualitt0a42e682015-12-10 13:20:58 -080043
joshualitt29677982015-12-11 06:08:59 -080044 static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex,
joshualitte76b4bb32015-12-28 07:23:58 -080045 GrBatchFontCache*, const SkSurfaceProps&, const SkPaint&,
joshualitt29677982015-12-11 06:08:59 -080046 GrColor, const SkMatrix& viewMatrix,
47 const char text[], size_t byteLength,
48 const SkScalar pos[], int scalarsPerPosition,
49 const SkPoint& offset);
joshualitt0a42e682015-12-10 13:20:58 -080050
joshualitt29677982015-12-11 06:08:59 -080051 // Functions for drawing text as paths
52 static void DrawTextAsPath(GrContext*, GrDrawContext*, const GrClip& clip,
53 const SkPaint& origPaint, const SkMatrix& viewMatrix,
54 const char text[], size_t byteLength, SkScalar x, SkScalar y,
55 const SkIRect& clipBounds);
56
57 static void DrawPosTextAsPath(GrContext* context,
58 GrDrawContext* dc,
59 const SkSurfaceProps& props,
60 const GrClip& clip,
61 const SkPaint& origPaint, const SkMatrix& viewMatrix,
62 const char text[], size_t byteLength,
63 const SkScalar pos[], int scalarsPerPosition,
64 const SkPoint& offset, const SkIRect& clipBounds);
65private:
66 static void BmpAppendGlyph(GrAtlasTextBlob*, int runIndex, GrBatchFontCache*,
67 GrBatchTextStrike**, const SkGlyph&, int left, int top,
68 GrColor color, GrFontScaler*);
joshualitt0a42e682015-12-10 13:20:58 -080069};
70
71#endif