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 10SkTextStyle::SkTextStyle() { 11 fPaint.setAntiAlias(true); 12} 13 14SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {} 15 16SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {} 17 18SkTextStyle::~SkTextStyle() {} 19 20/////////////////////////////////////////////////////////////////////////////// 21 22SkTextLayout::SkTextLayout() { 23 fBounds.setEmpty(); 24 fDefaultStyle = new SkTextStyle; 25} 26 27SkTextLayout::~SkTextLayout() { 28 fDefaultStyle->unref(); 29 fLines.deleteAll(); 30} 31 32void SkTextLayout::setText(const char text[], size_t length) { 33 fText.setCount(length); 34 memcpy(fText.begin(), text, length); 35} 36 37void SkTextLayout::setBounds(const SkRect& bounds) { 38 fBounds = bounds; 39 // if width changed, inval cache 40} 41 42SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) { 43 SkRefCnt_SafeAssign(fDefaultStyle, style); 44 return style; 45} 46 47/////////////////////////////////////////////////////////////////////////////// 48 49struct SkTextLayout::GlyphRun { 50 GlyphRun(); 51 ~GlyphRun(); 52 53 SkPoint* fLocs; 54 uint16_t* fGlyphIDs; 55 int fCount; 56}; 57 58SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {} 59 60SkTextLayout::GlyphRun::~GlyphRun() { 61 delete[] fLocs; 62 delete[] fGlyphIDs; 63} 64 65struct SkTextLayout::Line { 66 Line() {} 67 ~Line(); 68 69 SkScalar fBaselineY; 70 SkTDArray<GlyphRun*> fRuns; 71}; 72 73SkTextLayout::Line::~Line() { 74 fRuns.deleteAll(); 75} 76 77void SkTextLayout::draw(SkCanvas* canvas) { 78} 79 80