tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrCustomStage_DEFINED |
| 9 | #define GrCustomStage_DEFINED |
| 10 | |
tomhudson@google.com | 07eecdc | 2012-04-20 18:35:38 +0000 | [diff] [blame] | 11 | #include "GrRefCnt.h" |
| 12 | |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 13 | class GrContext; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 14 | class GrProgramStageFactory; |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 15 | |
| 16 | /** Provides custom vertex shader, fragment shader, uniform data for a |
| 17 | particular stage of the Ganesh shading pipeline. |
| 18 | TODO: may want to refcount these? */ |
tomhudson@google.com | 07eecdc | 2012-04-20 18:35:38 +0000 | [diff] [blame] | 19 | class GrCustomStage : public GrRefCnt { |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 20 | |
| 21 | public: |
| 22 | |
| 23 | GrCustomStage(); |
| 24 | virtual ~GrCustomStage(); |
| 25 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 26 | /** Human-meaningful string to identify this effect; may be embedded |
| 27 | in generated shader code. */ |
| 28 | virtual const char* name() const = 0; |
| 29 | |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 30 | /** If given an input texture that is/is not opaque, is this |
| 31 | stage guaranteed to produce an opaque output? */ |
| 32 | virtual bool isOpaque(bool inputTextureIsOpaque) const; |
| 33 | |
tomhudson@google.com | 02b1ea2 | 2012-04-30 20:19:07 +0000 | [diff] [blame] | 34 | /** This pointer, besides creating back-end-specific helper |
| 35 | objects, is used for run-time-type-identification. Every |
| 36 | subclass must return a consistent unique value for it. */ |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 37 | virtual GrProgramStageFactory* getFactory() const = 0; |
tomhudson@google.com | b88bbd2 | 2012-05-01 12:48:07 +0000 | [diff] [blame] | 38 | |
| 39 | /** Returns true if the other custom stage will generate |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 40 | equal output. |
| 41 | Must only be called if the two are already known to be of the |
| 42 | same type (i.e. they return the same value from getFactory()). |
| 43 | For equivalence (that they will generate the same |
| 44 | shader, but perhaps have different uniforms), check equality |
| 45 | of the stageKey produced by the GrProgramStageFactory. */ |
| 46 | virtual bool isEqual(const GrCustomStage *) const = 0; |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 47 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 48 | private: |
| 49 | |
| 50 | typedef GrRefCnt INHERITED; |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | #endif |