blob: 285b564c9332b2c6a811a91cbcc2c5e0694d162c [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
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.com8d4dc712014-04-18 15:14:25 +00008#include "SkPaintPart.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +00009#include "SkDrawPaint.h"
10#ifdef SK_DUMP_ENABLED
11#include "SkDisplayList.h"
12#include "SkDump.h"
13#endif
14
15SkPaintPart::SkPaintPart() : fPaint(NULL) {
16}
17
18SkDisplayable* SkPaintPart::getParent() const {
19 return fPaint;
20}
21
22bool 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
32bool SkDrawMaskFilter::add() {
33 if (fPaint->maskFilter != (SkDrawMaskFilter*) -1)
34 return true;
35 fPaint->maskFilter = this;
36 fPaint->fOwnsMaskFilter = true;
37 return false;
38}
39
40SkMaskFilter* SkDrawMaskFilter::getMaskFilter() {
41 return NULL;
42}
43
44
45// SkDrawPathEffect
46bool 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.comd6caf2e2011-07-08 14:41:12 +000054 fPaint->add(NULL, this);
reed@android.com8a1c16f2008-12-17 15:59:43 +000055 return false;
56}
57
58SkPathEffect* SkDrawPathEffect::getPathEffect() {
59 return NULL;
60}
61
62
63// SkDrawShader
64SkShader* SkDrawShader::getShader() {
65 return NULL;
66}
67
68
69// Typeface
70#if SK_USE_CONDENSED_INFO == 0
71
72const SkMemberInfo SkDrawTypeface::fInfo[] = {
73 SK_MEMBER(fontName, String),
74 SK_MEMBER(style, FontStyle)
75};
76
77#endif
78
79DEFINE_GET_MEMBER(SkDrawTypeface);
80
81SkDrawTypeface::SkDrawTypeface() : style (SkTypeface::kNormal){
82}
83
84bool 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.com93c7ee32013-03-12 14:36:57 +000093void SkDrawTypeface::dump(SkAnimateMaker*) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000094 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