OLD | NEW |
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 "gl/GrGLFragmentProcessor.h" |
339 #include "gl/builders/GrGLProgramBuilder.h" | 339 #include "gl/builders/GrGLProgramBuilder.h" |
| 340 #include "glsl/GrGLSLProgramDataManager.h" |
340 | 341 |
341 class ColorTableEffect : public GrFragmentProcessor { | 342 class ColorTableEffect : public GrFragmentProcessor { |
342 public: | 343 public: |
343 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap
, unsigned flags); | 344 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap
, unsigned flags); |
344 | 345 |
345 virtual ~ColorTableEffect(); | 346 virtual ~ColorTableEffect(); |
346 | 347 |
347 const char* name() const override { return "ColorTable"; } | 348 const char* name() const override { return "ColorTable"; } |
348 | 349 |
349 const GrTextureStripAtlas* atlas() const { return fAtlas; } | 350 const GrTextureStripAtlas* atlas() const { return fAtlas; } |
(...skipping 25 matching lines...) Expand all Loading... |
375 | 376 |
376 class GLColorTableEffect : public GrGLFragmentProcessor { | 377 class GLColorTableEffect : public GrGLFragmentProcessor { |
377 public: | 378 public: |
378 GLColorTableEffect(const GrProcessor&); | 379 GLColorTableEffect(const GrProcessor&); |
379 | 380 |
380 virtual void emitCode(EmitArgs&) override; | 381 virtual void emitCode(EmitArgs&) override; |
381 | 382 |
382 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der* b) {} | 383 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der* b) {} |
383 | 384 |
384 protected: | 385 protected: |
385 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; | 386 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
386 | 387 |
387 private: | 388 private: |
388 UniformHandle fRGBAYValuesUni; | 389 UniformHandle fRGBAYValuesUni; |
389 typedef GrGLFragmentProcessor INHERITED; | 390 typedef GrGLFragmentProcessor INHERITED; |
390 }; | 391 }; |
391 | 392 |
392 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { | 393 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { |
393 } | 394 } |
394 | 395 |
395 void GLColorTableEffect::onSetData(const GrGLProgramDataManager& pdm, const GrPr
ocessor& proc) { | 396 void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr
Processor& proc) { |
396 // The textures are organized in a strip where the rows are ordered a, r, g,
b. | 397 // The textures are organized in a strip where the rows are ordered a, r, g,
b. |
397 float rgbaYValues[4]; | 398 float rgbaYValues[4]; |
398 const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); | 399 const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); |
399 if (cte.atlas()) { | 400 if (cte.atlas()) { |
400 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight(); | 401 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight(); |
401 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf
* yDelta; | 402 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf
* yDelta; |
402 rgbaYValues[0] = rgbaYValues[3] + yDelta; | 403 rgbaYValues[0] = rgbaYValues[3] + yDelta; |
403 rgbaYValues[1] = rgbaYValues[0] + yDelta; | 404 rgbaYValues[1] = rgbaYValues[0] + yDelta; |
404 rgbaYValues[2] = rgbaYValues[1] + yDelta; | 405 rgbaYValues[2] = rgbaYValues[1] + yDelta; |
405 } else { | 406 } else { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 597 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
597 const uint8_t tableR[256], | 598 const uint8_t tableR[256], |
598 const uint8_t tableG[256], | 599 const uint8_t tableG[256], |
599 const uint8_t tableB[256]) { | 600 const uint8_t tableB[256]) { |
600 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); | 601 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); |
601 } | 602 } |
602 | 603 |
603 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 604 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
604 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 605 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 606 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |