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

Side by Side Diff: src/gpu/effects/GrGammaEffect.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/gpu/effects/GrGammaEffect.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.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 2016 Google Inc. 2 * Copyright 2016 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 "GrGammaEffect.h" 8 #include "GrGammaEffect.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 void GrGammaEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 111 void GrGammaEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
112 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 112 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
113 } 113 }
114 114
115 /////////////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////////////
116 116
117 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGammaEffect); 117 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGammaEffect);
118 118
119 const GrFragmentProcessor* GrGammaEffect::TestCreate(GrProcessorTestData* d) { 119 sk_sp<GrFragmentProcessor> GrGammaEffect::TestCreate(GrProcessorTestData* d) {
120 // We want to be sure and test sRGB sometimes 120 // We want to be sure and test sRGB sometimes
121 Mode testMode = static_cast<Mode>(d->fRandom->nextRangeU(0, 2)); 121 Mode testMode = static_cast<Mode>(d->fRandom->nextRangeU(0, 2));
122 SkScalar gamma = d->fRandom->nextRangeScalar(0.5f, 2.0f); 122 SkScalar gamma = d->fRandom->nextRangeScalar(0.5f, 2.0f);
123 return new GrGammaEffect(testMode, gamma); 123 return sk_sp<GrFragmentProcessor>(new GrGammaEffect(testMode, gamma));
124 } 124 }
125 125
126 /////////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////////
127 127
128 void GrGammaEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 128 void GrGammaEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
129 GrProcessorKeyBuilder* b) const { 129 GrProcessorKeyBuilder* b) const {
130 GrGLGammaEffect::GenKey(*this, caps, b); 130 GrGLGammaEffect::GenKey(*this, caps, b);
131 } 131 }
132 132
133 GrGLSLFragmentProcessor* GrGammaEffect::onCreateGLSLInstance() const { 133 GrGLSLFragmentProcessor* GrGammaEffect::onCreateGLSLInstance() const {
134 return new GrGLGammaEffect(); 134 return new GrGLGammaEffect();
135 } 135 }
136 136
137 const GrFragmentProcessor* GrGammaEffect::Create(SkScalar gamma) { 137 sk_sp<GrFragmentProcessor> GrGammaEffect::Make(SkScalar gamma) {
138 // TODO: Once our public-facing API for specifying gamma curves settles down , expose this, 138 // TODO: Once our public-facing API for specifying gamma curves settles down , expose this,
139 // and allow clients to explicitly request sRGB, rather than inferring from the exponent. 139 // and allow clients to explicitly request sRGB, rather than inferring from the exponent.
140 // Note that AdobeRGB (for example) is speficied as x^2.2, not the Rec.709 c urves. 140 // Note that AdobeRGB (for example) is speficied as x^2.2, not the Rec.709 c urves.
141 if (SkScalarNearlyEqual(gamma, 2.2f)) { 141 if (SkScalarNearlyEqual(gamma, 2.2f)) {
142 return new GrGammaEffect(Mode::kSRGBToLinear, 2.2f); 142 return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kSRGBToLinear, 2.2f));
143 } else if (SkScalarNearlyEqual(gamma, 1.0f / 2.2f)) { 143 } else if (SkScalarNearlyEqual(gamma, 1.0f / 2.2f)) {
144 return new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f); 144 return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kLinearToSRGB, 1.0f / 2.2f));
145 } else { 145 } else {
146 return new GrGammaEffect(Mode::kExponential, gamma); 146 return sk_sp<GrFragmentProcessor>(new GrGammaEffect(Mode::kExponential, gamma));
147 } 147 }
148 } 148 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrGammaEffect.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698