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

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

Issue 1789443002: Revert "Revert of add Make variations to return SkImage by sk_sp (patchset #5 id:80001 of https://c… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use get, not release, when calling legacy function that wants ptr 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/SkPictureShader.h ('k') | src/core/SkReadBuffer.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 result->reset(SkRef(rec.fShader.get())); 86 result->reset(SkRef(rec.fShader.get()));
87 87
88 // The bitmap shader is backed by an image generator, thus it can always re-generate its 88 // The bitmap shader is backed by an image generator, thus it can always re-generate its
89 // pixels if discarded. 89 // pixels if discarded.
90 return true; 90 return true;
91 } 91 }
92 }; 92 };
93 93
94 } // namespace 94 } // namespace
95 95
96 SkPictureShader::SkPictureShader(sk_sp<const SkPicture> picture, TileMode tmx, T ileMode tmy, 96 SkPictureShader::SkPictureShader(sk_sp<SkPicture> picture, TileMode tmx, TileMod e tmy,
97 const SkMatrix* localMatrix, const SkRect* tile ) 97 const SkMatrix* localMatrix, const SkRect* tile )
98 : INHERITED(localMatrix) 98 : INHERITED(localMatrix)
99 , fPicture(std::move(picture)) 99 , fPicture(std::move(picture))
100 , fTile(tile ? *tile : fPicture->cullRect()) 100 , fTile(tile ? *tile : fPicture->cullRect())
101 , fTmx(tmx) 101 , fTmx(tmx)
102 , fTmy(tmy) { 102 , fTmy(tmy) {
103 } 103 }
104 104
105 sk_sp<SkShader> SkPictureShader::Make(sk_sp<const SkPicture> picture, TileMode t mx, TileMode tmy, 105 sk_sp<SkShader> SkPictureShader::Make(sk_sp<SkPicture> picture, TileMode tmx, Ti leMode tmy,
106 const SkMatrix* localMatrix, const SkRect* tile) { 106 const SkMatrix* localMatrix, const SkRect* tile) {
107 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) { 107 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
108 return SkShader::MakeEmptyShader(); 108 return SkShader::MakeEmptyShader();
109 } 109 }
110 return sk_sp<SkShader>(new SkPictureShader(std::move(picture), tmx, tmy, loc alMatrix, tile)); 110 return sk_sp<SkShader>(new SkPictureShader(std::move(picture), tmx, tmy, loc alMatrix, tile));
111 } 111 }
112 112
113 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) { 113 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
114 SkMatrix lm; 114 SkMatrix lm;
115 buffer.readMatrix(&lm); 115 buffer.readMatrix(&lm);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 fTmx, 216 fTmx,
217 fTmy, 217 fTmy,
218 tileScale, 218 tileScale,
219 this->getLocalMatrix()); 219 this->getLocalMatrix());
220 220
221 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { 221 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
222 SkMatrix tileMatrix; 222 SkMatrix tileMatrix;
223 tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSi ze.height()), 223 tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSi ze.height()),
224 SkMatrix::kFill_ScaleToFit); 224 SkMatrix::kFill_ScaleToFit);
225 225
226 SkAutoTUnref<SkImage> tileImage( 226 sk_sp<SkImage> tileImage(
227 SkImage::NewFromPicture(fPicture.get(), tileSize, &tileMatrix, nullp tr)); 227 SkImage::MakeFromPicture(fPicture, tileSize, &tileMatrix, nullptr));
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 = tileImage->makeShader(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(),
(...skipping 89 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/SkPictureShader.h ('k') | src/core/SkReadBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698