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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/SkColorFilterShader.h ('k') | src/core/SkColorMatrixFilterRowMajor255.h » ('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 2013 Google Inc. 2 * Copyright 2013 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 "SkColorFilterShader.h" 8 #include "SkColorFilterShader.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 int count) { 90 int count) {
91 const SkColorFilterShader& filterShader = static_cast<const SkColorFilterSha der&>(fShader); 91 const SkColorFilterShader& filterShader = static_cast<const SkColorFilterSha der&>(fShader);
92 92
93 fShaderContext->shadeSpan4f(x, y, result, count); 93 fShaderContext->shadeSpan4f(x, y, result, count);
94 filterShader.fFilter->filterSpan4f(result, count, result); 94 filterShader.fFilter->filterSpan4f(result, count, result);
95 } 95 }
96 96
97 #if SK_SUPPORT_GPU 97 #if SK_SUPPORT_GPU
98 ///////////////////////////////////////////////////////////////////// 98 /////////////////////////////////////////////////////////////////////
99 99
100 const GrFragmentProcessor* SkColorFilterShader::asFragmentProcessor( 100 sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
101 GrContext* context, 101 GrContext* context,
102 const SkMatrix& viewM, 102 const SkMatrix& viewM,
103 const SkMatrix* localMatrix , 103 const SkMatrix* localMatrix ,
104 SkFilterQuality fq, 104 SkFilterQuality fq,
105 SkSourceGammaTreatment gamm aTreatment) const { 105 SkSourceGammaTreatment gamm aTreatment) const {
106 106
107 SkAutoTUnref<const GrFragmentProcessor> fp1(fShader->asFragmentProcessor(con text, viewM, 107 sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM, localMatrix, fq,
108 loc alMatrix, fq, 108 gammaTreatment)) ;
109 gam maTreatment)); 109 if (!fp1) {
110 if (!fp1.get()) {
111 return nullptr; 110 return nullptr;
112 } 111 }
113 112
114 SkAutoTUnref<const GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(con text)); 113 sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
115 if (!fp2.get()) { 114 if (!fp2) {
116 return fp1.release(); 115 return fp1;
117 } 116 }
118 117
119 const GrFragmentProcessor* fpSeries[] = { fp1.get(), fp2.get() }; 118 sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
120
121 return GrFragmentProcessor::RunInSeries(fpSeries, 2); 119 return GrFragmentProcessor::RunInSeries(fpSeries, 2);
122 } 120 }
123 #endif 121 #endif
124 122
125 #ifndef SK_IGNORE_TO_STRING 123 #ifndef SK_IGNORE_TO_STRING
126 void SkColorFilterShader::toString(SkString* str) const { 124 void SkColorFilterShader::toString(SkString* str) const {
127 str->append("SkColorFilterShader: ("); 125 str->append("SkColorFilterShader: (");
128 126
129 str->append("Shader: "); 127 str->append("Shader: ");
130 fShader->toString(str); 128 fShader->toString(str);
131 str->append(" Filter: "); 129 str->append(" Filter: ");
132 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added 130 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
133 131
134 this->INHERITED::toString(str); 132 this->INHERITED::toString(str);
135 133
136 str->append(")"); 134 str->append(")");
137 } 135 }
138 #endif 136 #endif
139 137
140 //////////////////////////////////////////////////////////////////////////////// /////////////////// 138 //////////////////////////////////////////////////////////////////////////////// ///////////////////
141 139
142 sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const { 140 sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const {
143 SkShader* base = const_cast<SkShader*>(this); 141 SkShader* base = const_cast<SkShader*>(this);
144 if (!filter) { 142 if (!filter) {
145 return sk_ref_sp(base); 143 return sk_ref_sp(base);
146 } 144 }
147 return sk_make_sp<SkColorFilterShader>(sk_ref_sp(base), filter); 145 return sk_make_sp<SkColorFilterShader>(sk_ref_sp(base), filter);
148 } 146 }
OLDNEW
« no previous file with comments | « src/core/SkColorFilterShader.h ('k') | src/core/SkColorMatrixFilterRowMajor255.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698