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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.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 2015 Google Inc. 2 * Copyright 2015 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 "SkTableColorFilter.h" 8 #include "SkTableColorFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 return SkTableColorFilter::CreateARGB(concatA, concatR, concatG, concatB); 329 return SkTableColorFilter::CreateARGB(concatA, concatR, concatG, concatB);
330 } 330 }
331 331
332 #if SK_SUPPORT_GPU 332 #if SK_SUPPORT_GPU
333 333
334 #include "GrFragmentProcessor.h" 334 #include "GrFragmentProcessor.h"
335 #include "GrInvariantOutput.h" 335 #include "GrInvariantOutput.h"
336 #include "SkGr.h" 336 #include "SkGr.h"
337 #include "effects/GrTextureStripAtlas.h" 337 #include "effects/GrTextureStripAtlas.h"
338 #include "gl/GrGLFragmentProcessor.h" 338 #include "glsl/GrGLSLFragmentProcessor.h"
339 #include "glsl/GrGLSLFragmentShaderBuilder.h" 339 #include "glsl/GrGLSLFragmentShaderBuilder.h"
340 #include "glsl/GrGLSLProgramBuilder.h" 340 #include "glsl/GrGLSLProgramBuilder.h"
341 #include "glsl/GrGLSLProgramDataManager.h" 341 #include "glsl/GrGLSLProgramDataManager.h"
342 342
343 class ColorTableEffect : public GrFragmentProcessor { 343 class ColorTableEffect : public GrFragmentProcessor {
344 public: 344 public:
345 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap , unsigned flags); 345 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap , unsigned flags);
346 346
347 virtual ~ColorTableEffect(); 347 virtual ~ColorTableEffect();
348 348
349 const char* name() const override { return "ColorTable"; } 349 const char* name() const override { return "ColorTable"; }
350 350
351 const GrTextureStripAtlas* atlas() const { return fAtlas; } 351 const GrTextureStripAtlas* atlas() const { return fAtlas; }
352 int atlasRow() const { return fRow; } 352 int atlasRow() const { return fRow; }
353 353
354 private: 354 private:
355 GrGLFragmentProcessor* onCreateGLInstance() const override; 355 GrGLSLFragmentProcessor* onCreateGLInstance() const override;
356 356
357 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 357 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
358 358
359 bool onIsEqual(const GrFragmentProcessor&) const override; 359 bool onIsEqual(const GrFragmentProcessor&) const override;
360 360
361 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 361 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
362 362
363 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un signed flags); 363 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un signed flags);
364 364
365 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 365 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
366 366
367 GrTextureAccess fTextureAccess; 367 GrTextureAccess fTextureAccess;
368 368
369 // currently not used in shader code, just to assist onComputeInvariantOutpu t(). 369 // currently not used in shader code, just to assist onComputeInvariantOutpu t().
370 unsigned fFlags; 370 unsigned fFlags;
371 371
372 GrTextureStripAtlas* fAtlas; 372 GrTextureStripAtlas* fAtlas;
373 int fRow; 373 int fRow;
374 374
375 typedef GrFragmentProcessor INHERITED; 375 typedef GrFragmentProcessor INHERITED;
376 }; 376 };
377 377
378 class GLColorTableEffect : public GrGLFragmentProcessor { 378 class GLColorTableEffect : public GrGLSLFragmentProcessor {
379 public: 379 public:
380 GLColorTableEffect(const GrProcessor&); 380 GLColorTableEffect(const GrProcessor&);
381 381
382 virtual void emitCode(EmitArgs&) override; 382 virtual void emitCode(EmitArgs&) override;
383 383
384 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der* b) {} 384 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der* b) {}
385 385
386 protected: 386 protected:
387 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 387 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
388 388
389 private: 389 private:
390 UniformHandle fRGBAYValuesUni; 390 UniformHandle fRGBAYValuesUni;
391 typedef GrGLFragmentProcessor INHERITED; 391 typedef GrGLSLFragmentProcessor INHERITED;
392 }; 392 };
393 393
394 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { 394 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) {
395 } 395 }
396 396
397 void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr Processor& proc) { 397 void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr Processor& proc) {
398 // The textures are organized in a strip where the rows are ordered a, r, g, b. 398 // The textures are organized in a strip where the rows are ordered a, r, g, b.
399 float rgbaYValues[4]; 399 float rgbaYValues[4];
400 const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); 400 const ColorTableEffect& cte = proc.cast<ColorTableEffect>();
401 if (cte.atlas()) { 401 if (cte.atlas()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (fAtlas) { 499 if (fAtlas) {
500 fAtlas->unlockRow(fRow); 500 fAtlas->unlockRow(fRow);
501 } 501 }
502 } 502 }
503 503
504 void ColorTableEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 504 void ColorTableEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
505 GrProcessorKeyBuilder* b) const { 505 GrProcessorKeyBuilder* b) const {
506 GLColorTableEffect::GenKey(*this, caps, b); 506 GLColorTableEffect::GenKey(*this, caps, b);
507 } 507 }
508 508
509 GrGLFragmentProcessor* ColorTableEffect::onCreateGLInstance() const { 509 GrGLSLFragmentProcessor* ColorTableEffect::onCreateGLInstance() const {
510 return new GLColorTableEffect(*this); 510 return new GLColorTableEffect(*this);
511 } 511 }
512 512
513 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { 513 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const {
514 // For non-atlased instances, the texture (compared by base class) is suffic ient to 514 // For non-atlased instances, the texture (compared by base class) is suffic ient to
515 // differentiate different tables. For atlased instances we ensure they are using the 515 // differentiate different tables. For atlased instances we ensure they are using the
516 // same row. 516 // same row.
517 const ColorTableEffect& that = other.cast<ColorTableEffect>(); 517 const ColorTableEffect& that = other.cast<ColorTableEffect>();
518 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); 518 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas));
519 // Ok to always do this comparison since both would be -1 if non-atlased. 519 // Ok to always do this comparison since both would be -1 if non-atlased.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], 598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
599 const uint8_t tableR[256], 599 const uint8_t tableR[256],
600 const uint8_t tableG[256], 600 const uint8_t tableG[256],
601 const uint8_t tableB[256]) { 601 const uint8_t tableB[256]) {
602 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); 602 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB);
603 } 603 }
604 604
605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) 605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)
606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) 606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter)
607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698