blob: 5b33e0e47fdf0101239f4969301a62027b721ba8 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@google.comac10a2d2010-12-22 21:39:39 +000010#ifndef GrGpuGL_DEFINED
11#define GrGpuGL_DEFINED
12
bsalomon@google.comc1d2a582012-06-01 15:08:19 +000013#include "GrBinHashKey.h"
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000014#include "GrDrawState.h"
15#include "GrGpu.h"
bsalomon@google.com89ec61e2012-02-10 20:05:18 +000016#include "GrGLContextInfo.h"
bsalomon@google.com4043ae22011-08-02 14:19:11 +000017#include "GrGLIndexBuffer.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000018#include "GrGLIRect.h"
bsalomon@google.com5739d2c2012-05-31 15:07:19 +000019#include "GrGLProgram.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000020#include "GrGLStencilBuffer.h"
21#include "GrGLTexture.h"
22#include "GrGLVertexBuffer.h"
bsalomon@google.comc1d2a582012-06-01 15:08:19 +000023#include "../GrTHashCache.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000024
25class GrGpuGL : public GrGpu {
26public:
bsalomon@google.com5739d2c2012-05-31 15:07:19 +000027 GrGpuGL(const GrGLContextInfo& ctxInfo);
reed@google.comac10a2d2010-12-22 21:39:39 +000028 virtual ~GrGpuGL();
29
bsalomon@google.com89ec61e2012-02-10 20:05:18 +000030 const GrGLInterface* glInterface() const {
31 return fGLContextInfo.interface();
32 }
tomhudson@google.comdd182cb2012-02-10 21:01:00 +000033 GrGLBinding glBinding() const { return fGLContextInfo.binding(); }
34 GrGLVersion glVersion() const { return fGLContextInfo.version(); }
35 GrGLSLGeneration glslGeneration() const {
bsalomon@google.com89ec61e2012-02-10 20:05:18 +000036 return fGLContextInfo.glslGeneration();
37 }
bsalomon@google.com0b77d682011-08-19 13:28:54 +000038
bsalomon@google.com56d11e02011-11-30 19:59:08 +000039 // GrGpu overrides
bsalomon@google.com0a97be22011-11-08 19:20:57 +000040 virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig config)
bsalomon@google.com56d11e02011-11-30 19:59:08 +000041 const SK_OVERRIDE;
bsalomon@google.coma85449d2011-11-19 02:36:05 +000042 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig config)
bsalomon@google.com56d11e02011-11-30 19:59:08 +000043 const SK_OVERRIDE;
bsalomon@google.comc4364992011-11-07 15:54:49 +000044 virtual bool readPixelsWillPayForYFlip(
45 GrRenderTarget* renderTarget,
46 int left, int top,
47 int width, int height,
48 GrPixelConfig config,
bsalomon@google.com56d11e02011-11-30 19:59:08 +000049 size_t rowBytes) const SK_OVERRIDE;
50 virtual bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE;
bsalomon@google.com75f9f252012-01-31 13:35:56 +000051
bsalomon@google.coma91e9232012-02-23 15:39:54 +000052 virtual bool canPreserveReadWriteUnpremulPixels() SK_OVERRIDE;
53
bsalomon@google.com5739d2c2012-05-31 15:07:19 +000054 virtual void abandonResources() SK_OVERRIDE;
55
56 bool programUnitTest();
57
bsalomon@google.com49209392012-06-05 15:13:46 +000058
bsalomon@google.com88939ae2011-12-14 15:58:11 +000059protected:
bsalomon@google.com1c13c962011-02-14 16:51:21 +000060 // GrGpu overrides
bsalomon@google.com1bf1c212011-11-05 12:18:58 +000061 virtual void onResetContext() SK_OVERRIDE;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000062
bsalomon@google.comfea37b52011-04-25 15:51:06 +000063 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc,
bsalomon@google.combcdbbe62011-04-12 15:40:00 +000064 const void* srcData,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000065 size_t rowBytes) SK_OVERRIDE;
bsalomon@google.combcdbbe62011-04-12 15:40:00 +000066 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000067 bool dynamic) SK_OVERRIDE;
bsalomon@google.combcdbbe62011-04-12 15:40:00 +000068 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000069 bool dynamic) SK_OVERRIDE;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000070 virtual GrPath* onCreatePath(const SkPath&) SK_OVERRIDE;
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000071 virtual GrTexture* onCreatePlatformTexture(
72 const GrPlatformTextureDesc& desc) SK_OVERRIDE;
73 virtual GrRenderTarget* onCreatePlatformRenderTarget(
74 const GrPlatformRenderTargetDesc& desc) SK_OVERRIDE;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000075 virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000076 int width,
77 int height) SK_OVERRIDE;
78 virtual bool attachStencilBufferToRenderTarget(
79 GrStencilBuffer* sb,
80 GrRenderTarget* rt) SK_OVERRIDE;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000081
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000082 virtual void onClear(const GrIRect* rect, GrColor color) SK_OVERRIDE;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000083
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +000084 virtual void onForceRenderTargetFlush() SK_OVERRIDE;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000085
bsalomon@google.com5877ffd2011-04-11 17:58:48 +000086 virtual bool onReadPixels(GrRenderTarget* target,
bsalomon@google.comc6980972011-11-02 19:57:21 +000087 int left, int top,
88 int width, int height,
89 GrPixelConfig,
bsalomon@google.comc4364992011-11-07 15:54:49 +000090 void* buffer,
91 size_t rowBytes,
92 bool invertY) SK_OVERRIDE;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000093
bsalomon@google.com6f379512011-11-16 20:36:03 +000094 virtual void onWriteTexturePixels(GrTexture* texture,
95 int left, int top, int width, int height,
96 GrPixelConfig config, const void* buffer,
97 size_t rowBytes) SK_OVERRIDE;
98
bsalomon@google.com75f9f252012-01-31 13:35:56 +000099 virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE;
100
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000101 virtual void onGpuDrawIndexed(GrPrimitiveType type,
102 uint32_t startVertex,
103 uint32_t startIndex,
104 uint32_t vertexCount,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000105 uint32_t indexCount) SK_OVERRIDE;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000106 virtual void onGpuDrawNonIndexed(GrPrimitiveType type,
107 uint32_t vertexCount,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000108 uint32_t numVertices) SK_OVERRIDE;
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000109
110 virtual void setStencilPathSettings(const GrPath&,
111 GrPathFill,
112 GrStencilSettings* settings)
113 SK_OVERRIDE;
114 virtual void onGpuStencilPath(const GrPath*, GrPathFill) SK_OVERRIDE;
robertphillips@google.com730ebe52012-04-16 16:33:13 +0000115
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000116 virtual void clearStencil() SK_OVERRIDE;
117 virtual void clearStencilClip(const GrIRect& rect,
118 bool insideClip) SK_OVERRIDE;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000119 virtual bool flushGraphicsState(DrawType) SK_OVERRIDE;
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000120 virtual void setupGeometry(int* startVertex,
121 int* startIndex,
122 int vertexCount,
123 int indexCount) SK_OVERRIDE;
124
bsalomon@google.com49209392012-06-05 15:13:46 +0000125private:
126
127 const GrGLCaps& glCaps() const { return fGLContextInfo.caps(); }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000128
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000129 // binds texture unit in GL
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000130 void setTextureUnit(int unitIdx);
reed@google.comac10a2d2010-12-22 21:39:39 +0000131
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000132 // binds appropriate vertex and index buffers, also returns any extra
133 // extra verts or indices to offset by.
134 void setBuffers(bool indexed,
135 int* extraVertexOffset,
136 int* extraIndexOffset);
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000137
bsalomon@google.com86c1f712011-10-12 14:54:26 +0000138 // Subclasses should call this to flush the blend state.
139 // The params should be the final coeffecients to apply
140 // (after any blending optimizations or dual source blending considerations
141 // have been accounted for).
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000142 void flushBlend(bool isLines,
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000143 GrBlendCoeff srcCoeff,
144 GrBlendCoeff dstCoeff);
145
bsalomon@google.com89ec61e2012-02-10 20:05:18 +0000146 bool hasExtension(const char* ext) const {
147 return fGLContextInfo.hasExtension(ext);
bsalomon@google.com96399942012-02-13 14:39:16 +0000148 }
149
150 const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; }
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +0000151
bsalomon@google.com99621082011-11-15 16:47:16 +0000152 // adjusts texture matrix to account for orientation
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000153 static void AdjustTextureMatrix(const GrGLTexture* texture,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000154 GrMatrix* matrix);
bsalomon@google.com88939ae2011-12-14 15:58:11 +0000155
156 // subclass may try to take advantage of identity tex matrices.
157 // This helper determines if matrix will be identity after all
158 // adjustments are applied.
159 static bool TextureMatrixIsIdentity(const GrGLTexture* texture,
160 const GrSamplerState& sampler);
161
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000162 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
bsalomon@google.com080773c2011-03-15 19:09:25 +0000163
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000164 // for readability of function impls
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000165 typedef GrGLProgram::Desc ProgramDesc;
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000166 typedef ProgramDesc::StageDesc StageDesc;
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000167
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000168 class ProgramCache : public ::GrNoncopyable {
169 public:
170 ProgramCache(const GrGLContextInfo& gl);
171 ~ProgramCache();
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000172
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000173 void abandon();
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000174 GrGLProgram* getProgram(const GrGLProgram::Desc& desc, GrCustomStage** stages);
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000175 private:
176 enum {
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000177 kKeySize = sizeof(ProgramDesc),
178 // We may actually have kMaxEntries+1 shaders in the GL context because we create a new
179 // shader before evicting from the cache.
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000180 kMaxEntries = 32
181 };
182
183 class Entry;
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000184 // The value of the hash key is based on the ProgramDesc.
185 typedef GrTBinHashKey<Entry, kKeySize> ProgramHashKey;
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000186
187 class Entry : public ::GrNoncopyable {
188 public:
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000189 Entry() : fProgram(NULL), fLRUStamp(0) {}
190 Entry& operator = (const Entry& entry) {
191 GrSafeRef(entry.fProgram.get());
192 fProgram.reset(entry.fProgram.get());
193 fKey = entry.fKey;
194 fLRUStamp = entry.fLRUStamp;
195 return *this;
196 }
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000197 int compare(const ProgramHashKey& key) const {
198 return fKey.compare(key);
199 }
200
201 public:
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000202 SkAutoTUnref<GrGLProgram> fProgram;
203 ProgramHashKey fKey;
204 unsigned int fLRUStamp; // Move outside entry?
bsalomon@google.comc1d2a582012-06-01 15:08:19 +0000205 };
206
207 GrTHashTable<Entry, ProgramHashKey, 8> fHashCache;
208
209 Entry fEntries[kMaxEntries];
210 int fCount;
211 unsigned int fCurrLRUStamp;
212 const GrGLContextInfo& fGL;
213 };
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000214
bsalomon@google.com4c883782012-06-04 19:05:11 +0000215 // binds the texture and sets its texture params
bsalomon@google.coma3201942012-06-21 19:58:20 +0000216 // This may also perform a downsample on the src texture which may or may
217 // not modify the scissor test and rect. So in flushGraphicsState a
218 // call to flushScissor must occur after all textures have been flushed via
219 // this function.
bsalomon@google.com4c883782012-06-04 19:05:11 +0000220 void flushBoundTextureAndParams(int stage);
tomhudson@google.comd0c1a062012-07-12 17:23:52 +0000221 void flushBoundTextureAndParams(int stage, GrGLTexture* nextTexture);
bsalomon@google.com4c883782012-06-04 19:05:11 +0000222
bsalomon@google.com890e3b52012-06-01 19:01:37 +0000223 // sets the texture matrix and domain for the currently bound program
224 void flushTextureMatrixAndDomain(int stage);
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000225
226 // sets the color specified by GrDrawState::setColor()
227 void flushColor(GrColor color);
228
229 // sets the color specified by GrDrawState::setCoverage()
230 void flushCoverage(GrColor color);
231
232 // sets the MVP matrix uniform for currently bound program
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000233 void flushViewMatrix(DrawType type);
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000234
235 // flushes the parameters to two point radial gradient
236 void flushRadial2(int stage);
237
238 // flushes the parameters for convolution
239 void flushConvolution(int stage);
240
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000241 // flushes the color matrix
242 void flushColorMatrix();
243
bsalomon@google.comc96cb3a2012-06-04 19:31:00 +0000244 // flushes dithering, color-mask, and face culling stat
245 void flushMiscFixedFunctionState();
246
bsalomon@google.coma3201942012-06-21 19:58:20 +0000247 // flushes the scissor. see the note on flushBoundTextureAndParams about
248 // flushing the scissor after that function is called.
249 void flushScissor();
250
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000251 static void DeleteProgram(const GrGLInterface* gl, GrGLProgram* programData);
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000252
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000253 void buildProgram(bool isPoints,
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000254 BlendOptFlags blendOpts,
255 GrBlendCoeff dstCoeff,
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000256 GrCustomStage** customStages,
257 ProgramDesc* desc);
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000258
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000259 // Inits GrDrawTarget::Caps, sublcass may enable additional caps.
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000260 void initCaps();
261
262 void initFSAASupport();
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000263
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +0000264 // determines valid stencil formats
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000265 void initStencilFormats();
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +0000266
reed@google.comac10a2d2010-12-22 21:39:39 +0000267 // notify callbacks to update state tracking when related
268 // objects are bound to GL or deleted outside of the class
269 void notifyVertexBufferBind(const GrGLVertexBuffer* buffer);
270 void notifyVertexBufferDelete(const GrGLVertexBuffer* buffer);
271 void notifyIndexBufferBind(const GrGLIndexBuffer* buffer);
272 void notifyIndexBufferDelete(const GrGLIndexBuffer* buffer);
reed@google.comac10a2d2010-12-22 21:39:39 +0000273 void notifyTextureDelete(GrGLTexture* texture);
274 void notifyRenderTargetDelete(GrRenderTarget* renderTarget);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000275
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000276 void setSpareTextureUnit();
reed@google.comac10a2d2010-12-22 21:39:39 +0000277
bsalomon@google.com8295dc12011-05-02 12:53:34 +0000278 // bound is region that may be modified and therefore has to be resolved.
279 // NULL means whole target. Can be an empty rect.
280 void flushRenderTarget(const GrIRect* bound);
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000281 void flushStencil(DrawType);
282 void flushAAState(DrawType);
bsalomon@google.com0650e812011-04-08 18:07:53 +0000283
bsalomon@google.com280e99f2012-01-05 16:17:38 +0000284 bool configToGLFormats(GrPixelConfig config,
285 bool getSizedInternal,
286 GrGLenum* internalFormat,
287 GrGLenum* externalFormat,
288 GrGLenum* externalType);
bsalomon@google.com6f379512011-11-16 20:36:03 +0000289 // helper for onCreateTexture and writeTexturePixels
bsalomon@google.com136f55b2011-11-28 18:34:44 +0000290 bool uploadTexData(const GrGLTexture::Desc& desc,
bsalomon@google.com1e0e6072011-11-28 18:49:37 +0000291 bool isNewTexture,
bsalomon@google.com6f379512011-11-16 20:36:03 +0000292 int left, int top, int width, int height,
293 GrPixelConfig dataConfig,
294 const void* data,
295 size_t rowBytes);
bsalomon@google.com0650e812011-04-08 18:07:53 +0000296
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000297 bool createRenderTargetObjects(int width, int height,
298 GrGLuint texID,
299 GrGLRenderTarget::Desc* desc);
300
robertphillips@google.com99a5ac02012-04-10 19:26:38 +0000301 void fillInConfigRenderableTable();
302
reed@google.comac10a2d2010-12-22 21:39:39 +0000303 friend class GrGLVertexBuffer;
304 friend class GrGLIndexBuffer;
305 friend class GrGLTexture;
306 friend class GrGLRenderTarget;
307
bsalomon@google.com89ec61e2012-02-10 20:05:18 +0000308 GrGLContextInfo fGLContextInfo;
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +0000309
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000310 // GL program-related state
311 ProgramCache* fProgramCache;
bsalomon@google.com9ba4fa62012-07-16 17:36:28 +0000312 SkAutoTUnref<GrGLProgram> fCurrentProgram;
bsalomon@google.com49209392012-06-05 15:13:46 +0000313
314 ///////////////////////////////////////////////////////////////////////////
315 ///@name Caching of GL State
316 ///@{
317 int fHWActiveTextureUnitIdx;
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000318 GrGLuint fHWProgramID;
319 GrColor fHWConstAttribColor;
320 GrColor fHWConstAttribCoverage;
bsalomon@google.com5739d2c2012-05-31 15:07:19 +0000321
bsalomon@google.com49209392012-06-05 15:13:46 +0000322 enum TriState {
323 kNo_TriState,
324 kYes_TriState,
325 kUnknown_TriState
326 };
327
bsalomon@google.coma3201942012-06-21 19:58:20 +0000328 // last scissor / viewport scissor state seen by the GL.
329 struct {
330 TriState fEnabled;
331 GrGLIRect fRect;
332 void invalidate() {
333 fEnabled = kUnknown_TriState;
334 fRect.invalidate();
335 }
336 } fHWScissorSettings;
337
338 GrGLIRect fHWViewport;
339
bsalomon@google.com49209392012-06-05 15:13:46 +0000340 struct {
341 size_t fVertexOffset;
342 GrVertexLayout fVertexLayout;
343 const GrVertexBuffer* fVertexBuffer;
344 const GrIndexBuffer* fIndexBuffer;
345 bool fArrayPtrsDirty;
346 } fHWGeometryState;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000347
bsalomon@google.coma4d8fc22012-05-21 13:21:46 +0000348 struct {
349 GrBlendCoeff fSrcCoeff;
350 GrBlendCoeff fDstCoeff;
351 GrColor fConstColor;
352 bool fConstColorValid;
353 TriState fEnabled;
354
355 void invalidate() {
bsalomon@google.com47059542012-06-06 20:51:20 +0000356 fSrcCoeff = kInvalid_GrBlendCoeff;
357 fDstCoeff = kInvalid_GrBlendCoeff;
bsalomon@google.coma4d8fc22012-05-21 13:21:46 +0000358 fConstColorValid = false;
359 fEnabled = kUnknown_TriState;
360 }
361 } fHWBlendState;
362
bsalomon@google.com4d5f3fe2012-05-21 17:11:44 +0000363 struct {
364 TriState fMSAAEnabled;
365 TriState fSmoothLineEnabled;
366 void invalidate() {
367 fMSAAEnabled = kUnknown_TriState;
368 fSmoothLineEnabled = kUnknown_TriState;
369 }
370 } fHWAAState;
371
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000372 struct {
373 GrMatrix fViewMatrix;
374 SkISize fRTSize;
375 void invalidate() {
376 fViewMatrix = GrMatrix::InvalidMatrix();
377 fRTSize.fWidth = -1; // just make the first value compared illegal.
378 }
379 } fHWPathMatrixState;
380
bsalomon@google.coma3201942012-06-21 19:58:20 +0000381 GrStencilSettings fHWStencilSettings;
382 TriState fHWStencilTestEnabled;
bsalomon@google.com457b8a32012-05-21 21:19:58 +0000383
bsalomon@google.comc811ea32012-05-21 15:33:09 +0000384 GrDrawState::DrawFace fHWDrawFace;
385 TriState fHWWriteToColor;
386 TriState fHWDitherEnabled;
387 GrRenderTarget* fHWBoundRenderTarget;
388 GrTexture* fHWBoundTextures[GrDrawState::kNumStages];
bsalomon@google.com49209392012-06-05 15:13:46 +0000389 ///@}
bsalomon@google.com978c8c62012-05-21 14:45:49 +0000390
bsalomon@google.comfe676522011-06-17 18:12:21 +0000391 // we record what stencil format worked last time to hopefully exit early
392 // from our loop that tries stencil formats and calls check fb status.
393 int fLastSuccessfulStencilFmtIdx;
394
bsalomon@google.com49209392012-06-05 15:13:46 +0000395 enum UnpremulConversion {
396 kUpOnWrite_DownOnRead_UnpremulConversion,
397 kDownOnWrite_UpOnRead_UnpremulConversion
398 } fUnpremulConversion;
399
bsalomon@google.coma91e9232012-02-23 15:39:54 +0000400 enum CanPreserveUnpremulRoundtrip {
401 kUnknown_CanPreserveUnpremulRoundtrip,
402 kNo_CanPreserveUnpremulRoundtrip,
403 kYes_CanPreserveUnpremulRoundtrip,
404 } fCanPreserveUnpremulRoundtrip;
bsalomon@google.com0b77d682011-08-19 13:28:54 +0000405
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000406 bool fPrintedCaps;
407
reed@google.comac10a2d2010-12-22 21:39:39 +0000408 typedef GrGpu INHERITED;
409};
410
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000411#endif
bsalomon@google.comfe676522011-06-17 18:12:21 +0000412