OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 // This is a GPU-backend specific test. It relies on static intializers to work | 8 // This is a GPU-backend specific test. It relies on static intializers to work |
9 | 9 |
10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrBatchFlushState.h" | 14 #include "GrBatchFlushState.h" |
15 #include "GrDrawContext.h" | 15 #include "GrDrawContext.h" |
16 #include "GrDrawContextPriv.h" | 16 #include "GrDrawContextPriv.h" |
17 #include "GrContext.h" | 17 #include "GrContext.h" |
18 #include "GrGeometryProcessor.h" | 18 #include "GrGeometryProcessor.h" |
19 #include "GrGpu.h" | 19 #include "GrGpu.h" |
20 #include "GrTextureProvider.h" | 20 #include "GrTextureProvider.h" |
21 #include "glsl/GrGLSLGeometryProcessor.h" | 21 #include "glsl/GrGLSLGeometryProcessor.h" |
| 22 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
22 #include "glsl/GrGLSLVarying.h" | 23 #include "glsl/GrGLSLVarying.h" |
23 #include "batches/GrVertexBatch.h" | 24 #include "batches/GrVertexBatch.h" |
24 #include "SkString.h" | 25 #include "SkString.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 class Batch : public GrVertexBatch { | 28 class Batch : public GrVertexBatch { |
28 public: | 29 public: |
29 DEFINE_BATCH_CLASS_ID | 30 DEFINE_BATCH_CLASS_ID |
30 | 31 |
31 const char* name() const override { return "Dummy Batch"; } | 32 const char* name() const override { return "Dummy Batch"; } |
(...skipping 29 matching lines...) Expand all Loading... |
61 } | 62 } |
62 const char* name() const override { return "Dummy GP"; } | 63 const char* name() const override { return "Dummy GP"; } |
63 | 64 |
64 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons
t override { | 65 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons
t override { |
65 class GLSLGP : public GrGLSLGeometryProcessor { | 66 class GLSLGP : public GrGLSLGeometryProcessor { |
66 public: | 67 public: |
67 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 68 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
68 const GP& gp = args.fGP.cast<GP>(); | 69 const GP& gp = args.fGP.cast<GP>(); |
69 args.fVaryingHandler->emitAttributes(gp); | 70 args.fVaryingHandler->emitAttributes(gp); |
70 this->setupPosition(args.fVertBuilder, gpArgs, gp.fAttri
bs[0].fName); | 71 this->setupPosition(args.fVertBuilder, gpArgs, gp.fAttri
bs[0].fName); |
| 72 GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder
; |
| 73 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCo
lor); |
| 74 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCo
verage); |
71 } | 75 } |
72 void setData(const GrGLSLProgramDataManager& pdman, | 76 void setData(const GrGLSLProgramDataManager& pdman, |
73 const GrPrimitiveProcessor& primProc, | 77 const GrPrimitiveProcessor& primProc, |
74 FPCoordTransformIter&&) override {} | 78 FPCoordTransformIter&&) override {} |
75 }; | 79 }; |
76 return new GLSLGP(); | 80 return new GLSLGP(); |
77 } | 81 } |
78 void getGLSLProcessorKey(const GrGLSLCaps&, | 82 void getGLSLProcessorKey(const GrGLSLCaps&, |
79 GrProcessorKeyBuilder* builder) const overr
ide { | 83 GrProcessorKeyBuilder* builder) const overr
ide { |
80 builder->add32(this->numAttribs()); | 84 builder->add32(this->numAttribs()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // This one should fail. | 136 // This one should fail. |
133 batch.reset(new Batch(attribCnt+1)); | 137 batch.reset(new Batch(attribCnt+1)); |
134 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); | 138 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch); |
135 context->flush(); | 139 context->flush(); |
136 #if GR_GPU_STATS | 140 #if GR_GPU_STATS |
137 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); | 141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); |
138 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1)
; | 142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1)
; |
139 #endif | 143 #endif |
140 } | 144 } |
141 #endif | 145 #endif |
OLD | NEW |