| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
| 9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
| 10 #include "gl/builders/GrGLFullProgramBuilder.h" | 10 #include "gl/builders/GrGLFullProgramBuilder.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 static GrGeometryProcessor* Create() { | 23 static GrGeometryProcessor* Create() { |
| 24 GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gAlignedRectEffect, GrAlignedRectEff
ect, ()); | 24 GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gAlignedRectEffect, GrAlignedRectEff
ect, ()); |
| 25 gAlignedRectEffect->ref(); | 25 gAlignedRectEffect->ref(); |
| 26 return gAlignedRectEffect; | 26 return gAlignedRectEffect; |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual ~GrAlignedRectEffect() {} | 29 virtual ~GrAlignedRectEffect() {} |
| 30 | 30 |
| 31 static const char* Name() { return "AlignedRectEdge"; } | 31 static const char* Name() { return "AlignedRectEdge"; } |
| 32 | 32 |
| 33 virtual void getConstantColorComponents(GrColor* color, |
| 34 uint32_t* validFlags) const SK_OVERR
IDE { |
| 35 *validFlags = 0; |
| 36 } |
| 37 |
| 33 const GrShaderVar& inRect() const { return fInRect; } | 38 const GrShaderVar& inRect() const { return fInRect; } |
| 34 | 39 |
| 35 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 40 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
| 36 return GrTBackendGeometryProcessorFactory<GrAlignedRectEffect>::getInsta
nce(); | 41 return GrTBackendGeometryProcessorFactory<GrAlignedRectEffect>::getInsta
nce(); |
| 37 } | 42 } |
| 38 | 43 |
| 39 class GLProcessor : public GrGLGeometryProcessor { | 44 class GLProcessor : public GrGLGeometryProcessor { |
| 40 public: | 45 public: |
| 41 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) | 46 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) |
| 42 : INHERITED (factory) {} | 47 : INHERITED (factory) {} |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 GrAlignedRectEffect() | 105 GrAlignedRectEffect() |
| 101 : fInRect(this->addVertexAttrib(GrShaderVar("inRect", | 106 : fInRect(this->addVertexAttrib(GrShaderVar("inRect", |
| 102 kVec4f_GrSLType, | 107 kVec4f_GrSLType, |
| 103 GrShaderVar::kAttribute_Type
Modifier))) { | 108 GrShaderVar::kAttribute_Type
Modifier))) { |
| 104 } | 109 } |
| 105 | 110 |
| 106 const GrShaderVar& fInRect; | 111 const GrShaderVar& fInRect; |
| 107 | 112 |
| 108 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} | 113 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} |
| 109 | 114 |
| 110 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { | |
| 111 inout->fValidFlags = 0; | |
| 112 inout->fIsSingleComponent = false; | |
| 113 } | |
| 114 | |
| 115 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 115 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 116 | 116 |
| 117 typedef GrGeometryProcessor INHERITED; | 117 typedef GrGeometryProcessor INHERITED; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 | 120 |
| 121 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrAlignedRectEffect); | 121 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrAlignedRectEffect); |
| 122 | 122 |
| 123 GrGeometryProcessor* GrAlignedRectEffect::TestCreate(SkRandom* random, | 123 GrGeometryProcessor* GrAlignedRectEffect::TestCreate(SkRandom* random, |
| 124 GrContext* context, | 124 GrContext* context, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 148 static GrGeometryProcessor* Create() { | 148 static GrGeometryProcessor* Create() { |
| 149 GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gRectEffect, GrRectEffect, ()); | 149 GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gRectEffect, GrRectEffect, ()); |
| 150 gRectEffect->ref(); | 150 gRectEffect->ref(); |
| 151 return gRectEffect; | 151 return gRectEffect; |
| 152 } | 152 } |
| 153 | 153 |
| 154 virtual ~GrRectEffect() {} | 154 virtual ~GrRectEffect() {} |
| 155 | 155 |
| 156 static const char* Name() { return "RectEdge"; } | 156 static const char* Name() { return "RectEdge"; } |
| 157 | 157 |
| 158 virtual void getConstantColorComponents(GrColor* color, |
| 159 uint32_t* validFlags) const SK_OVERR
IDE { |
| 160 *validFlags = 0; |
| 161 } |
| 162 |
| 158 const GrShaderVar& inRectEdge() const { return fInRectEdge; } | 163 const GrShaderVar& inRectEdge() const { return fInRectEdge; } |
| 159 const GrShaderVar& inWidthHeight() const { return fInWidthHeight; } | 164 const GrShaderVar& inWidthHeight() const { return fInWidthHeight; } |
| 160 | 165 |
| 161 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { | 166 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR
IDE { |
| 162 return GrTBackendGeometryProcessorFactory<GrRectEffect>::getInstance(); | 167 return GrTBackendGeometryProcessorFactory<GrRectEffect>::getInstance(); |
| 163 } | 168 } |
| 164 | 169 |
| 165 class GLProcessor : public GrGLGeometryProcessor { | 170 class GLProcessor : public GrGLGeometryProcessor { |
| 166 public: | 171 public: |
| 167 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) | 172 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&
) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 GrShaderVar::kAttribute_
TypeModifier))) | 250 GrShaderVar::kAttribute_
TypeModifier))) |
| 246 , fInWidthHeight(this->addVertexAttrib( | 251 , fInWidthHeight(this->addVertexAttrib( |
| 247 GrShaderVar("inWidthHeight", | 252 GrShaderVar("inWidthHeight", |
| 248 kVec2f_GrSLType, | 253 kVec2f_GrSLType, |
| 249 GrShaderVar::kAttribute_TypeModifier))) { | 254 GrShaderVar::kAttribute_TypeModifier))) { |
| 250 this->setWillReadFragmentPosition(); | 255 this->setWillReadFragmentPosition(); |
| 251 } | 256 } |
| 252 | 257 |
| 253 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} | 258 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true;
} |
| 254 | 259 |
| 255 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE { | |
| 256 inout->fValidFlags = 0; | |
| 257 inout->fIsSingleComponent = false; | |
| 258 } | |
| 259 | |
| 260 const GrShaderVar& fInRectEdge; | 260 const GrShaderVar& fInRectEdge; |
| 261 const GrShaderVar& fInWidthHeight; | 261 const GrShaderVar& fInWidthHeight; |
| 262 | 262 |
| 263 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 263 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 264 | 264 |
| 265 typedef GrGeometryProcessor INHERITED; | 265 typedef GrGeometryProcessor INHERITED; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 | 268 |
| 269 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRectEffect); | 269 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRectEffect); |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // can't call mapRect for devInside since it calls sort | 963 // can't call mapRect for devInside since it calls sort |
| 964 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 964 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 965 | 965 |
| 966 if (devInside.isEmpty()) { | 966 if (devInside.isEmpty()) { |
| 967 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); | 967 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); |
| 968 return; | 968 return; |
| 969 } | 969 } |
| 970 | 970 |
| 971 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); | 971 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); |
| 972 } | 972 } |
| OLD | NEW |