epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | |
reed@google.com | 8d4dc71 | 2014-04-18 15:14:25 +0000 | [diff] [blame] | 8 | #include "SkPaintPart.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | #include "SkDrawPaint.h" |
| 10 | #ifdef SK_DUMP_ENABLED |
| 11 | #include "SkDisplayList.h" |
| 12 | #include "SkDump.h" |
| 13 | #endif |
| 14 | |
| 15 | SkPaintPart::SkPaintPart() : fPaint(NULL) { |
| 16 | } |
| 17 | |
| 18 | SkDisplayable* SkPaintPart::getParent() const { |
| 19 | return fPaint; |
| 20 | } |
| 21 | |
| 22 | bool SkPaintPart::setParent(SkDisplayable* parent) { |
| 23 | SkASSERT(parent != NULL); |
| 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 NULL; |
| 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 | } |
tomhudson@google.com | d6caf2e | 2011-07-08 14:41:12 +0000 | [diff] [blame] | 54 | fPaint->add(NULL, this); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | return false; |
| 56 | } |
| 57 | |
| 58 | SkPathEffect* SkDrawPathEffect::getPathEffect() { |
| 59 | return NULL; |
| 60 | } |
| 61 | |
| 62 | |
| 63 | // SkDrawShader |
| 64 | SkShader* SkDrawShader::getShader() { |
| 65 | return NULL; |
| 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 |
sugoi@google.com | 93c7ee3 | 2013-03-12 14:36:57 +0000 | [diff] [blame] | 93 | void SkDrawTypeface::dump(SkAnimateMaker*) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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 |