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

Side by Side Diff: src/effects/SkColorCubeFilter.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorFilters.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 "SkColorCubeFilter.h" 8 #include "SkColorCubeFilter.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkOnce.h" 10 #include "SkOnce.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void SkColorCubeFilter::toString(SkString* str) const { 155 void SkColorCubeFilter::toString(SkString* str) const {
156 str->append("SkColorCubeFilter "); 156 str->append("SkColorCubeFilter ");
157 } 157 }
158 #endif 158 #endif
159 159
160 /////////////////////////////////////////////////////////////////////////////// 160 ///////////////////////////////////////////////////////////////////////////////
161 #if SK_SUPPORT_GPU 161 #if SK_SUPPORT_GPU
162 162
163 class GrColorCubeEffect : public GrFragmentProcessor { 163 class GrColorCubeEffect : public GrFragmentProcessor {
164 public: 164 public:
165 static const GrFragmentProcessor* Create(GrTexture* colorCube) { 165 static const GrFragmentProcessor* Create(GrTexture* colorCube, GrRenderTarge t* dst) {
166 return (nullptr != colorCube) ? new GrColorCubeEffect(colorCube) : nullp tr; 166 return (nullptr != colorCube) ? new GrColorCubeEffect(colorCube, dst) : nullptr;
167 } 167 }
168 168
169 virtual ~GrColorCubeEffect(); 169 virtual ~GrColorCubeEffect();
170 170
171 const char* name() const override { return "ColorCube"; } 171 const char* name() const override { return "ColorCube"; }
172 172
173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } 173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); }
174 174
175 175
176 void onComputeInvariantOutput(GrInvariantOutput*) const override; 176 void onComputeInvariantOutput(GrInvariantOutput*) const override;
(...skipping 18 matching lines...) Expand all
195 }; 195 };
196 196
197 private: 197 private:
198 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 198 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
199 GrProcessorKeyBuilder* b) const override; 199 GrProcessorKeyBuilder* b) const override;
200 200
201 GrGLFragmentProcessor* onCreateGLInstance() const override; 201 GrGLFragmentProcessor* onCreateGLInstance() const override;
202 202
203 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 203 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
204 204
205 GrColorCubeEffect(GrTexture* colorCube); 205 GrColorCubeEffect(GrTexture* colorCube, GrRenderTarget* dst);
206 206
207 GrTextureAccess fColorCubeAccess; 207 GrTextureAccess fColorCubeAccess;
208 208
209 typedef GrFragmentProcessor INHERITED; 209 typedef GrFragmentProcessor INHERITED;
210 }; 210 };
211 211
212 /////////////////////////////////////////////////////////////////////////////// 212 ///////////////////////////////////////////////////////////////////////////////
213 213
214 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube) 214 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube, GrRenderTarget* dst)
215 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) { 215 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode, S kShader::kClamp_TileMode, dst) {
216 this->initClassID<GrColorCubeEffect>(); 216 this->initClassID<GrColorCubeEffect>();
217 this->addTextureAccess(&fColorCubeAccess); 217 this->addTextureAccess(&fColorCubeAccess);
218 } 218 }
219 219
220 GrColorCubeEffect::~GrColorCubeEffect() { 220 GrColorCubeEffect::~GrColorCubeEffect() {
221 } 221 }
222 222
223 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK eyBuilder* b) const { 223 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK eyBuilder* b) const {
224 GLProcessor::GenKey(*this, caps, b); 224 GLProcessor::GenKey(*this, caps, b);
225 } 225 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); 298 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>();
299 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); 299 SkScalar size = SkIntToScalar(colorCube.colorCubeSize());
300 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); 300 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size));
301 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); 301 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size)));
302 } 302 }
303 303
304 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, 304 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc,
305 const GrGLSLCaps&, GrProcessorKeyBui lder* b) { 305 const GrGLSLCaps&, GrProcessorKeyBui lder* b) {
306 } 306 }
307 307
308 const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* con text) const { 308 const GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* con text,
309 GrRenderTarget * dst) const {
309 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 310 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
310 GrUniqueKey key; 311 GrUniqueKey key;
311 GrUniqueKey::Builder builder(&key, kDomain, 2); 312 GrUniqueKey::Builder builder(&key, kDomain, 2);
312 builder[0] = fUniqueID; 313 builder[0] = fUniqueID;
313 builder[1] = fCache.cubeDimension(); 314 builder[1] = fCache.cubeDimension();
314 builder.finish(); 315 builder.finish();
315 316
316 GrSurfaceDesc desc; 317 GrSurfaceDesc desc;
317 desc.fWidth = fCache.cubeDimension(); 318 desc.fWidth = fCache.cubeDimension();
318 desc.fHeight = fCache.cubeDimension() * fCache.cubeDimension(); 319 desc.fHeight = fCache.cubeDimension() * fCache.cubeDimension();
319 desc.fConfig = kRGBA_8888_GrPixelConfig; 320 desc.fConfig = kRGBA_8888_GrPixelConfig;
320 321
321 SkAutoTUnref<GrTexture> textureCube( 322 SkAutoTUnref<GrTexture> textureCube(
322 context->textureProvider()->findAndRefTextureByUniqueKey(key)); 323 context->textureProvider()->findAndRefTextureByUniqueKey(key));
323 if (!textureCube) { 324 if (!textureCube) {
324 textureCube.reset(context->textureProvider()->createTexture( 325 textureCube.reset(context->textureProvider()->createTexture(
325 desc, true, fCubeData->data(), 0)); 326 desc, true, fCubeData->data(), 0));
326 if (textureCube) { 327 if (textureCube) {
327 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub e); 328 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub e);
328 } else { 329 } else {
329 return nullptr; 330 return nullptr;
330 } 331 }
331 } 332 }
332 333
333 return GrColorCubeEffect::Create(textureCube); 334 return GrColorCubeEffect::Create(textureCube, dst);
334 } 335 }
335 #endif 336 #endif
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698