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