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

Side by Side Diff: src/core/SkComposeShader.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
« no previous file with comments | « src/core/SkColorMatrixFilterRowMajor255.cpp ('k') | src/core/SkLightingShader.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkComposeShader.h" 8 #include "SkComposeShader.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 21 matching lines...) Expand all
32 32
33 ~SkAutoAlphaRestore() { 33 ~SkAutoAlphaRestore() {
34 fPaint->setAlpha(fAlpha); 34 fPaint->setAlpha(fAlpha);
35 } 35 }
36 private: 36 private:
37 SkPaint* fPaint; 37 SkPaint* fPaint;
38 uint8_t fAlpha; 38 uint8_t fAlpha;
39 }; 39 };
40 #define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore) 40 #define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore)
41 41
42 SkFlattenable* SkComposeShader::CreateProc(SkReadBuffer& buffer) { 42 sk_sp<SkFlattenable> SkComposeShader::CreateProc(SkReadBuffer& buffer) {
43 sk_sp<SkShader> shaderA(buffer.readShader()); 43 sk_sp<SkShader> shaderA(buffer.readShader());
44 sk_sp<SkShader> shaderB(buffer.readShader()); 44 sk_sp<SkShader> shaderB(buffer.readShader());
45 sk_sp<SkXfermode> mode(buffer.readXfermode()); 45 sk_sp<SkXfermode> mode(buffer.readXfermode());
46 if (!shaderA || !shaderB) { 46 if (!shaderA || !shaderB) {
47 return nullptr; 47 return nullptr;
48 } 48 }
49 return new SkComposeShader(std::move(shaderA), std::move(shaderB), std::move (mode)); 49 return sk_make_sp<SkComposeShader>(std::move(shaderA), std::move(shaderB), s td::move(mode));
50 } 50 }
51 51
52 void SkComposeShader::flatten(SkWriteBuffer& buffer) const { 52 void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
53 buffer.writeFlattenable(fShaderA.get()); 53 buffer.writeFlattenable(fShaderA.get());
54 buffer.writeFlattenable(fShaderB.get()); 54 buffer.writeFlattenable(fShaderB.get());
55 buffer.writeFlattenable(fMode.get()); 55 buffer.writeFlattenable(fMode.get());
56 } 56 }
57 57
58 template <typename T> void safe_call_destructor(T* obj) { 58 template <typename T> void safe_call_destructor(T* obj) {
59 if (obj) { 59 if (obj) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!dst || !src) { 246 if (!dst || !src) {
247 return nullptr; 247 return nullptr;
248 } 248 }
249 return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), std::move (xfer)); 249 return sk_make_sp<SkComposeShader>(std::move(dst), std::move(src), std::move (xfer));
250 } 250 }
251 251
252 sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src, 252 sk_sp<SkShader> SkShader::MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src,
253 SkXfermode::Mode mode) { 253 SkXfermode::Mode mode) {
254 return MakeComposeShader(std::move(dst), std::move(src), SkXfermode::Make(mo de)); 254 return MakeComposeShader(std::move(dst), std::move(src), SkXfermode::Make(mo de));
255 } 255 }
OLDNEW
« no previous file with comments | « src/core/SkColorMatrixFilterRowMajor255.cpp ('k') | src/core/SkLightingShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698