OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 #ifndef GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 class GrVertexBuffer; | 42 class GrVertexBuffer; |
43 class GrVertexBufferAllocPool; | 43 class GrVertexBufferAllocPool; |
44 class GrStrokeInfo; | 44 class GrStrokeInfo; |
45 class GrSoftwarePathRenderer; | 45 class GrSoftwarePathRenderer; |
46 class SkStrokeRec; | 46 class SkStrokeRec; |
47 | 47 |
48 class SK_API GrContext : public SkRefCnt { | 48 class SK_API GrContext : public SkRefCnt { |
49 public: | 49 public: |
50 SK_DECLARE_INST_COUNT(GrContext) | 50 SK_DECLARE_INST_COUNT(GrContext) |
51 | 51 |
52 struct Options { | |
53 Options() | |
54 : fDrawPathToCompressedTexture(false) | |
55 { } | |
56 | |
57 // EXPERIMENTAL | |
58 // May be removed in the future, or may become standard depending | |
59 // on the outcomes of a variety of internal tests. | |
60 bool fDrawPathToCompressedTexture; | |
61 }; | |
62 | |
52 /** | 63 /** |
53 * Creates a GrContext for a backend context. | 64 * Creates a GrContext for a backend context. |
54 */ | 65 */ |
55 static GrContext* Create(GrBackend, GrBackendContext); | 66 static GrContext* Create(GrBackend, GrBackendContext, const Options* opts = NULL); |
56 | 67 |
57 virtual ~GrContext(); | 68 virtual ~GrContext(); |
58 | 69 |
59 /** | 70 /** |
60 * The GrContext normally assumes that no outsider is setting state | 71 * The GrContext normally assumes that no outsider is setting state |
61 * within the underlying 3D API's context/device/whatever. This call informs | 72 * within the underlying 3D API's context/device/whatever. This call informs |
62 * the context that the state was modified and it should resend. Shouldn't | 73 * the context that the state was modified and it should resend. Shouldn't |
63 * be called frequently for good performance. | 74 * be called frequently for good performance. |
64 * The flag bits, state, is dpendent on which backend is used by the | 75 * The flag bits, state, is dpendent on which backend is used by the |
65 * context, either GL or D3D (possible in future). | 76 * context, either GL or D3D (possible in future). |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
932 GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt); | 943 GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt); |
933 | 944 |
934 GrPathRenderer* getPathRenderer( | 945 GrPathRenderer* getPathRenderer( |
935 const SkPath& path, | 946 const SkPath& path, |
936 const SkStrokeRec& stroke, | 947 const SkStrokeRec& stroke, |
937 const GrDrawTarget* target, | 948 const GrDrawTarget* target, |
938 bool allowSW, | 949 bool allowSW, |
939 GrPathRendererChain::DrawType drawType = GrPathRendererChain ::kColor_DrawType, | 950 GrPathRendererChain::DrawType drawType = GrPathRendererChain ::kColor_DrawType, |
940 GrPathRendererChain::StencilSupport* stencilSupport = NULL); | 951 GrPathRendererChain::StencilSupport* stencilSupport = NULL); |
941 | 952 |
953 /** | |
954 * This returns true if the underlying graphics device and system is | |
bsalomon
2014/08/11 20:51:32
update comment?
| |
955 * capable of drawing paths to compressed textures. This generally provides | |
956 * a speedup on mobile devices with advanced GPUs, but it only gets turned | |
957 * on when there is a clear speedup benefit. | |
958 */ | |
959 const Options& getOptions() const { return fOptions; } | |
960 | |
942 #if GR_CACHE_STATS | 961 #if GR_CACHE_STATS |
943 void printCacheStats() const; | 962 void printCacheStats() const; |
944 #endif | 963 #endif |
945 | 964 |
946 private: | 965 private: |
947 // Used to indicate whether a draw should be performed immediately or queued in fDrawBuffer. | 966 // Used to indicate whether a draw should be performed immediately or queued in fDrawBuffer. |
948 enum BufferedDraw { | 967 enum BufferedDraw { |
949 kYes_BufferedDraw, | 968 kYes_BufferedDraw, |
950 kNo_BufferedDraw, | 969 kNo_BufferedDraw, |
951 }; | 970 }; |
(...skipping 28 matching lines...) Expand all Loading... | |
980 | 999 |
981 struct CleanUpData { | 1000 struct CleanUpData { |
982 PFCleanUpFunc fFunc; | 1001 PFCleanUpFunc fFunc; |
983 void* fInfo; | 1002 void* fInfo; |
984 }; | 1003 }; |
985 | 1004 |
986 SkTDArray<CleanUpData> fCleanUpData; | 1005 SkTDArray<CleanUpData> fCleanUpData; |
987 | 1006 |
988 int fMaxTextureSizeOverride; | 1007 int fMaxTextureSizeOverride; |
989 | 1008 |
990 GrContext(); // init must be called after the constructor. | 1009 const Options fOptions; |
1010 | |
1011 GrContext(const Options&); // init must be called after the constructor. | |
991 bool init(GrBackend, GrBackendContext); | 1012 bool init(GrBackend, GrBackendContext); |
992 | 1013 |
993 void setupDrawBuffer(); | 1014 void setupDrawBuffer(); |
994 | 1015 |
995 class AutoRestoreEffects; | 1016 class AutoRestoreEffects; |
996 class AutoCheckFlush; | 1017 class AutoCheckFlush; |
997 /// Sets the paint and returns the target to draw into. The paint can be NUL L in which case the | 1018 /// Sets the paint and returns the target to draw into. The paint can be NUL L in which case the |
998 /// draw state is left unmodified. | 1019 /// draw state is left unmodified. |
999 GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw, AutoRestoreEffects *, AutoCheckFlush*); | 1020 GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw, AutoRestoreEffects *, AutoCheckFlush*); |
1000 | 1021 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 } | 1148 } |
1128 | 1149 |
1129 GrTexture* texture() { return fTexture; } | 1150 GrTexture* texture() { return fTexture; } |
1130 | 1151 |
1131 private: | 1152 private: |
1132 GrContext* fContext; | 1153 GrContext* fContext; |
1133 GrTexture* fTexture; | 1154 GrTexture* fTexture; |
1134 }; | 1155 }; |
1135 | 1156 |
1136 #endif | 1157 #endif |
OLD | NEW |