3 * Copyright 2006 The Android Open Source Project
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #include "SkDrawShader.h"
11 #include "SkDrawBitmap.h"
12 #include "SkDrawMatrix.h"
13 #include "SkDrawPaint.h"
14 #include "SkTemplates.h"
16 #if SK_USE_CONDENSED_INFO == 0
18 const SkMemberInfo SkDrawShader::fInfo[] = {
19 SK_MEMBER(matrix, Matrix),
20 SK_MEMBER(tileMode, TileMode)
25 DEFINE_GET_MEMBER(SkDrawShader);
27 SkDrawShader::SkDrawShader() : matrix(NULL),
28 tileMode(SkShader::kClamp_TileMode) {
31 bool SkDrawShader::add() {
32 if (fPaint->shader != (SkDrawShader*) -1)
34 fPaint->shader = this;
35 fPaint->fOwnsShader = true;
39 SkMatrix* SkDrawShader::getMatrix() {
40 return matrix ? &matrix->getMatrix() : NULL;
43 #if SK_USE_CONDENSED_INFO == 0
45 const SkMemberInfo SkDrawBitmapShader::fInfo[] = {
47 SK_MEMBER(filterBitmap, Boolean),
48 SK_MEMBER(image, BaseBitmap)
53 DEFINE_GET_MEMBER(SkDrawBitmapShader);
55 SkDrawBitmapShader::SkDrawBitmapShader() : filterBitmap(-1), image(NULL) {}
57 bool SkDrawBitmapShader::add() {
58 if (fPaint->shader != (SkDrawShader*) -1)
60 fPaint->shader = this;
61 fPaint->fOwnsShader = true;
65 SkShader* SkDrawBitmapShader::getShader() {
69 // note: bitmap shader now supports independent tile modes for X and Y
70 // we pass the same to both, but later we should extend this flexibility
71 // to the xml (e.g. tileModeX="repeat" tileModeY="clmap")
73 // oops, bitmapshader no longer takes filterBitmap, but deduces it at
74 // draw-time from the paint
75 SkShader* shader = SkShader::CreateBitmapShader(image->fBitmap,
76 (SkShader::TileMode) tileMode,
77 (SkShader::TileMode) tileMode,
79 SkAutoTDelete<SkShader> autoDel(shader);
80 (void)autoDel.detach();