More threading of GrShaderDataManager
authorjoshualitt <joshualitt@chromium.org>
Wed, 8 Jul 2015 14:58:18 +0000 (07:58 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 8 Jul 2015 14:58:18 +0000 (07:58 -0700)
TBR=bsalomon@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1213613016

13 files changed:
include/core/SkColorFilter.h
include/effects/SkColorCubeFilter.h
include/effects/SkColorMatrixFilter.h
include/effects/SkLumaColorFilter.h
include/effects/SkModeColorFilter.h
src/core/SkColorFilter.cpp
src/effects/SkColorCubeFilter.cpp
src/effects/SkColorFilters.cpp
src/effects/SkColorMatrixFilter.cpp
src/effects/SkLumaColorFilter.cpp
src/effects/SkTableColorFilter.cpp
src/gpu/SkGr.cpp
tests/GpuColorFilterTest.cpp

index 5ba1a8fa44ff4a9643c1e6f8ac9fb11f8951593f..c4109dcdd12dfcd060171d597d95b9788b8bfebb 100644 (file)
@@ -16,6 +16,7 @@
 class SkBitmap;
 class GrProcessor;
 class GrContext;
+class GrShaderDataManager;
 
 /**
  *  ColorFilters are optional objects in the drawing pipeline. When present in
@@ -134,7 +135,8 @@ public:
      *
      *  If the subclass returns false, then it should not modify the array at all.
      */
-    virtual bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const {
+    virtual bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                                      SkTDArray<GrFragmentProcessor*>*) const {
         return false;
     }
 
index 4999bc5777d2fe40d5ffb6b3630c95d72601cb4e..1fc355ed42fdf9578c6dd452a89957d3e007e658 100644 (file)
@@ -25,7 +25,8 @@ public:
     uint32_t getFlags() const override;
 
 #if SK_SUPPORT_GPU
-   bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const override;
+   bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                             SkTDArray<GrFragmentProcessor*>*) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index 47092739f23700bef505a8253823ad41f852b1cb..2dc6b4903d89309a7d72a9150731a5fd67f7be77 100644 (file)
@@ -26,7 +26,8 @@ public:
     SkColorFilter* newComposed(const SkColorFilter*) const override;
 
 #if SK_SUPPORT_GPU
-    bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const override;
+    bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                              SkTDArray<GrFragmentProcessor*>*) const override;
 #endif
 
     struct State {
index 4e8ac798e63148520c201909cc2b557d43ed170f..4cca2d4edecaaec2d11e3e8f54ea85d1c5736c45 100644 (file)
@@ -28,7 +28,8 @@ public:
     void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
 
 #if SK_SUPPORT_GPU
-    bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const override;
+    bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                              SkTDArray<GrFragmentProcessor*>*) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
index a2cb841699fd76307994ab06d08115725b398f32..17f135a28e29d3adb61205ab75e490dfa377b441 100644 (file)
@@ -39,7 +39,8 @@ public:
 #endif
 
 #if SK_SUPPORT_GPU
-    bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const override;
+    bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                              SkTDArray<GrFragmentProcessor*>*) const override;
 #endif
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
 
index 8007271a3fe53d5893de1cae30073dec95ed70d5..a7072324bc4b350e086decca37b4320258b4d08a 100644 (file)
@@ -62,10 +62,10 @@ public:
 #endif
 
 #if SK_SUPPORT_GPU
-    bool asFragmentProcessors(GrContext* context,
+    bool asFragmentProcessors(GrContext* context, GrShaderDataManager* shaderDataManager,
                               SkTDArray<GrFragmentProcessor*>* array) const override {
-        bool hasFrags = fInner->asFragmentProcessors(context, array);
-        hasFrags |= fOuter->asFragmentProcessors(context, array);
+        bool hasFrags = fInner->asFragmentProcessors(context, shaderDataManager, array);
+        hasFrags |= fOuter->asFragmentProcessors(context, shaderDataManager, array);
         return hasFrags;
     }
 #endif
index 8347a9e80f3f71f3fec45db926f9215f8e60c4b1..32bbd2e31751649fdbdf0fbaf0db243b784af847 100644 (file)
@@ -337,7 +337,7 @@ void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc,
                                             const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
 }
 
