reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 8 | #ifndef GrGLGpu_DEFINED |
| 9 | #define GrGLGpu_DEFINED |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 11 | #include "GrGLContext.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 12 | #include "GrGLIRect.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 13 | #include "GrGLIndexBuffer.h" |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 14 | #include "GrGLPathRendering.h" |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 15 | #include "GrGLProgram.h" |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 16 | #include "GrGLRenderTarget.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 17 | #include "GrGLStencilAttachment.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 18 | #include "GrGLTexture.h" |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 19 | #include "GrGLVertexArray.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 20 | #include "GrGLVertexBuffer.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 21 | #include "GrGpu.h" |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 22 | #include "GrPipelineBuilder.h" |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 23 | #include "GrXferProcessor.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 24 | #include "SkTypes.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 26 | class GrPipeline; |
bsalomon | e64eb57 | 2015-05-07 11:35:55 -0700 | [diff] [blame] | 27 | class GrNonInstancedVertices; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 28 | |
commit-bot@chromium.org | 174db77 | 2013-03-21 12:46:01 +0000 | [diff] [blame] | 29 | #ifdef SK_DEVELOPER |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 30 | #define PROGRAM_CACHE_STATS |
| 31 | #endif |
| 32 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 33 | class GrGLGpu : public GrGpu { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 34 | public: |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 35 | static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options, |
| 36 | GrContext* context); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 37 | ~GrGLGpu() override; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 39 | void contextAbandoned() override; |
bsalomon | c8dc1f7 | 2014-08-21 13:02:13 -0700 | [diff] [blame] | 40 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 41 | const GrGLContext& glContext() const { return *fGLContext; } |
commit-bot@chromium.org | c9424b8 | 2013-10-30 20:03:16 +0000 | [diff] [blame] | 42 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 43 | const GrGLInterface* glInterface() const { return fGLContext->interface(); } |
| 44 | const GrGLContextInfo& ctxInfo() const { return *fGLContext; } |
| 45 | GrGLStandard glStandard() const { return fGLContext->standard(); } |
| 46 | GrGLVersion glVersion() const { return fGLContext->version(); } |
| 47 | GrGLSLGeneration glslGeneration() const { return fGLContext->glslGeneration(); } |
| 48 | const GrGLCaps& glCaps() const { return *fGLContext->caps(); } |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 49 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 50 | GrGLPathRendering* glPathRendering() { |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 51 | SkASSERT(glCaps().shaderCaps()->pathRenderingSupport()); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 52 | return static_cast<GrGLPathRendering*>(pathRendering()); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 53 | } |
| 54 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 55 | void discard(GrRenderTarget*) override; |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 56 | |
kkinnunen | cfe62e3 | 2015-07-01 02:58:50 -0700 | [diff] [blame] | 57 | // Used by GrGLProgram to configure OpenGL state. |
bsalomon@google.com | 34cccde | 2013-01-04 18:34:30 +0000 | [diff] [blame] | 58 | void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 59 | |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 60 | // GrGpu overrides |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 61 | GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 62 | GrPixelConfig surfaceConfig) const override; |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 63 | GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 64 | GrPixelConfig surfaceConfig) const override; |
| 65 | bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const override; |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 66 | bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
| 67 | int left, int top, |
| 68 | int width, int height, |
| 69 | GrPixelConfig config, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 70 | size_t rowBytes) const override; |
| 71 | bool fullReadPixelsIsFasterThanPartial() const override; |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 72 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame^] | 73 | bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const override; |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 74 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 75 | // These functions should be used to bind GL objects. They track the GL state and skip redundant |
skia.committer@gmail.com | 754a3eb | 2013-03-08 07:01:25 +0000 | [diff] [blame] | 76 | // bindings. Making the equivalent glBind calls directly will confuse the state tracking. |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 77 | void bindVertexArray(GrGLuint id) { |
| 78 | fHWGeometryState.setVertexArrayID(this, id); |
| 79 | } |
| 80 | void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
| 81 | fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, id); |
| 82 | } |
| 83 | void bindVertexBuffer(GrGLuint id) { |
| 84 | fHWGeometryState.setVertexBufferID(this, id); |
| 85 | } |
| 86 | |
| 87 | // These callbacks update state tracking when GL objects are deleted. They are called from |
| 88 | // GrGLResource onRelease functions. |
| 89 | void notifyVertexArrayDelete(GrGLuint id) { |
| 90 | fHWGeometryState.notifyVertexArrayDelete(id); |
| 91 | } |
| 92 | void notifyVertexBufferDelete(GrGLuint id) { |
| 93 | fHWGeometryState.notifyVertexBufferDelete(id); |
| 94 | } |
| 95 | void notifyIndexBufferDelete(GrGLuint id) { |
| 96 | fHWGeometryState.notifyIndexBufferDelete(id); |
| 97 | } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 98 | |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 99 | bool copySurface(GrSurface* dst, |
| 100 | GrSurface* src, |
| 101 | const SkIRect& srcRect, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 102 | const SkIPoint& dstPoint) override; |
joshualitt | a702415 | 2014-11-03 14:16:35 -0800 | [diff] [blame] | 103 | |
cdalton | 231c5fd | 2015-05-13 12:35:36 -0700 | [diff] [blame] | 104 | void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 105 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 106 | void buildProgramDesc(GrProgramDesc*, |
| 107 | const GrPrimitiveProcessor&, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 108 | const GrPipeline&, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 109 | const GrBatchTracker&) const override; |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 110 | |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame] | 111 | const GrGLContext* glContextForTesting() const override { |
| 112 | return &this->glContext(); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 113 | } |
| 114 | |
jvanverth | 672bb7f | 2015-07-13 07:19:57 -0700 | [diff] [blame] | 115 | GrBackendObject createBackendTexture(void* pixels, int w, int h, |
| 116 | GrPixelConfig config) const override; |
| 117 | bool isBackendTexture(GrBackendObject id) const override; |
| 118 | void deleteBackendTexture(GrBackendObject id) const override; |
| 119 | |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 120 | private: |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 121 | GrGLGpu(GrGLContext* ctx, GrContext* context); |
| 122 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 123 | // GrGpu overrides |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 124 | void onResetContext(uint32_t resetBits) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 125 | |
egdaniel | b0e1be2 | 2015-04-22 13:27:39 -0700 | [diff] [blame] | 126 | GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCycle lifeCycle, |
| 127 | const void* srcData, size_t rowBytes) override; |
| 128 | GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 129 | GrGpuResource::LifeCycle lifeCycle, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 130 | const void* srcData) override; |
| 131 | GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
| 132 | GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 133 | GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) override; |
| 134 | GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
| 135 | GrWrapOwnership) override; |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 136 | bool createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int width, int height) override; |
| 137 | bool attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, |
| 138 | GrRenderTarget* rt) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 139 | |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 140 | void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 141 | bool canIgnoreRect) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 142 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 143 | void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) override; |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 144 | |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 145 | bool onReadPixels(GrRenderTarget* target, |
| 146 | int left, int top, |
| 147 | int width, int height, |
| 148 | GrPixelConfig, |
| 149 | void* buffer, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 150 | size_t rowBytes) override; |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 151 | |
| 152 | bool onWriteTexturePixels(GrTexture* texture, |
| 153 | int left, int top, int width, int height, |
| 154 | GrPixelConfig config, const void* buffer, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 155 | size_t rowBytes) override; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 156 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 157 | void onResolveRenderTarget(GrRenderTarget* target) override; |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 158 | |
bsalomon | e64eb57 | 2015-05-07 11:35:55 -0700 | [diff] [blame] | 159 | void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 160 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 161 | void clearStencil(GrRenderTarget*) override; |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 162 | |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 163 | // GrDrawTarget overrides |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 164 | void didAddGpuTraceMarker() override; |
| 165 | void didRemoveGpuTraceMarker() override; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 166 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 167 | // binds texture unit in GL |
bsalomon@google.com | 8531c1c | 2011-01-13 19:52:45 +0000 | [diff] [blame] | 168 | void setTextureUnit(int unitIdx); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 169 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 170 | // Flushes state from GrPipeline to GL. Returns false if the state couldn't be set. |
cdalton | d0a840d | 2015-03-16 17:19:58 -0700 | [diff] [blame] | 171 | bool flushGLState(const DrawArgs&); |
bsalomon | d95263c | 2014-12-16 13:05:12 -0800 | [diff] [blame] | 172 | |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 173 | // Sets up vertex attribute pointers and strides. On return indexOffsetInBytes gives the offset |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 174 | // an into the index buffer. It does not account for vertices.startIndex() but rather the start |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 175 | // index is relative to the returned offset. |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 176 | void setupGeometry(const GrPrimitiveProcessor&, |
bsalomon | e64eb57 | 2015-05-07 11:35:55 -0700 | [diff] [blame] | 177 | const GrNonInstancedVertices& vertices, |
joshualitt | d53a827 | 2014-11-10 16:03:14 -0800 | [diff] [blame] | 178 | size_t* indexOffsetInBytes); |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 179 | |
bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 180 | // Subclasses should call this to flush the blend state. |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 181 | void flushBlend(const GrXferProcessor::BlendInfo& blendInfo); |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 182 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 183 | bool hasExtension(const char* ext) const { return fGLContext->hasExtension(ext); } |
bsalomon@google.com | 9639994 | 2012-02-13 14:39:16 +0000 | [diff] [blame] | 184 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 185 | void copySurfaceAsDraw(GrSurface* dst, |
| 186 | GrSurface* src, |
| 187 | const SkIRect& srcRect, |
| 188 | const SkIPoint& dstPoint); |
| 189 | void copySurfaceAsCopyTexSubImage(GrSurface* dst, |
| 190 | GrSurface* src, |
| 191 | const SkIRect& srcRect, |
| 192 | const SkIPoint& dstPoint); |
| 193 | bool copySurfaceAsBlitFramebuffer(GrSurface* dst, |
| 194 | GrSurface* src, |
| 195 | const SkIRect& srcRect, |
| 196 | const SkIPoint& dstPoint); |
| 197 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 198 | static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 199 | |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 200 | class ProgramCache : public ::SkNoncopyable { |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 201 | public: |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 202 | ProgramCache(GrGLGpu* gpu); |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 203 | ~ProgramCache(); |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 204 | |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 205 | void abandon(); |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 206 | GrGLProgram* refProgram(const DrawArgs&); |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 207 | |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 208 | private: |
| 209 | enum { |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 210 | // We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
| 211 | // shader before evicting from the cache. |
commit-bot@chromium.org | b556422 | 2014-03-28 15:52:18 +0000 | [diff] [blame] | 212 | kMaxEntries = 128, |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 213 | kHashBits = 6, |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 214 | }; |
| 215 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 216 | struct Entry; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 217 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 218 | struct ProgDescLess; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 219 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 220 | // binary search for entry matching desc. returns index into fEntries that matches desc or ~ |
| 221 | // of the index of where it should be inserted. |
joshualitt | 79f8fae | 2014-10-28 17:59:26 -0700 | [diff] [blame] | 222 | int search(const GrProgramDesc& desc) const; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 223 | |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 224 | // sorted array of all the entries |
| 225 | Entry* fEntries[kMaxEntries]; |
| 226 | // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
| 227 | // searching fEntries. |
| 228 | Entry* fHashTable[1 << kHashBits]; |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 229 | |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 230 | int fCount; |
| 231 | unsigned int fCurrLRUStamp; |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 232 | GrGLGpu* fGpu; |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 233 | #ifdef PROGRAM_CACHE_STATS |
| 234 | int fTotalRequests; |
| 235 | int fCacheMisses; |
bsalomon@google.com | 2db3ded | 2013-05-22 14:34:04 +0000 | [diff] [blame] | 236 | int fHashMisses; // cache hit but hash table missed |
jvanverth@google.com | 9487877 | 2013-03-12 16:00:54 +0000 | [diff] [blame] | 237 | #endif |
bsalomon@google.com | c1d2a58 | 2012-06-01 15:08:19 +0000 | [diff] [blame] | 238 | }; |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 239 | |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 240 | void flushDither(bool dither); |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 241 | void flushColorWrite(bool writeColor); |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 242 | void flushDrawFace(GrPipelineBuilder::DrawFace face); |
bsalomon@google.com | c96cb3a | 2012-06-04 19:31:00 +0000 | [diff] [blame] | 243 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 244 | // flushes the scissor. see the note on flushBoundTextureAndParams about |
| 245 | // flushing the scissor after that function is called. |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 246 | void flushScissor(const GrScissorState&, |
joshualitt | 77b1307 | 2014-10-27 14:51:01 -0700 | [diff] [blame] | 247 | const GrGLIRect& rtViewport, |
| 248 | GrSurfaceOrigin rtOrigin); |
| 249 | |
| 250 | // disables the scissor |
| 251 | void disableScissor(); |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 252 | |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 253 | void initFSAASupport(); |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 254 | |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 255 | // determines valid stencil formats |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 256 | void initStencilFormats(); |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 257 | |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 258 | // sets a texture unit to use for texture operations other than binding a texture to a program. |
| 259 | // ensures that such operations don't negatively interact with tracking bound textures. |
| 260 | void setScratchTextureUnit(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 261 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 262 | // bounds is region that may be modified and therefore has to be resolved. |
| 263 | // NULL means whole target. Can be an empty rect. |
| 264 | void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); |
bsalomon | b0bd4f6 | 2014-09-03 07:19:50 -0700 | [diff] [blame] | 265 | |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 266 | void flushStencil(const GrStencilSettings&); |
cdalton | d0a840d | 2015-03-16 17:19:58 -0700 | [diff] [blame] | 267 | void flushHWAAState(GrRenderTarget* rt, bool useHWAA); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 268 | |
bsalomon@google.com | 280e99f | 2012-01-05 16:17:38 +0000 | [diff] [blame] | 269 | bool configToGLFormats(GrPixelConfig config, |
| 270 | bool getSizedInternal, |
| 271 | GrGLenum* internalFormat, |
| 272 | GrGLenum* externalFormat, |
jvanverth | 672bb7f | 2015-07-13 07:19:57 -0700 | [diff] [blame] | 273 | GrGLenum* externalType) const; |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 274 | // helper for onCreateTexture and writeTexturePixels |
bsalomon | b15b4c1 | 2014-10-29 12:41:57 -0700 | [diff] [blame] | 275 | bool uploadTexData(const GrSurfaceDesc& desc, |
bsalomon@google.com | 1e0e607 | 2011-11-28 18:49:37 +0000 | [diff] [blame] | 276 | bool isNewTexture, |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 277 | int left, int top, int width, int height, |
| 278 | GrPixelConfig dataConfig, |
| 279 | const void* data, |
| 280 | size_t rowBytes); |
bsalomon@google.com | 0650e81 | 2011-04-08 18:07:53 +0000 | [diff] [blame] | 281 | |
krajcevski | 145d48c | 2014-06-11 16:07:50 -0700 | [diff] [blame] | 282 | // helper for onCreateCompressedTexture. If width and height are |
| 283 | // set to -1, then this function will use desc.fWidth and desc.fHeight |
| 284 | // for the size of the data. The isNewTexture flag should be set to true |
| 285 | // whenever a new texture needs to be created. Otherwise, we assume that |
| 286 | // the texture is already in GPU memory and that it's going to be updated |
| 287 | // with new data. |
bsalomon | b15b4c1 | 2014-10-29 12:41:57 -0700 | [diff] [blame] | 288 | bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
krajcevski | 145d48c | 2014-06-11 16:07:50 -0700 | [diff] [blame] | 289 | const void* data, |
| 290 | bool isNewTexture = true, |
| 291 | int left = 0, int top = 0, |
| 292 | int width = -1, int height = -1); |
krajcevski | 9c0e629 | 2014-06-02 07:38:14 -0700 | [diff] [blame] | 293 | |
egdaniel | b0e1be2 | 2015-04-22 13:27:39 -0700 | [diff] [blame] | 294 | bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycle lifeCycle, |
| 295 | GrGLuint texID, GrGLRenderTarget::IDDesc*); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 296 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 297 | enum TempFBOTarget { |
| 298 | kSrc_TempFBOTarget, |
| 299 | kDst_TempFBOTarget |
| 300 | }; |
egdaniel | 0f5f967 | 2015-02-03 11:10:51 -0800 | [diff] [blame] | 301 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 302 | GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, |
| 303 | TempFBOTarget tempFBOTarget); |
egdaniel | 0f5f967 | 2015-02-03 11:10:51 -0800 | [diff] [blame] | 304 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 305 | void unbindTextureFromFBO(GrGLenum fboTarget); |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 306 | |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame] | 307 | SkAutoTUnref<GrGLContext> fGLContext; |
bsalomon@google.com | 2c17fcd | 2011-07-06 17:47:02 +0000 | [diff] [blame] | 308 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 309 | void createCopyProgram(); |
| 310 | |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 311 | // GL program-related state |
| 312 | ProgramCache* fProgramCache; |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 313 | |
| 314 | /////////////////////////////////////////////////////////////////////////// |
| 315 | ///@name Caching of GL State |
| 316 | ///@{ |
| 317 | int fHWActiveTextureUnitIdx; |
bsalomon@google.com | 5739d2c | 2012-05-31 15:07:19 +0000 | [diff] [blame] | 318 | GrGLuint fHWProgramID; |
bsalomon@google.com | 9120748 | 2013-02-12 21:45:24 +0000 | [diff] [blame] | 319 | |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 320 | enum TriState { |
| 321 | kNo_TriState, |
| 322 | kYes_TriState, |
| 323 | kUnknown_TriState |
| 324 | }; |
| 325 | |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 326 | GrGLuint fTempSrcFBOID; |
| 327 | GrGLuint fTempDstFBOID; |
| 328 | |
| 329 | GrGLuint fStencilClearFBOID; |
bsalomon | dd3143b | 2015-02-23 09:27:45 -0800 | [diff] [blame] | 330 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 331 | // last scissor / viewport scissor state seen by the GL. |
| 332 | struct { |
| 333 | TriState fEnabled; |
| 334 | GrGLIRect fRect; |
| 335 | void invalidate() { |
| 336 | fEnabled = kUnknown_TriState; |
| 337 | fRect.invalidate(); |
| 338 | } |
| 339 | } fHWScissorSettings; |
| 340 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 341 | GrGLIRect fHWViewport; |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 342 | |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 343 | /** |
| 344 | * Tracks bound vertex and index buffers and vertex attrib array state. |
| 345 | */ |
| 346 | class HWGeometryState { |
| 347 | public: |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 348 | HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } |
skia.committer@gmail.com | 754a3eb | 2013-03-08 07:01:25 +0000 | [diff] [blame] | 349 | |
bsalomon | 8780bc6 | 2015-05-13 09:56:37 -0700 | [diff] [blame] | 350 | ~HWGeometryState() { SkDELETE(fVBOVertexArray); } |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 351 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 352 | void invalidate() { |
| 353 | fBoundVertexArrayIDIsValid = false; |
| 354 | fBoundVertexBufferIDIsValid = false; |
| 355 | fDefaultVertexArrayBoundIndexBufferID = false; |
| 356 | fDefaultVertexArrayBoundIndexBufferIDIsValid = false; |
| 357 | fDefaultVertexArrayAttribState.invalidate(); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 358 | if (fVBOVertexArray) { |
commit-bot@chromium.org | ce6da4d | 2013-09-09 14:55:37 +0000 | [diff] [blame] | 359 | fVBOVertexArray->invalidateCachedState(); |
| 360 | } |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | void notifyVertexArrayDelete(GrGLuint id) { |
| 364 | if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { |
| 365 | // Does implicit bind to 0 |
| 366 | fBoundVertexArrayID = 0; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 370 | void setVertexArrayID(GrGLGpu* gpu, GrGLuint arrayID) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 371 | if (!gpu->glCaps().vertexArrayObjectSupport()) { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 372 | SkASSERT(0 == arrayID); |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 373 | return; |
| 374 | } |
| 375 | if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { |
| 376 | GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); |
| 377 | fBoundVertexArrayIDIsValid = true; |
| 378 | fBoundVertexArrayID = arrayID; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 382 | void notifyVertexBufferDelete(GrGLuint id) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 383 | if (fBoundVertexBufferIDIsValid && id == fBoundVertexBufferID) { |
| 384 | fBoundVertexBufferID = 0; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 385 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 386 | if (fVBOVertexArray) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 387 | fVBOVertexArray->notifyVertexBufferDelete(id); |
| 388 | } |
| 389 | fDefaultVertexArrayAttribState.notifyVertexBufferDelete(id); |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 390 | } |
| 391 | |
bsalomon@google.com | e49ad45 | 2013-02-20 19:33:20 +0000 | [diff] [blame] | 392 | void notifyIndexBufferDelete(GrGLuint id) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 393 | if (fDefaultVertexArrayBoundIndexBufferIDIsValid && |
| 394 | id == fDefaultVertexArrayBoundIndexBufferID) { |
| 395 | fDefaultVertexArrayBoundIndexBufferID = 0; |
| 396 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 397 | if (fVBOVertexArray) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 398 | fVBOVertexArray->notifyIndexBufferDelete(id); |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 402 | void setVertexBufferID(GrGLGpu* gpu, GrGLuint id) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 403 | if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) { |
| 404 | GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id)); |
| 405 | fBoundVertexBufferIDIsValid = true; |
| 406 | fBoundVertexBufferID = id; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 410 | /** |
| 411 | * Binds the default vertex array and binds the index buffer. This is used when binding |
| 412 | * an index buffer in order to update it. |
| 413 | */ |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 414 | void setIndexBufferIDOnDefaultVertexArray(GrGLGpu* gpu, GrGLuint id) { |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 415 | this->setVertexArrayID(gpu, 0); |
| 416 | if (!fDefaultVertexArrayBoundIndexBufferIDIsValid || |
| 417 | id != fDefaultVertexArrayBoundIndexBufferID) { |
| 418 | GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, id)); |
| 419 | fDefaultVertexArrayBoundIndexBufferIDIsValid = true; |
| 420 | fDefaultVertexArrayBoundIndexBufferID = id; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Binds the vertex array object that should be used to render from the vertex buffer. |
| 426 | * The vertex array is bound and its attrib array state object is returned. The vertex |
| 427 | * buffer is bound. The index buffer (if non-NULL) is bound to the vertex array. The |
skia.committer@gmail.com | 754a3eb | 2013-03-08 07:01:25 +0000 | [diff] [blame] | 428 | * returned GrGLAttribArrayState should be used to set vertex attribute arrays. |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 429 | */ |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 430 | GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 431 | const GrGLVertexBuffer* vbuffer, |
| 432 | const GrGLIndexBuffer* ibuffer); |
| 433 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 434 | /** Variants of the above that takes GL buffer IDs. Note that 0 does not imply that a |
| 435 | buffer won't be bound. The "default buffer" will be bound, which is used for client-side |
| 436 | array rendering. */ |
| 437 | GrGLAttribArrayState* bindArrayAndBufferToDraw(GrGLGpu* gpu, GrGLuint vbufferID); |
| 438 | GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu, |
| 439 | GrGLuint vbufferID, |
| 440 | GrGLuint ibufferID); |
| 441 | |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 442 | private: |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 443 | GrGLAttribArrayState* internalBind(GrGLGpu* gpu, GrGLuint vbufferID, GrGLuint* ibufferID); |
| 444 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 445 | GrGLuint fBoundVertexArrayID; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 446 | GrGLuint fBoundVertexBufferID; |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 447 | bool fBoundVertexArrayIDIsValid; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 448 | bool fBoundVertexBufferIDIsValid; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 449 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 450 | GrGLuint fDefaultVertexArrayBoundIndexBufferID; |
| 451 | bool fDefaultVertexArrayBoundIndexBufferIDIsValid; |
| 452 | // We return a non-const pointer to this from bindArrayAndBuffersToDraw when vertex array 0 |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 453 | // is bound. However, this class is internal to GrGLGpu and this object never leaks out of |
| 454 | // GrGLGpu. |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 455 | GrGLAttribArrayState fDefaultVertexArrayAttribState; |
bsalomon@google.com | 880b8fc | 2013-02-19 20:17:28 +0000 | [diff] [blame] | 456 | |
bsalomon@google.com | 6918d48 | 2013-03-07 19:09:11 +0000 | [diff] [blame] | 457 | // This is used when we're using a core profile and the vertices are in a VBO. |
| 458 | GrGLVertexArray* fVBOVertexArray; |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 459 | } fHWGeometryState; |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 460 | |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 461 | struct { |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 462 | GrBlendEquation fEquation; |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 463 | GrBlendCoeff fSrcCoeff; |
| 464 | GrBlendCoeff fDstCoeff; |
| 465 | GrColor fConstColor; |
| 466 | bool fConstColorValid; |
| 467 | TriState fEnabled; |
| 468 | |
| 469 | void invalidate() { |
bsalomon | f7cc877 | 2015-05-11 11:21:14 -0700 | [diff] [blame] | 470 | fEquation = static_cast<GrBlendEquation>(-1); |
| 471 | fSrcCoeff = static_cast<GrBlendCoeff>(-1); |
| 472 | fDstCoeff = static_cast<GrBlendCoeff>(-1); |
bsalomon@google.com | a4d8fc2 | 2012-05-21 13:21:46 +0000 | [diff] [blame] | 473 | fConstColorValid = false; |
| 474 | fEnabled = kUnknown_TriState; |
| 475 | } |
| 476 | } fHWBlendState; |
| 477 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 478 | /** IDs for copy surface program. */ |
| 479 | struct { |
| 480 | GrGLuint fProgram; |
| 481 | GrGLint fTextureUniform; |
| 482 | GrGLint fTexCoordXformUniform; |
| 483 | GrGLint fPosXformUniform; |
| 484 | GrGLuint fArrayBuffer; |
| 485 | } fCopyProgram; |
| 486 | |
egdaniel | b414f25 | 2014-07-29 13:15:47 -0700 | [diff] [blame] | 487 | TriState fMSAAEnabled; |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 488 | |
bsalomon@google.com | 6a51dcb | 2013-02-13 16:03:51 +0000 | [diff] [blame] | 489 | GrStencilSettings fHWStencilSettings; |
| 490 | TriState fHWStencilTestEnabled; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 491 | |
bsalomon@google.com | 6a51dcb | 2013-02-13 16:03:51 +0000 | [diff] [blame] | 492 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 493 | GrPipelineBuilder::DrawFace fHWDrawFace; |
bsalomon@google.com | 6a51dcb | 2013-02-13 16:03:51 +0000 | [diff] [blame] | 494 | TriState fHWWriteToColor; |
| 495 | TriState fHWDitherEnabled; |
egdaniel | d803f27 | 2015-03-18 13:01:52 -0700 | [diff] [blame] | 496 | uint32_t fHWBoundRenderTargetUniqueID; |
bsalomon | 1c63bf6 | 2014-07-22 13:09:46 -0700 | [diff] [blame] | 497 | SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 498 | |
bsalomon@google.com | 4920939 | 2012-06-05 15:13:46 +0000 | [diff] [blame] | 499 | ///@} |
bsalomon@google.com | 978c8c6 | 2012-05-21 14:45:49 +0000 | [diff] [blame] | 500 | |
bsalomon@google.com | fe67652 | 2011-06-17 18:12:21 +0000 | [diff] [blame] | 501 | // we record what stencil format worked last time to hopefully exit early |
| 502 | // from our loop that tries stencil formats and calls check fb status. |
| 503 | int fLastSuccessfulStencilFmtIdx; |
| 504 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 505 | typedef GrGpu INHERITED; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 506 | friend class GrGLPathRendering; // For accessing setTextureUnit. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 507 | }; |
| 508 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 509 | #endif |