Home | History | Annotate | Download | only in animator
      1 
      2 /*
      3  * Copyright 2006 The Android Open Source Project
      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 
      9 
     10 #include "SkPaintParts.h"
     11 #include "SkDrawPaint.h"
     12 #ifdef SK_DUMP_ENABLED
     13 #include "SkDisplayList.h"
     14 #include "SkDump.h"
     15 #endif
     16 
     17 SkPaintPart::SkPaintPart() : fPaint(NULL) {
     18 }
     19 
     20 SkDisplayable* SkPaintPart::getParent() const {
     21     return fPaint;
     22 }
     23 
     24 bool SkPaintPart::setParent(SkDisplayable* parent) {
     25     SkASSERT(parent != NULL);
     26     if (parent->isPaint() == false)
     27         return true;
     28     fPaint = (SkDrawPaint*) parent;
     29     return false;
     30 }
     31 
     32 
     33 // SkDrawMaskFilter
     34 bool SkDrawMaskFilter::add() {
     35     if (fPaint->maskFilter != (SkDrawMaskFilter*) -1)
     36         return true;
     37     fPaint->maskFilter = this;
     38     fPaint->fOwnsMaskFilter = true;
     39     return false;
     40 }
     41 
     42 SkMaskFilter* SkDrawMaskFilter::getMaskFilter() {
     43     return NULL;
     44 }
     45 
     46 
     47 // SkDrawPathEffect
     48 bool SkDrawPathEffect::add() {
     49     if (fPaint->isPaint()) {
     50         if (fPaint->pathEffect != (SkDrawPathEffect*) -1)
     51             return true;
     52         fPaint->pathEffect = this;
     53         fPaint->fOwnsPathEffect = true;
     54         return false;
     55     }
     56     fPaint->add(NULL, this);
     57     return false;
     58 }
     59 
     60 SkPathEffect* SkDrawPathEffect::getPathEffect() {
     61     return NULL;
     62 }
     63 
     64 
     65 // SkDrawShader
     66 SkShader* SkDrawShader::getShader() {
     67     return NULL;
     68 }
     69 
     70 
     71 // Typeface
     72 #if SK_USE_CONDENSED_INFO == 0
     73 
     74 const SkMemberInfo SkDrawTypeface::fInfo[] = {
     75     SK_MEMBER(fontName, String),
     76     SK_MEMBER(style, FontStyle)
     77 };
     78 
     79 #endif
     80 
     81 DEFINE_GET_MEMBER(SkDrawTypeface);
     82 
     83 SkDrawTypeface::SkDrawTypeface() : style (SkTypeface::kNormal){
     84 }
     85 
     86 bool SkDrawTypeface::add() {
     87     if (fPaint->typeface != (SkDrawTypeface*) -1)
     88         return true;
     89     fPaint->typeface = this;
     90     fPaint->fOwnsTypeface = true;
     91     return false;
     92 }
     93 
     94 #ifdef SK_DUMP_ENABLED
     95 void SkDrawTypeface::dump(SkAnimateMaker*) {
     96     SkDebugf("%*s<typeface fontName=\"%s\" ", SkDisplayList::fIndent, "", fontName.c_str());
     97     SkString string;
     98     SkDump::GetEnumString(SkType_FontStyle, style, &string);
     99     SkDebugf("style=\"%s\" />\n", string.c_str());
    100 }
    101 #endif
    102