OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkBitmapProvider.h" | 9 #include "SkBitmapProvider.h" |
10 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 size_t SkImageShader::onContextSize(const ContextRec& rec) const { | 45 size_t SkImageShader::onContextSize(const ContextRec& rec) const { |
46 return SkBitmapProcShader::ContextSize(rec, SkBitmapProvider(fImage).info())
; | 46 return SkBitmapProcShader::ContextSize(rec, SkBitmapProvider(fImage).info())
; |
47 } | 47 } |
48 | 48 |
49 SkShader::Context* SkImageShader::onCreateContext(const ContextRec& rec, void* s
torage) const { | 49 SkShader::Context* SkImageShader::onCreateContext(const ContextRec& rec, void* s
torage) const { |
50 return SkBitmapProcShader::MakeContext(*this, fTileModeX, fTileModeY, | 50 return SkBitmapProcShader::MakeContext(*this, fTileModeX, fTileModeY, |
51 SkBitmapProvider(fImage), rec, storag
e); | 51 SkBitmapProvider(fImage), rec, storag
e); |
52 } | 52 } |
53 | 53 |
| 54 SkImage* SkImageShader::onIsAImage(SkMatrix* texM, TileMode xy[]) const { |
| 55 if (texM) { |
| 56 *texM = this->getLocalMatrix(); |
| 57 } |
| 58 if (xy) { |
| 59 xy[0] = (TileMode)fTileModeX; |
| 60 xy[1] = (TileMode)fTileModeY; |
| 61 } |
| 62 return const_cast<SkImage*>(fImage.get()); |
| 63 } |
| 64 |
| 65 bool SkImageShader::onIsABitmap(SkBitmap* texture, SkMatrix* texM, TileMode xy[]
) const { |
| 66 const SkBitmap* bm = as_IB(fImage)->onPeekBitmap(); |
| 67 if (!bm) { |
| 68 return false; |
| 69 } |
| 70 |
| 71 if (texture) { |
| 72 *texture = *bm; |
| 73 } |
| 74 if (texM) { |
| 75 *texM = this->getLocalMatrix(); |
| 76 } |
| 77 if (xy) { |
| 78 xy[0] = (TileMode)fTileModeX; |
| 79 xy[1] = (TileMode)fTileModeY; |
| 80 } |
| 81 return true; |
| 82 } |
| 83 |
54 sk_sp<SkShader> SkImageShader::Make(const SkImage* image, TileMode tx, TileMode
ty, | 84 sk_sp<SkShader> SkImageShader::Make(const SkImage* image, TileMode tx, TileMode
ty, |
55 const SkMatrix* localMatrix) { | 85 const SkMatrix* localMatrix) { |
56 if (!image) { | 86 if (!image) { |
57 return nullptr; | 87 return nullptr; |
58 } | 88 } |
59 return sk_sp<SkShader>(new SkImageShader(image, tx, ty, localMatrix)); | 89 return sk_sp<SkShader>(new SkImageShader(image, tx, ty, localMatrix)); |
60 } | 90 } |
61 | 91 |
62 #ifndef SK_IGNORE_TO_STRING | 92 #ifndef SK_IGNORE_TO_STRING |
63 void SkImageShader::toString(SkString* str) const { | 93 void SkImageShader::toString(SkString* str) const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params); | 154 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params); |
125 } | 155 } |
126 | 156 |
127 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 157 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
128 return inner; | 158 return inner; |
129 } | 159 } |
130 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha
(std::move(inner))); | 160 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha
(std::move(inner))); |
131 } | 161 } |
132 | 162 |
133 #endif | 163 #endif |
OLD | NEW |