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