reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrTextContext_DEFINED |
| 9 | #define GrTextContext_DEFINED |
| 10 | |
| 11 | #include "GrGlyph.h" |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 12 | #include "GrPaint.h" |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 13 | #include "SkDeviceProperties.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 14 | |
commit-bot@chromium.org | cc40f06 | 2014-01-24 14:38:27 +0000 | [diff] [blame] | 15 | #include "SkPostConfig.h" |
| 16 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | class GrContext; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 18 | class GrDrawTarget; |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 19 | class GrFontScaler; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 21 | /* |
| 22 | * This class wraps the state for a single text render |
| 23 | */ |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 24 | class GrTextContext { |
bsalomon@google.com | f4a9c82 | 2012-03-16 14:02:46 +0000 | [diff] [blame] | 25 | public: |
commit-bot@chromium.org | cc40f06 | 2014-01-24 14:38:27 +0000 | [diff] [blame] | 26 | virtual ~GrTextContext() {} |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame^] | 27 | |
| 28 | virtual bool canDraw(const SkPaint& paint) = 0; |
| 29 | |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 30 | virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 31 | SkScalar x, SkScalar y) = 0; |
| 32 | virtual void drawPosText(const GrPaint&, const SkPaint&, |
| 33 | const char text[], size_t byteLength, |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 34 | const SkScalar pos[], int scalarsPerPosition, |
| 35 | const SkPoint& offset) = 0; |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 36 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 37 | protected: |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 38 | GrContext* fContext; |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 39 | SkDeviceProperties fDeviceProperties; |
| 40 | |
| 41 | GrDrawTarget* fDrawTarget; |
| 42 | SkIRect fClipRect; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 43 | GrPaint fPaint; |
| 44 | SkPaint fSkPaint; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame^] | 45 | |
| 46 | GrTextContext(GrContext*, const SkDeviceProperties&); |
| 47 | |
| 48 | void init(const GrPaint&, const SkPaint&); |
| 49 | void finish() { fDrawTarget = NULL; } |
| 50 | |
| 51 | static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
| 52 | static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| 53 | const char text[], size_t byteLength, SkVector* stopVector); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #endif |