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

Side by Side Diff: src/image/SkImageShader.cpp

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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"
11 #include "SkImageShader.h" 11 #include "SkImageShader.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
14 14
15 SkImageShader::SkImageShader(const SkImage* img, TileMode tmx, TileMode tmy, con st SkMatrix* matrix) 15 SkImageShader::SkImageShader(const SkImage* img, TileMode tmx, TileMode tmy, con st SkMatrix* matrix)
16 : INHERITED(matrix) 16 : INHERITED(matrix)
17 , fImage(SkRef(img)) 17 , fImage(SkRef(img))
18 , fTileModeX(tmx) 18 , fTileModeX(tmx)
19 , fTileModeY(tmy) 19 , fTileModeY(tmy)
20 {} 20 {}
21 21
22 SkFlattenable* SkImageShader::CreateProc(SkReadBuffer& buffer) { 22 sk_sp<SkFlattenable> SkImageShader::CreateProc(SkReadBuffer& buffer) {
23 const TileMode tx = (TileMode)buffer.readUInt(); 23 const TileMode tx = (TileMode)buffer.readUInt();
24 const TileMode ty = (TileMode)buffer.readUInt(); 24 const TileMode ty = (TileMode)buffer.readUInt();
25 SkMatrix matrix; 25 SkMatrix matrix;
26 buffer.readMatrix(&matrix); 26 buffer.readMatrix(&matrix);
27 SkAutoTUnref<SkImage> img(buffer.readImage()); 27 SkAutoTUnref<SkImage> img(buffer.readImage());
28 if (!img) { 28 if (!img) {
29 return nullptr; 29 return nullptr;
30 } 30 }
31 return SkImageShader::Make(img, tx, ty, &matrix).release(); 31 return SkImageShader::Make(img, tx, ty, &matrix);
32 } 32 }
33 33
34 void SkImageShader::flatten(SkWriteBuffer& buffer) const { 34 void SkImageShader::flatten(SkWriteBuffer& buffer) const {
35 buffer.writeUInt(fTileModeX); 35 buffer.writeUInt(fTileModeX);
36 buffer.writeUInt(fTileModeY); 36 buffer.writeUInt(fTileModeY);
37 buffer.writeMatrix(this->getLocalMatrix()); 37 buffer.writeMatrix(this->getLocalMatrix());
38 buffer.writeImage(fImage); 38 buffer.writeImage(fImage);
39 } 39 }
40 40
41 bool SkImageShader::isOpaque() const { 41 bool SkImageShader::isOpaque() const {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); 125 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
126 } 126 }
127 127
128 if (GrPixelConfigIsAlphaOnly(texture->config())) { 128 if (GrPixelConfigIsAlphaOnly(texture->config())) {
129 return SkRef(inner.get()); 129 return SkRef(inner.get());
130 } 130 }
131 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 131 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
132 } 132 }
133 133
134 #endif 134 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | src/utils/SkBitmapSourceDeserializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698