1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/text/SkTextLayout.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 +#include "SkTextLayout.h" 1.12 + 1.13 +SkTextStyle::SkTextStyle() { 1.14 + fPaint.setAntiAlias(true); 1.15 +} 1.16 + 1.17 +SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {} 1.18 + 1.19 +SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {} 1.20 + 1.21 +SkTextStyle::~SkTextStyle() {} 1.22 + 1.23 +/////////////////////////////////////////////////////////////////////////////// 1.24 + 1.25 +SkTextLayout::SkTextLayout() { 1.26 + fBounds.setEmpty(); 1.27 + fDefaultStyle = new SkTextStyle; 1.28 +} 1.29 + 1.30 +SkTextLayout::~SkTextLayout() { 1.31 + fDefaultStyle->unref(); 1.32 + fLines.deleteAll(); 1.33 +} 1.34 + 1.35 +void SkTextLayout::setText(const char text[], size_t length) { 1.36 + fText.setCount(length); 1.37 + memcpy(fText.begin(), text, length); 1.38 +} 1.39 + 1.40 +void SkTextLayout::setBounds(const SkRect& bounds) { 1.41 + fBounds = bounds; 1.42 + // if width changed, inval cache 1.43 +} 1.44 + 1.45 +SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) { 1.46 + SkRefCnt_SafeAssign(fDefaultStyle, style); 1.47 + return style; 1.48 +} 1.49 + 1.50 +/////////////////////////////////////////////////////////////////////////////// 1.51 + 1.52 +struct SkTextLayout::GlyphRun { 1.53 + GlyphRun(); 1.54 + ~GlyphRun(); 1.55 + 1.56 + SkPoint* fLocs; 1.57 + uint16_t* fGlyphIDs; 1.58 + int fCount; 1.59 +}; 1.60 + 1.61 +SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {} 1.62 + 1.63 +SkTextLayout::GlyphRun::~GlyphRun() { 1.64 + delete[] fLocs; 1.65 + delete[] fGlyphIDs; 1.66 +} 1.67 + 1.68 +struct SkTextLayout::Line { 1.69 + Line() {} 1.70 + ~Line(); 1.71 + 1.72 + SkScalar fBaselineY; 1.73 + SkTDArray<GlyphRun*> fRuns; 1.74 +}; 1.75 + 1.76 +SkTextLayout::Line::~Line() { 1.77 + fRuns.deleteAll(); 1.78 +} 1.79 + 1.80 +void SkTextLayout::draw(SkCanvas* canvas) { 1.81 +}