| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTextBlob_DEFINED | 8 #ifndef SkTextBlob_DEFINED |
| 9 #define SkTextBlob_DEFINED | 9 #define SkTextBlob_DEFINED |
| 10 | 10 |
| 11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
| 12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 | 14 |
| 15 class SkReadBuffer; | 15 class SkReadBuffer; |
| 16 class SkWriteBuffer; | 16 class SkWriteBuffer; |
| 17 | 17 |
| 18 /** \class SkTextBlob | 18 /** \class SkTextBlob |
| 19 | 19 |
| 20 SkTextBlob combines multiple text runs into an immutable, ref-counted struct
ure. | 20 SkTextBlob combines multiple text runs into an immutable, ref-counted struct
ure. |
| 21 */ | 21 */ |
| 22 class SK_API SkTextBlob : public SkRefCnt { | 22 class SK_API SkTextBlob final : public SkNVRefCnt<SkTextBlob> { |
| 23 public: | 23 public: |
| 24 /** | 24 /** |
| 25 * Returns a conservative blob bounding box. | 25 * Returns a conservative blob bounding box. |
| 26 */ | 26 */ |
| 27 const SkRect& bounds() const { return fBounds; } | 27 const SkRect& bounds() const { return fBounds; } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Return a non-zero, unique value representing the text blob. | 30 * Return a non-zero, unique value representing the text blob. |
| 31 */ | 31 */ |
| 32 uint32_t uniqueID() const { return fUniqueID; } | 32 uint32_t uniqueID() const { return fUniqueID; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 */ | 45 */ |
| 46 static const SkTextBlob* CreateFromBuffer(SkReadBuffer&); | 46 static const SkTextBlob* CreateFromBuffer(SkReadBuffer&); |
| 47 | 47 |
| 48 enum GlyphPositioning { | 48 enum GlyphPositioning { |
| 49 kDefault_Positioning = 0, // Default glyph advances -- zero scalars
per glyph. | 49 kDefault_Positioning = 0, // Default glyph advances -- zero scalars
per glyph. |
| 50 kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar p
er glyph. | 50 kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar p
er glyph. |
| 51 kFull_Positioning = 2 // Point positioning -- two scalars per g
lyph. | 51 kFull_Positioning = 2 // Point positioning -- two scalars per g
lyph. |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 friend class SkNVRefCnt<SkTextBlob>; |
| 55 class RunRecord; | 56 class RunRecord; |
| 56 | 57 |
| 57 SkTextBlob(int runCount, const SkRect& bounds); | 58 SkTextBlob(int runCount, const SkRect& bounds); |
| 58 | 59 |
| 59 virtual ~SkTextBlob(); | 60 ~SkTextBlob(); |
| 60 | 61 |
| 61 // Memory for objects of this class is created with sk_malloc rather than op
erator new and must | 62 // Memory for objects of this class is created with sk_malloc rather than op
erator new and must |
| 62 // be freed with sk_free. | 63 // be freed with sk_free. |
| 63 void operator delete(void* p) { sk_free(p); } | 64 void operator delete(void* p) { sk_free(p); } |
| 64 void* operator new(size_t) { | 65 void* operator new(size_t) { |
| 65 SkFAIL("All blobs are created by placement new."); | 66 SkFAIL("All blobs are created by placement new."); |
| 66 return sk_malloc_throw(0); | 67 return sk_malloc_throw(0); |
| 67 } | 68 } |
| 68 void* operator new(size_t, void* p) { return p; } | 69 void* operator new(size_t, void* p) { return p; } |
| 69 | 70 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 175 |
| 175 SkRect fBounds; | 176 SkRect fBounds; |
| 176 int fRunCount; | 177 int fRunCount; |
| 177 bool fDeferredBounds; | 178 bool fDeferredBounds; |
| 178 size_t fLastRun; // index into fStorage | 179 size_t fLastRun; // index into fStorage |
| 179 | 180 |
| 180 RunBuffer fCurrentRunBuffer; | 181 RunBuffer fCurrentRunBuffer; |
| 181 }; | 182 }; |
| 182 | 183 |
| 183 #endif // SkTextBlob_DEFINED | 184 #endif // SkTextBlob_DEFINED |
| OLD | NEW |