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

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

Issue 973593002: change colorfilter to return an array of frag processors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update gm Created 5 years, 9 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 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); 330 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>();
331 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); 331 SkScalar size = SkIntToScalar(colorCube.colorCubeSize());
332 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); 332 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size));
333 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); 333 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size)));
334 } 334 }
335 335
336 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc, 336 void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc,
337 const GrGLCaps&, GrProcessorKeyBuild er* b) { 337 const GrGLCaps&, GrProcessorKeyBuild er* b) {
338 } 338 }
339 339
340 GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) const { 340 bool SkColorCubeFilter::asFragmentProcessors(GrContext* context,
341 SkTDArray<GrFragmentProcessor*>* ar ray) const {
341 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 342 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
342 GrUniqueKey key; 343 GrUniqueKey key;
343 GrUniqueKey::Builder builder(&key, kDomain, 2); 344 GrUniqueKey::Builder builder(&key, kDomain, 2);
344 builder[0] = fUniqueID; 345 builder[0] = fUniqueID;
345 builder[1] = fCache.cubeDimension(); 346 builder[1] = fCache.cubeDimension();
346 builder.finish(); 347 builder.finish();
347 348
348 GrSurfaceDesc desc; 349 GrSurfaceDesc desc;
349 desc.fWidth = fCache.cubeDimension(); 350 desc.fWidth = fCache.cubeDimension();
350 desc.fHeight = fCache.cubeDimension() * fCache.cubeDimension(); 351 desc.fHeight = fCache.cubeDimension() * fCache.cubeDimension();
351 desc.fConfig = kRGBA_8888_GrPixelConfig; 352 desc.fConfig = kRGBA_8888_GrPixelConfig;
352 353
353 SkAutoTUnref<GrTexture> textureCube(context->findAndRefCachedTexture(key)); 354 SkAutoTUnref<GrTexture> textureCube(context->findAndRefCachedTexture(key));
354 if (!textureCube) { 355 if (!textureCube) {
355 textureCube.reset(context->createTexture(desc, true, fCubeData->data(), 0)); 356 textureCube.reset(context->createTexture(desc, true, fCubeData->data(), 0));
356 if (textureCube) { 357 if (textureCube) {
357 context->addResourceToCache(key, textureCube); 358 context->addResourceToCache(key, textureCube);
358 } 359 }
359 } 360 }
360 361
361 return textureCube ? GrColorCubeEffect::Create(textureCube) : NULL; 362 GrFragmentProcessor* frag = textureCube ? GrColorCubeEffect::Create(textureC ube) : NULL;
363 if (frag) {
364 if (array) {
365 *array->append() = frag;
366 }
367 return true;
Noel Gordon 2015/06/09 17:29:03 If array was NULL (maybe doesn't happen in practic
bsalomon 2015/06/12 15:20:36 Definitely not! https://codereview.chromium.org/1
368 }
369 return false;
362 } 370 }
363 #endif 371 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698