-bool SkColorCubeFilter::asFragmentProcessors(GrContext* context,
+bool SkColorCubeFilter::asFragmentProcessors(GrContext* context, GrShaderDataManager*,
                                              SkTDArray<GrFragmentProcessor*>* array) const {
     static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
     GrUniqueKey key;
index 1bb9f8fb153b138d64975cffc3b0b6257f41c549..ac3bee0ea68d8a0e5ecf868aac3644be2b19df12 100644 (file)
@@ -362,7 +362,7 @@ GrFragmentProcessor* ModeColorFilterEffect::TestCreate(SkRandom* rand,
     return ModeColorFilterEffect::Create(color, mode);
 }
 
-bool SkModeColorFilter::asFragmentProcessors(GrContext*,
+bool SkModeColorFilter::asFragmentProcessors(GrContext*, GrShaderDataManager*,
                                              SkTDArray<GrFragmentProcessor*>* array) const {
     if (SkXfermode::kDst_Mode != fMode) {
         GrFragmentProcessor* frag = ModeColorFilterEffect::Create(SkColor2GrColor(fColor), fMode);
index 78d4797e44c9bce37bd3cfa8e16c2d5241dd3279..6401aaa55f0344ddb3ede1bd24e9843de1000c62 100644 (file)
@@ -542,7 +542,7 @@ GrFragmentProcessor* ColorMatrixEffect::TestCreate(SkRandom* random,
     return ColorMatrixEffect::Create(colorMatrix);
 }
 
-bool SkColorMatrixFilter::asFragmentProcessors(GrContext*,
+bool SkColorMatrixFilter::asFragmentProcessors(GrContext*, GrShaderDataManager*,
                                                SkTDArray<GrFragmentProcessor*>* array) const {
     GrFragmentProcessor* frag = ColorMatrixEffect::Create(fMatrix);
     if (frag) {
index 13bb6cbd9ea5f778b1c8733e57ff2a52b5a9e6b6..021c3c1090c6ac56fd58c24a26faa9931608502d 100644 (file)
@@ -119,7 +119,7 @@ private:
     }
 };
 
-bool SkLumaColorFilter::asFragmentProcessors(GrContext*,
+bool SkLumaColorFilter::asFragmentProcessors(GrContext*, GrShaderDataManager*,
                                              SkTDArray<GrFragmentProcessor*>* array) const {
 
     GrFragmentProcessor* frag = LumaColorFilterEffect::Create();
index 839b014c68c5bdf60fb5c3d5afe4068092cbc242..e4bc778a8e974477576e0528dc936494ef42dc23 100644 (file)
@@ -50,7 +50,8 @@ public:
     SkColorFilter* newComposed(const SkColorFilter* inner) const override;
 
 #if SK_SUPPORT_GPU
-    bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) const override;
+    bool asFragmentProcessors(GrContext*, GrShaderDataManager*,
+                              SkTDArray<GrFragmentProcessor*>*) const override;
 #endif
 
     void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const override;
@@ -576,7 +577,8 @@ GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random,
     ));
 
     SkTDArray<GrFragmentProcessor*> array;
-    if (filter->asFragmentProcessors(context, &array)) {
+    GrPaint grPaint;
+    if (filter->asFragmentProcessors(context, grPaint.getShaderDataManager(), &array)) {
         SkASSERT(1 == array.count());   // TableColorFilter only returns 1
         return array[0];
     }
@@ -584,6 +586,7 @@ GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random,
 }
 
 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context,
+                                               GrShaderDataManager*,
                                                SkTDArray<GrFragmentProcessor*>* array) const {
     SkBitmap bitmap;
     this->asComponentTable(&bitmap);
index 4c71093e44f2c4afba6df40ef3ee87b9272a7851..b7568c3ba64f8c4fd321a451b739fda3ca6d8104 100644 (file)
@@ -720,7 +720,8 @@ bool SkPaint2GrPaintNoShader(GrContext* context, GrRenderTarget* rt, const SkPai
         } else {
             SkTDArray<GrFragmentProcessor*> array;
             // return false if failed?
-            if (colorFilter->asFragmentProcessors(context, &array)) {
+            if (colorFilter->asFragmentProcessors(context, grPaint->getShaderDataManager(),
+                                                  &array)) {
                 for (int i = 0; i < array.count(); ++i) {
                     grPaint->addColorProcessor(array[i]);
                     array[i]->unref();
index 037734eebcf5d1063f01af2f52dce778657aff5e..3d7f89ed53b93d6d4648fe9c4bb0cf3fe8ec7c5e 100644 (file)
@@ -6,15 +6,16 @@
  * found in the LICENSE file.
  */
 
+#include "SkColorFilter.h"
+#include "Test.h"
+
 #if SK_SUPPORT_GPU
 
 #include "GrContext.h"
 #include "GrContextFactory.h"
 #include "GrFragmentProcessor.h"
 #include "GrInvariantOutput.h"
-#include "SkColorFilter.h"
 #include "SkGr.h"
-#include "Test.h"
 
 static GrColor filterColor(const GrColor& color, uint32_t flags)  {
     uint32_t mask = 0;
@@ -96,11 +97,12 @@ static void test_getConstantColorComponents(skiatest::Reporter* reporter, GrCont
         { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode::kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) }
     };
 
+    GrPaint paint;
     for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
         const GetConstantComponentTestCase& test = filterTests[i];
         SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filterColor, test.filterMode));
         SkTDArray<GrFragmentProcessor*> array;
-        bool hasFrag = cf->asFragmentProcessors(grContext, &array);
+        bool hasFrag = cf->asFragmentProcessors(grContext, paint.getShaderDataManager(), &array);
         REPORTER_ASSERT(reporter, hasFrag);
         REPORTER_ASSERT(reporter, 1 == array.count());
         GrInvariantOutput inout(test.inputColor,