| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkDrawShader.h" | 10 #include "SkDrawShader.h" |
| 11 #include "SkDrawBitmap.h" | 11 #include "SkDrawBitmap.h" |
| 12 #include "SkDrawMatrix.h" | 12 #include "SkDrawMatrix.h" |
| 13 #include "SkDrawPaint.h" | 13 #include "SkDrawPaint.h" |
| 14 | 14 |
| 15 #if SK_USE_CONDENSED_INFO == 0 | 15 #if SK_USE_CONDENSED_INFO == 0 |
| 16 | 16 |
| 17 const SkMemberInfo SkDrawShader::fInfo[] = { | 17 const SkMemberInfo SkDrawShader::fInfo[] = { |
| 18 SK_MEMBER(matrix, Matrix), | 18 SK_MEMBER(matrix, Matrix), |
| 19 SK_MEMBER(tileMode, TileMode) | 19 SK_MEMBER(tileMode, TileMode) |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 DEFINE_GET_MEMBER(SkDrawShader); | 24 DEFINE_GET_MEMBER(SkDrawShader); |
| 25 | 25 |
| 26 SkDrawShader::SkDrawShader() : matrix(NULL), | 26 SkDrawShader::SkDrawShader() : matrix(nullptr), |
| 27 tileMode(SkShader::kClamp_TileMode) { | 27 tileMode(SkShader::kClamp_TileMode) { |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool SkDrawShader::add() { | 30 bool SkDrawShader::add() { |
| 31 if (fPaint->shader != (SkDrawShader*) -1) | 31 if (fPaint->shader != (SkDrawShader*) -1) |
| 32 return true; | 32 return true; |
| 33 fPaint->shader = this; | 33 fPaint->shader = this; |
| 34 fPaint->fOwnsShader = true; | 34 fPaint->fOwnsShader = true; |
| 35 return false; | 35 return false; |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkMatrix* SkDrawShader::getMatrix() { | 38 SkMatrix* SkDrawShader::getMatrix() { |
| 39 return matrix ? &matrix->getMatrix() : NULL; | 39 return matrix ? &matrix->getMatrix() : nullptr; |
| 40 } | 40 } |
| 41 | 41 |
| 42 #if SK_USE_CONDENSED_INFO == 0 | 42 #if SK_USE_CONDENSED_INFO == 0 |
| 43 | 43 |
| 44 const SkMemberInfo SkDrawBitmapShader::fInfo[] = { | 44 const SkMemberInfo SkDrawBitmapShader::fInfo[] = { |
| 45 SK_MEMBER_INHERITED, | 45 SK_MEMBER_INHERITED, |
| 46 SK_MEMBER(filterBitmap, Boolean), | 46 SK_MEMBER(filterBitmap, Boolean), |
| 47 SK_MEMBER(image, BaseBitmap) | 47 SK_MEMBER(image, BaseBitmap) |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 DEFINE_GET_MEMBER(SkDrawBitmapShader); | 52 DEFINE_GET_MEMBER(SkDrawBitmapShader); |
| 53 | 53 |
| 54 SkDrawBitmapShader::SkDrawBitmapShader() : filterBitmap(-1), image(NULL) {} | 54 SkDrawBitmapShader::SkDrawBitmapShader() : filterBitmap(-1), image(nullptr) {} |
| 55 | 55 |
| 56 bool SkDrawBitmapShader::add() { | 56 bool SkDrawBitmapShader::add() { |
| 57 if (fPaint->shader != (SkDrawShader*) -1) | 57 if (fPaint->shader != (SkDrawShader*) -1) |
| 58 return true; | 58 return true; |
| 59 fPaint->shader = this; | 59 fPaint->shader = this; |
| 60 fPaint->fOwnsShader = true; | 60 fPaint->fOwnsShader = true; |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 SkShader* SkDrawBitmapShader::getShader() { | 64 SkShader* SkDrawBitmapShader::getShader() { |
| 65 if (image == NULL) | 65 if (image == nullptr) |
| 66 return NULL; | 66 return nullptr; |
| 67 | 67 |
| 68 // note: bitmap shader now supports independent tile modes for X and Y | 68 // note: bitmap shader now supports independent tile modes for X and Y |
| 69 // we pass the same to both, but later we should extend this flexibility | 69 // we pass the same to both, but later we should extend this flexibility |
| 70 // to the xml (e.g. tileModeX="repeat" tileModeY="clmap") | 70 // to the xml (e.g. tileModeX="repeat" tileModeY="clmap") |
| 71 // | 71 // |
| 72 // oops, bitmapshader no longer takes filterBitmap, but deduces it at | 72 // oops, bitmapshader no longer takes filterBitmap, but deduces it at |
| 73 // draw-time from the paint | 73 // draw-time from the paint |
| 74 return SkShader::CreateBitmapShader(image->fBitmap, | 74 return SkShader::CreateBitmapShader(image->fBitmap, |
| 75 (SkShader::TileMode) tileMode, | 75 (SkShader::TileMode) tileMode, |
| 76 (SkShader::TileMode) tileMode, | 76 (SkShader::TileMode) tileMode, |
| 77 getMatrix()); | 77 getMatrix()); |
| 78 } | 78 } |
| OLD | NEW |