blob: 64bcce303627421f41d571a53a0c65ce1f4795a2 [file] [log] [blame]
tomhudson@google.com168e6342012-04-18 17:49:20 +00001/*
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.com07eecdc2012-04-20 18:35:38 +000011#include "GrRefCnt.h"
12
tomhudson@google.com168e6342012-04-18 17:49:20 +000013class GrContext;
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000014class GrProgramStageFactory;
tomhudson@google.com168e6342012-04-18 17:49:20 +000015
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.com07eecdc2012-04-20 18:35:38 +000019class GrCustomStage : public GrRefCnt {
tomhudson@google.com168e6342012-04-18 17:49:20 +000020
21public:
22
23 GrCustomStage();
24 virtual ~GrCustomStage();
25
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000026 /** 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.com168e6342012-04-18 17:49:20 +000030 /** 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.com02b1ea22012-04-30 20:19:07 +000034 /** 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.comd8f856c2012-05-10 12:13:36 +000037 virtual GrProgramStageFactory* getFactory() const = 0;
tomhudson@google.comb88bbd22012-05-01 12:48:07 +000038
39 /** Returns true if the other custom stage will generate
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000040 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.com168e6342012-04-18 17:49:20 +000047
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000048private:
49
50 typedef GrRefCnt INHERITED;
tomhudson@google.com168e6342012-04-18 17:49:20 +000051};
52
53#endif