Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/core/SkPictureShader.cpp

Issue 1785473002: SkImage now has makeShader to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use build guard for impl of newShader Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698