• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #include "SkTextLayout.h"
9 
SkTextStyle()10 SkTextStyle::SkTextStyle() {
11     fPaint.setAntiAlias(true);
12 }
13 
SkTextStyle(const SkTextStyle & src)14 SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {}
15 
SkTextStyle(const SkPaint & paint)16 SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {}
17 
~SkTextStyle()18 SkTextStyle::~SkTextStyle() {}
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 
SkTextLayout()22 SkTextLayout::SkTextLayout() {
23     fBounds.setEmpty();
24     fDefaultStyle = new SkTextStyle;
25 }
26 
~SkTextLayout()27 SkTextLayout::~SkTextLayout() {
28     fDefaultStyle->unref();
29     fLines.deleteAll();
30 }
31 
setText(const char text[],size_t length)32 void SkTextLayout::setText(const char text[], size_t length) {
33     fText.setCount(length);
34     memcpy(fText.begin(), text, length);
35 }
36 
setBounds(const SkRect & bounds)37 void SkTextLayout::setBounds(const SkRect& bounds) {
38     fBounds = bounds;
39     // if width changed, inval cache
40 }
41 
setDefaultStyle(SkTextStyle * style)42 SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) {
43     SkRefCnt_SafeAssign(fDefaultStyle, style);
44     return style;
45 }
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 
49 struct SkTextLayout::GlyphRun {
50     GlyphRun();
51     ~GlyphRun();
52 
53     SkPoint*    fLocs;
54     uint16_t*   fGlyphIDs;
55     int         fCount;
56 };
57 
GlyphRun()58 SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {}
59 
~GlyphRun()60 SkTextLayout::GlyphRun::~GlyphRun() {
61     delete[] fLocs;
62     delete[] fGlyphIDs;
63 }
64 
65 struct SkTextLayout::Line {
LineSkTextLayout::Line66     Line() {}
67     ~Line();
68 
69     SkScalar                fBaselineY;
70     SkTDArray<GlyphRun*>    fRuns;
71 };
72 
~Line()73 SkTextLayout::Line::~Line() {
74     fRuns.deleteAll();
75 }
76 
draw(SkCanvas * canvas)77 void SkTextLayout::draw(SkCanvas* canvas) {
78 }
79 
80