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