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

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

Issue 1405103003: Remove SkDEPRECATED_InstallDiscardablePixelRef from SkPictureShader (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: comment Created 5 years, 2 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 | « no previous file | no next file » | 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"
11 #include "SkBitmapProcShader.h" 11 #include "SkBitmapProcShader.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkImage.h"
13 #include "SkImageGenerator.h" 14 #include "SkImageGenerator.h"
14 #include "SkMatrixUtils.h" 15 #include "SkMatrixUtils.h"
15 #include "SkPicture.h" 16 #include "SkPicture.h"
16 #include "SkReadBuffer.h" 17 #include "SkReadBuffer.h"
17 #include "SkResourceCache.h" 18 #include "SkResourceCache.h"
18 19
19 #if SK_SUPPORT_GPU 20 #if SK_SUPPORT_GPU
20 #include "GrContext.h" 21 #include "GrContext.h"
21 #include "GrCaps.h" 22 #include "GrCaps.h"
22 #endif 23 #endif
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 BitmapShaderKey key(fPicture->uniqueID(), 211 BitmapShaderKey key(fPicture->uniqueID(),
211 fTile, 212 fTile,
212 fTmx, 213 fTmx,
213 fTmy, 214 fTmy,
214 tileScale, 215 tileScale,
215 this->getLocalMatrix()); 216 this->getLocalMatrix());
216 217
217 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { 218 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
218 SkMatrix tileMatrix; 219 SkMatrix tileMatrix;
219 tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSi ze.height()), 220 tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSi ze.height()),
220 SkMatrix::kFill_ScaleToFit); 221 SkMatrix::kFill_ScaleToFit);
221 SkBitmap bm; 222
222 if (!SkDEPRECATED_InstallDiscardablePixelRef( 223 SkAutoTDelete<SkImageGenerator> tileGenerator(
223 SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nu llptr), &bm)) { 224 SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nu llptr));
225 if (!tileGenerator) {
226 return nullptr;
227 }
228
229 // Grab this before the generator goes poof!
230 const SkImageInfo tileInfo = tileGenerator->getInfo();
reed1 2015/10/16 14:12:19 Can we replace these to New calls with just s
231
232 SkAutoTUnref<SkImage> tileImage(SkImage::NewFromGenerator(tileGenerator. detach()));
233 if (!tileImage) {
224 return nullptr; 234 return nullptr;
225 } 235 }
226 236
227 SkMatrix shaderMatrix = this->getLocalMatrix(); 237 SkMatrix shaderMatrix = this->getLocalMatrix();
228 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); 238 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height());
229 tileShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatrix)); 239 tileShader.reset(tileImage->newShader(fTmx, fTmy, &shaderMatrix));
230 240
231 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(), bm.getSi ze())); 241 SkResourceCache::Add(new BitmapShaderRec(key, tileShader.get(),
242 tileInfo.getSafeSize(tileInfo.m inRowBytes())));
232 } 243 }
233 244
234 return tileShader.detach(); 245 return tileShader.detach();
235 } 246 }
236 247
237 size_t SkPictureShader::contextSize() const { 248 size_t SkPictureShader::contextSize() const {
238 return sizeof(PictureShaderContext); 249 return sizeof(PictureShaderContext);
239 } 250 }
240 251
241 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const { 252 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (context) { 334 if (context) {
324 maxTextureSize = context->caps()->maxTextureSize(); 335 maxTextureSize = context->caps()->maxTextureSize();
325 } 336 }
326 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize)); 337 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize));
327 if (!bitmapShader) { 338 if (!bitmapShader) {
328 return nullptr; 339 return nullptr;
329 } 340 }
330 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); 341 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq);
331 } 342 }
332 #endif 343 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698