OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 SkMatrix::kFill_ScaleToFit); | 224 SkMatrix::kFill_ScaleToFit); |
225 | 225 |
226 SkAutoTUnref<SkImage> tileImage( | 226 SkAutoTUnref<SkImage> tileImage( |
227 SkImage::NewFromPicture(fPicture.get(), tileSize, &tileMatrix, nullp
tr)); | 227 SkImage::NewFromPicture(fPicture.get(), tileSize, &tileMatrix, nullp
tr)); |
228 if (!tileImage) { | 228 if (!tileImage) { |
229 return nullptr; | 229 return nullptr; |
230 } | 230 } |
231 | 231 |
232 SkMatrix shaderMatrix = this->getLocalMatrix(); | 232 SkMatrix shaderMatrix = this->getLocalMatrix(); |
233 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); | 233 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); |
234 tileShader.reset(tileImage->newShader(fTmx, fTmy, &shaderMatrix)); | 234 tileShader = tileImage->makeShader(fTmx, fTmy, &shaderMatrix); |
235 | 235 |
236 const SkImageInfo tileInfo = SkImageInfo::MakeN32Premul(tileSize); | 236 const SkImageInfo tileInfo = SkImageInfo::MakeN32Premul(tileSize); |
237 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), | 237 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), |
238 tileInfo.getSafeSize(tileInfo.m
inRowBytes()))); | 238 tileInfo.getSafeSize(tileInfo.m
inRowBytes()))); |
239 } | 239 } |
240 | 240 |
241 return tileShader; | 241 return tileShader; |
242 } | 242 } |
243 | 243 |
244 size_t SkPictureShader::onContextSize(const ContextRec&) const { | 244 size_t SkPictureShader::onContextSize(const ContextRec&) const { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 if (context) { | 327 if (context) { |
328 maxTextureSize = context->caps()->maxTextureSize(); | 328 maxTextureSize = context->caps()->maxTextureSize(); |
329 } | 329 } |
330 sk_sp<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTe
xtureSize)); | 330 sk_sp<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTe
xtureSize)); |
331 if (!bitmapShader) { | 331 if (!bitmapShader) { |
332 return nullptr; | 332 return nullptr; |
333 } | 333 } |
334 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); | 334 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); |
335 } | 335 } |
336 #endif | 336 #endif |
OLD | NEW |