Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: include/gpu/GrTBackendProcessorFactory.h

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: fix Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 GrTBackendProcessorFactory_DEFINED
9 #define GrTBackendProcessorFactory_DEFINED
10
11 #include "GrBackendProcessorFactory.h"
12 #include "gl/GrGLProgramEffects.h"
13
14 /**
15 * Implements GrBackendEffectFactory for a GrProcessor subclass as a singleton. This can be used by
16 * most GrProcessor subclasses to implement the GrProcessor::getFactory() method :
17 *
18 * const GrBackendEffectFactory& MyEffect::getFactory() const {
19 * return GrTBackendEffectFactory<MyEffect>::getInstance();
20 * }
21 *
22 * Using this class requires that the GrProcessor subclass always produces the s ame GrGLProcessor
23 * subclass. Additionally, It adds the following requirements to the GrProcessor and GrGLProcessor
bsalomon 2014/09/22 14:56:38 Probably my typo originally, but "It" shouldn't be
24 * subclasses:
25 *
26 * 1. The GrGLProcessor used by GrProcessor subclass MyEffect must be named or t ypedef'ed to
27 * MyEffect::GLProcessor.
28 * 2. MyEffect::GLProcessor must have a static function:
29 * EffectKey GenKey(const GrProcessor, const GrGLCaps&)
30 * which generates a key that maps 1 to 1 with code variations emitted by
31 * MyEffect::GLProcessor::emitCode().
32 * 3. MyEffect must have a static function:
33 * const char* Name()
34 * which returns a human-readable name for the effect.
35 */
36 template <class ProcessorClass, class BackEnd, class ProcessorBase, class GLProc essorBase>
37 class GrTBackendProcessorFactory : public BackEnd {
38 public:
39 typedef typename ProcessorClass::GLProcessor GLProcessor;
40
41 /** Returns a human-readable name for the effect. Implemented using GLProces sor::Name as
42 * described in this class's comment. */
43 virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name() ; }
44
45
46 /** Implemented using GLProcessor::GenKey as described in this class's comme nt. */
47 virtual void getGLProcessorKey(const GrProcessor& effect,
48 const GrGLCaps& caps,
49 GrProcessorKeyBuilder* b) const SK_OVERRIDE {
50 GLProcessor::GenKey(effect, caps, b);
51 }
52
53 /** Returns a new instance of the appropriate *GL* implementation class
54 for the given GrProcessor; caller is responsible for deleting
55 the object. */
56 virtual GLProcessorBase* createGLInstance(const ProcessorBase& effect) const SK_OVERRIDE {
57 return SkNEW_ARGS(GLProcessor, (*this, effect));
58 }
59
60 /** This class is a singleton. This function returns the single instance. */
61 static const BackEnd& getInstance() {
62 static SkAlignedSTStorage<1, GrTBackendProcessorFactory> gInstanceMem;
63 static const GrTBackendProcessorFactory* gInstance;
64 if (!gInstance) {
65 gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
66 GrTBackendProcessorFactory);
67 }
68 return *gInstance;
69 }
70
71 protected:
72 GrTBackendProcessorFactory() {}
73 };
74
75 /*
76 * every effect so far derives from one of the following subclasses of GrTBacken dProcessorFactory
bsalomon 2014/09/22 14:56:38 Capitalize "Every", period at end of sentence? So
77 * All of this machinery is necessary to ensure that creatGLInstace is typesafe and does not
78 * require any casting
79 */
80 template <class ProcessorClass>
81 class GrTBackendGeometryProcessorFactory
bsalomon 2014/09/22 14:56:38 Maybe the GP variant should be somewhere under src
joshua.litt 2014/09/22 18:14:44 Yes, I will follow up and move GrProcessorStage to
82 : public GrTBackendProcessorFactory<ProcessorClass,
83 GrBackendGeometryProcessorFactory,
84 GrGeometryProcessor,
85 GrGLGeometryProcessor> {
86 protected:
87 GrTBackendGeometryProcessorFactory() {}
88 };
89
90 template <class ProcessorClass>
91 class GrTBackendFragmentProcessorFactory
92 : public GrTBackendProcessorFactory<ProcessorClass,
93 GrBackendFragmentProcessorFactory,
94 GrFragmentProcessor,
95 GrGLFragmentProcessor> {
96 protected:
97 GrTBackendFragmentProcessorFactory() {}
98 };
99
100
101 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698