OLD | NEW |
| (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 GrGLProcessor_DEFINED | |
9 #define GrGLProcessor_DEFINED | |
10 | |
11 #include "GrProcessor.h" | |
12 #include "GrShaderVar.h" | |
13 #include "GrTextureAccess.h" | |
14 #include "glsl/GrGLSLProgramDataManager.h" | |
15 | |
16 /** @file | |
17 This file contains specializations for OpenGL of the shader stages declared
in | |
18 include/gpu/GrProcessor.h. Objects of type GrGLProcessor are responsible for
emitting the | |
19 GLSL code that implements a GrProcessor and for uploading uniforms at draw t
ime. If they don't | |
20 always emit the same GLSL code, they must have a function: | |
21 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*) | |
22 that is used to implement a program cache. When two GrProcessors produce the
same key this means | |
23 that their GrGLProcessors would emit the same GLSL code. | |
24 | |
25 The GrGLProcessor subclass must also have a constructor of the form: | |
26 ProcessorSubclass::ProcessorSubclass(const GrBackendProcessorFactory&, c
onst GrProcessor&) | |
27 | |
28 These objects are created by the factory object returned by the GrProcessor:
:getFactory(). | |
29 */ | |
30 // TODO delete this and make TextureSampler its own thing | |
31 class GrGLProcessor { | |
32 public: | |
33 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | |
34 | |
35 /** | |
36 * Passed to GrGLProcessors so they can add transformed coordinates to their
shader code. | |
37 */ | |
38 typedef GrShaderVar TransformedCoords; | |
39 typedef SkTArray<GrShaderVar> TransformedCoordsArray; | |
40 | |
41 /** | |
42 * Passed to GrGLProcessors so they can add texture reads to their shader co
de. | |
43 */ | |
44 class TextureSampler { | |
45 public: | |
46 TextureSampler(UniformHandle uniform, const GrTextureAccess& access) | |
47 : fSamplerUniform(uniform) | |
48 , fConfigComponentMask(GrPixelConfigComponentMask(access.getTexture(
)->config())) { | |
49 SkASSERT(0 != fConfigComponentMask); | |
50 memcpy(fSwizzle, access.getSwizzle(), 5); | |
51 } | |
52 | |
53 // bitfield of GrColorComponentFlags present in the texture's config. | |
54 uint32_t configComponentMask() const { return fConfigComponentMask; } | |
55 // this is .abcd | |
56 const char* swizzle() const { return fSwizzle; } | |
57 | |
58 private: | |
59 UniformHandle fSamplerUniform; | |
60 uint32_t fConfigComponentMask; | |
61 char fSwizzle[5]; | |
62 | |
63 friend class GrGLShaderBuilder; | |
64 }; | |
65 | |
66 typedef SkTArray<TextureSampler> TextureSamplerArray; | |
67 }; | |
68 | |
69 #endif | |
OLD | NEW |