gfx/skia/trunk/src/text/SkTextLayout.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial