gfx/skia/src/text/SkTextLayout.cpp
author Lucas Rocha <lucasr@mozilla.com>
Sat, 17 Aug 2013 14:23:52 +0100
changeset 143556 fbbc87078c3c5375d4f3edb2fe0219bd6bb5dedc
parent 137322 b3e5868f25401ac2529fec6f3aaeaec6dc9e40b3
permissions -rw-r--r--
Bug 903478 - Add findListViewWithTag() to BaseTest (r=margaret)


/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "SkTextLayout.h"

SK_DEFINE_INST_COUNT(SkTextStyle)

SkTextStyle::SkTextStyle() {
    fPaint.setAntiAlias(true);
}

SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {}

SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {}

SkTextStyle::~SkTextStyle() {}

///////////////////////////////////////////////////////////////////////////////

SkTextLayout::SkTextLayout() {
    fBounds.setEmpty();
    fDefaultStyle = new SkTextStyle;
}

SkTextLayout::~SkTextLayout() {
    fDefaultStyle->unref();
    fLines.deleteAll();
}

void SkTextLayout::setText(const char text[], size_t length) {
    fText.setCount(length);
    memcpy(fText.begin(), text, length);
}

void SkTextLayout::setBounds(const SkRect& bounds) {
    fBounds = bounds;
    // if width changed, inval cache
}

SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) {
    SkRefCnt_SafeAssign(fDefaultStyle, style);
    return style;
}

///////////////////////////////////////////////////////////////////////////////

struct SkTextLayout::GlyphRun {
    GlyphRun();
    ~GlyphRun();

    SkPoint*    fLocs;
    uint16_t*   fGlyphIDs;
    int         fCount;
};

SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {}

SkTextLayout::GlyphRun::~GlyphRun() {
    delete[] fLocs;
    delete[] fGlyphIDs;
}

struct SkTextLayout::Line {
    Line() {}
    ~Line();

    SkScalar                fBaselineY;
    SkTDArray<GlyphRun*>    fRuns;
};

SkTextLayout::Line::~Line() {
    fRuns.deleteAll();
}

void SkTextLayout::draw(SkCanvas* canvas) {
}