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 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrGpu_DEFINED |
| 9 | #define GrGpu_DEFINED |
| 10 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 11 | #include "GrDrawTarget.h" |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 12 | #include "GrClipMaskManager.h" |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 13 | #include "SkPath.h" |
| 14 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 15 | class GrContext; |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 16 | class GrGpuObject; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 17 | class GrIndexBufferAllocPool; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 18 | class GrPath; |
bsalomon@google.com | 3008519 | 2011-08-19 15:42:31 +0000 | [diff] [blame] | 19 | class GrPathRenderer; |
| 20 | class GrPathRendererChain; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 21 | class GrStencilBuffer; |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 22 | class GrVertexBufferAllocPool; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
| 24 | class GrGpu : public GrDrawTarget { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | public: |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 26 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 27 | /** |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 28 | * Additional blend coefficients for dual source blending, not exposed |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 29 | * through GrPaint/GrContext. |
| 30 | */ |
| 31 | enum ExtendedBlendCoeffs { |
| 32 | // source 2 refers to second output color when |
| 33 | // using dual source blending. |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 34 | kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, |
| 35 | kIS2C_GrBlendCoeff, |
| 36 | kS2A_GrBlendCoeff, |
| 37 | kIS2A_GrBlendCoeff, |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 38 | |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 39 | kTotalGrBlendCoeffCount |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /** |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 43 | * Create an instance of GrGpu that matches the specified backend. If the requested backend is |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 44 | * not supported (at compile-time or run-time) this returns NULL. The context will not be |
| 45 | * fully constructed and should not be used by GrGpu until after this function returns. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | */ |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 47 | static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 48 | |
| 49 | //////////////////////////////////////////////////////////////////////////// |
| 50 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 51 | GrGpu(GrContext* context); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 52 | virtual ~GrGpu(); |
| 53 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 54 | GrContext* getContext() { return this->INHERITED::getContext(); } |
| 55 | const GrContext* getContext() const { return this->INHERITED::getContext(); } |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 56 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 57 | /** |
| 58 | * The GrGpu object normally assumes that no outsider is setting state |
| 59 | * within the underlying 3D API's context/device/whatever. This call informs |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 60 | * the GrGpu that the state was modified and it shouldn't make assumptions |
| 61 | * about the state. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 62 | */ |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 63 | void markContextDirty(uint32_t state = kAll_GrBackendState) { |
| 64 | fResetBits |= state; |
| 65 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 66 | |
| 67 | void unimpl(const char[]); |
| 68 | |
| 69 | /** |
bsalomon@google.com | 0748f21 | 2011-02-01 22:56:16 +0000 | [diff] [blame] | 70 | * Creates a texture object. If desc width or height is not a power of |
| 71 | * two but underlying API requires a power of two texture then srcData |
| 72 | * will be embedded in a power of two texture. The extra width and height |
| 73 | * is filled as though srcData were rendered clamped into the texture. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 74 | * |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 75 | * If kRenderTarget_TextureFlag is specified the GrRenderTarget is |
bsalomon@google.com | 1da0746 | 2011-03-10 14:51:57 +0000 | [diff] [blame] | 76 | * accessible via GrTexture::asRenderTarget(). The texture will hold a ref |
commit-bot@chromium.org | 999cfd1 | 2014-05-30 20:36:21 +0000 | [diff] [blame] | 77 | * on the render target until the texture is destroyed. |
bsalomon@google.com | 1da0746 | 2011-03-10 14:51:57 +0000 | [diff] [blame] | 78 | * |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 79 | * @param desc describes the texture to be created. |
| 80 | * @param srcData texel data to load texture. Begins with full-size |
commit-bot@chromium.org | 999cfd1 | 2014-05-30 20:36:21 +0000 | [diff] [blame] | 81 | * palette data for paletted textures. Contains width* |
| 82 | * height texels. If NULL texture data is uninitialized. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 83 | * |
| 84 | * @return The texture object if successful, otherwise NULL. |
| 85 | */ |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 86 | GrTexture* createTexture(const GrTextureDesc& desc, |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 87 | const void* srcData, size_t rowBytes); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 88 | |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 89 | /** |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 90 | * Implements GrContext::wrapBackendTexture |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 91 | */ |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 92 | GrTexture* wrapBackendTexture(const GrBackendTextureDesc&); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 95 | * Implements GrContext::wrapBackendTexture |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 96 | */ |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 97 | GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 98 | |
| 99 | /** |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 100 | * Creates a vertex buffer. |
| 101 | * |
| 102 | * @param size size in bytes of the vertex buffer |
| 103 | * @param dynamic hints whether the data will be frequently changed |
commit-bot@chromium.org | 8341eb7 | 2014-05-07 20:51:05 +0000 | [diff] [blame] | 104 | * by either GrVertexBuffer::map() or |
| 105 | * GrVertexBuffer::updateData(). |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 106 | * |
| 107 | * @return The vertex buffer if successful, otherwise NULL. |
| 108 | */ |
robertphillips@google.com | adacc70 | 2013-10-14 21:53:24 +0000 | [diff] [blame] | 109 | GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Creates an index buffer. |
| 113 | * |
| 114 | * @param size size in bytes of the index buffer |
| 115 | * @param dynamic hints whether the data will be frequently changed |
commit-bot@chromium.org | 8341eb7 | 2014-05-07 20:51:05 +0000 | [diff] [blame] | 116 | * by either GrIndexBuffer::map() or |
| 117 | * GrIndexBuffer::updateData(). |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 118 | * |
| 119 | * @return The index buffer if successful, otherwise NULL. |
| 120 | */ |
robertphillips@google.com | adacc70 | 2013-10-14 21:53:24 +0000 | [diff] [blame] | 121 | GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 122 | |
| 123 | /** |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 124 | * Creates a path object that can be stenciled using stencilPath(). It is |
| 125 | * only legal to call this if the caps report support for path stenciling. |
| 126 | */ |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 127 | GrPath* createPath(const SkPath& path, const SkStrokeRec& stroke); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 128 | |
| 129 | /** |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 130 | * Returns an index buffer that can be used to render quads. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 131 | * Six indices per quad: 0, 1, 2, 0, 2, 3, etc. |
| 132 | * The max number of quads can be queried using GrIndexBuffer::maxQuads(). |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 133 | * Draw with kTriangles_GrPrimitiveType |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 134 | * @ return the quad index buffer |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 135 | */ |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 136 | const GrIndexBuffer* getQuadIndexBuffer() const; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 137 | |
| 138 | /** |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 139 | * Resolves MSAA. |
| 140 | */ |
| 141 | void resolveRenderTarget(GrRenderTarget* target); |
| 142 | |
| 143 | /** |
commit-bot@chromium.org | 5d1d79a | 2013-05-24 18:52:52 +0000 | [diff] [blame] | 144 | * Gets a preferred 8888 config to use for writing/reading pixel data to/from a surface with |
| 145 | * config surfaceConfig. The returned config must have at least as many bits per channel as the |
| 146 | * readConfig or writeConfig param. |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 147 | */ |
commit-bot@chromium.org | 5d1d79a | 2013-05-24 18:52:52 +0000 | [diff] [blame] | 148 | virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
| 149 | GrPixelConfig surfaceConfig) const { |
| 150 | return readConfig; |
| 151 | } |
| 152 | virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
| 153 | GrPixelConfig surfaceConfig) const { |
| 154 | return writeConfig; |
| 155 | } |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 156 | |
| 157 | /** |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 158 | * Called before uploading writing pixels to a GrTexture when the src pixel config doesn't |
| 159 | * match the texture's config. |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 160 | */ |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 161 | virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const = 0; |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 162 | |
| 163 | /** |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 164 | * OpenGL's readPixels returns the result bottom-to-top while the skia |
| 165 | * API is top-to-bottom. Thus we have to do a y-axis flip. The obvious |
| 166 | * solution is to have the subclass do the flip using either the CPU or GPU. |
| 167 | * However, the caller (GrContext) may have transformations to apply and can |
| 168 | * simply fold in the y-flip for free. On the other hand, the subclass may |
| 169 | * be able to do it for free itself. For example, the subclass may have to |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 170 | * do memcpys to handle rowBytes that aren't tight. It could do the y-flip |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 171 | * concurrently. |
| 172 | * |
| 173 | * This function returns true if a y-flip is required to put the pixels in |
| 174 | * top-to-bottom order and the subclass cannot do it for free. |
| 175 | * |
| 176 | * See read pixels for the params |
| 177 | * @return true if calling readPixels with the same set of params will |
| 178 | * produce bottom-to-top data |
| 179 | */ |
| 180 | virtual bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, |
| 181 | int left, int top, |
| 182 | int width, int height, |
| 183 | GrPixelConfig config, |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 184 | size_t rowBytes) const = 0; |
| 185 | /** |
| 186 | * This should return true if reading a NxM rectangle of pixels from a |
| 187 | * render target is faster if the target has dimensons N and M and the read |
| 188 | * rectangle has its top-left at 0,0. |
| 189 | */ |
| 190 | virtual bool fullReadPixelsIsFasterThanPartial() const { return false; }; |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 191 | |
| 192 | /** |
bsalomon@google.com | a04e8e8 | 2012-08-27 12:53:13 +0000 | [diff] [blame] | 193 | * Reads a rectangle of pixels from a render target. |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 194 | * |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 195 | * @param renderTarget the render target to read from. NULL means the |
| 196 | * current render target. |
| 197 | * @param left left edge of the rectangle to read (inclusive) |
| 198 | * @param top top edge of the rectangle to read (inclusive) |
| 199 | * @param width width of rectangle to read in pixels. |
| 200 | * @param height height of rectangle to read in pixels. |
| 201 | * @param config the pixel config of the destination buffer |
| 202 | * @param buffer memory to read the rectangle into. |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 203 | * @param rowBytes the number of bytes between consecutive rows. Zero |
| 204 | * means rows are tightly packed. |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 205 | * @param invertY buffer should be populated bottom-to-top as opposed |
| 206 | * to top-to-bottom (skia's usual order) |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 207 | * |
| 208 | * @return true if the read succeeded, false if not. The read can fail |
| 209 | * because of a unsupported pixel config or because no render |
| 210 | * target is currently set. |
| 211 | */ |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 212 | bool readPixels(GrRenderTarget* renderTarget, |
| 213 | int left, int top, int width, int height, |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 214 | GrPixelConfig config, void* buffer, size_t rowBytes); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 215 | |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 216 | /** |
| 217 | * Updates the pixels in a rectangle of a texture. |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 218 | * |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 219 | * @param left left edge of the rectangle to write (inclusive) |
| 220 | * @param top top edge of the rectangle to write (inclusive) |
| 221 | * @param width width of rectangle to write in pixels. |
| 222 | * @param height height of rectangle to write in pixels. |
| 223 | * @param config the pixel config of the source buffer |
| 224 | * @param buffer memory to read pixels from |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 225 | * @param rowBytes number of bytes between consecutive rows. Zero |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 226 | * means rows are tightly packed. |
| 227 | */ |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 228 | bool writeTexturePixels(GrTexture* texture, |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 229 | int left, int top, int width, int height, |
| 230 | GrPixelConfig config, const void* buffer, |
| 231 | size_t rowBytes); |
| 232 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 233 | /** |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 234 | * Called to tell GrGpu that all GrGpuObjects have been lost and should |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 235 | * be abandoned. Overrides must call INHERITED::abandonResources(). |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 236 | */ |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 237 | virtual void abandonResources(); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 238 | |
| 239 | /** |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 240 | * Called to tell GrGpu to release all GrGpuObjects. Overrides must call |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 241 | * INHERITED::releaseResources(). |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 242 | */ |
| 243 | void releaseResources(); |
| 244 | |
| 245 | /** |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 246 | * Add object to list of objects. Should only be called by GrGpuObject. |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 247 | * @param resource the resource to add. |
| 248 | */ |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 249 | void insertObject(GrGpuObject* object); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 250 | |
| 251 | /** |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 252 | * Remove object from list of objects. Should only be called by GrGpuObject. |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 253 | * @param resource the resource to remove. |
| 254 | */ |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 255 | void removeObject(GrGpuObject* object); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 256 | |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 257 | // GrDrawTarget overrides |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 258 | virtual void clear(const SkIRect* rect, |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 259 | GrColor color, |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 260 | bool canIgnoreRect, |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 261 | GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 262 | |
robertphillips@google.com | ff17584 | 2012-05-14 19:31:39 +0000 | [diff] [blame] | 263 | virtual void purgeResources() SK_OVERRIDE { |
| 264 | // The clip mask manager can rebuild all its clip masks so just |
| 265 | // get rid of them all. |
| 266 | fClipMaskManager.releaseResources(); |
| 267 | } |
| 268 | |
bsalomon@google.com | 80d09b9 | 2011-11-05 21:21:13 +0000 | [diff] [blame] | 269 | // After the client interacts directly with the 3D context state the GrGpu |
| 270 | // must resync its internal state and assumptions about 3D context state. |
| 271 | // Each time this occurs the GrGpu bumps a timestamp. |
| 272 | // state of the 3D context |
| 273 | // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about |
| 274 | // a billion years. |
| 275 | typedef uint64_t ResetTimestamp; |
| 276 | |
| 277 | // This timestamp is always older than the current timestamp |
| 278 | static const ResetTimestamp kExpiredTimestamp = 0; |
| 279 | // Returns a timestamp based on the number of times the context was reset. |
| 280 | // This timestamp can be used to lazily detect when cached 3D context state |
| 281 | // is dirty. |
| 282 | ResetTimestamp getResetTimestamp() const { |
| 283 | return fResetTimestamp; |
| 284 | } |
| 285 | |
robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 286 | /** |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 287 | * These methods are called by the clip manager's setupClipping function |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 288 | * which (called as part of GrGpu's implementation of onDraw and |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 289 | * onStencilPath member functions.) The GrGpu subclass should flush the |
| 290 | * stencil state to the 3D API in its implementation of flushGraphicsState. |
| 291 | */ |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 292 | void enableScissor(const SkIRect& rect) { |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 293 | fScissorState.fEnabled = true; |
| 294 | fScissorState.fRect = rect; |
| 295 | } |
| 296 | void disableScissor() { fScissorState.fEnabled = false; } |
| 297 | |
| 298 | /** |
| 299 | * Like the scissor methods above this is called by setupClipping and |
| 300 | * should be flushed by the GrGpu subclass in flushGraphicsState. These |
| 301 | * stencil settings should be used in place of those on the GrDrawState. |
| 302 | * They have been adjusted to account for any interactions between the |
| 303 | * GrDrawState's stencil settings and stencil clipping. |
| 304 | */ |
| 305 | void setStencilSettings(const GrStencilSettings& settings) { |
| 306 | fStencilSettings = settings; |
| 307 | } |
| 308 | void disableStencil() { fStencilSettings.setDisabled(); } |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 309 | |
| 310 | // GrGpu subclass sets clip bit in the stencil buffer. The subclass is |
| 311 | // free to clear the remaining bits to zero if masked clears are more |
| 312 | // expensive than clearing all bits. |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 313 | virtual void clearStencilClip(const SkIRect& rect, bool insideClip) = 0; |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 314 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 315 | enum PrivateDrawStateStateBits { |
| 316 | kFirstBit = (GrDrawState::kLastPublicStateBit << 1), |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 317 | |
| 318 | kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify |
| 319 | // stencil bits used for |
| 320 | // clipping. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 321 | }; |
| 322 | |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 323 | void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSettings* outStencilSettings); |
| 324 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 325 | enum DrawType { |
| 326 | kDrawPoints_DrawType, |
| 327 | kDrawLines_DrawType, |
| 328 | kDrawTriangles_DrawType, |
| 329 | kStencilPath_DrawType, |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 330 | kDrawPath_DrawType, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 331 | kDrawPaths_DrawType, |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 332 | }; |
| 333 | |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 334 | protected: |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 335 | DrawType PrimTypeToDrawType(GrPrimitiveType type) { |
| 336 | switch (type) { |
| 337 | case kTriangles_GrPrimitiveType: |
| 338 | case kTriangleStrip_GrPrimitiveType: |
| 339 | case kTriangleFan_GrPrimitiveType: |
| 340 | return kDrawTriangles_DrawType; |
| 341 | case kPoints_GrPrimitiveType: |
| 342 | return kDrawPoints_DrawType; |
| 343 | case kLines_GrPrimitiveType: |
| 344 | case kLineStrip_GrPrimitiveType: |
| 345 | return kDrawLines_DrawType; |
| 346 | default: |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 347 | SkFAIL("Unexpected primitive type"); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 348 | return kDrawTriangles_DrawType; |
| 349 | } |
| 350 | } |
| 351 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 352 | // prepares clip flushes gpu state before a draw |
bsalomon@google.com | eb6879f | 2013-06-13 19:34:18 +0000 | [diff] [blame] | 353 | bool setupClipAndFlushState(DrawType, |
| 354 | const GrDeviceCoordTexture* dstCopy, |
commit-bot@chromium.org | 3ae0e6c | 2014-02-11 18:24:25 +0000 | [diff] [blame] | 355 | GrDrawState::AutoRestoreEffects* are, |
| 356 | const SkRect* devBounds); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 357 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 358 | // Functions used to map clip-respecting stencil tests into normal |
| 359 | // stencil funcs supported by GPUs. |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 360 | static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 361 | GrStencilFunc func); |
| 362 | static void ConvertStencilFuncAndMask(GrStencilFunc func, |
| 363 | bool clipInStencil, |
| 364 | unsigned int clipBit, |
| 365 | unsigned int userBits, |
| 366 | unsigned int* ref, |
| 367 | unsigned int* mask); |
| 368 | |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 369 | GrClipMaskManager fClipMaskManager; |
| 370 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 371 | struct GeometryPoolState { |
| 372 | const GrVertexBuffer* fPoolVertexBuffer; |
| 373 | int fPoolStartVertex; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 374 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 375 | const GrIndexBuffer* fPoolIndexBuffer; |
| 376 | int fPoolStartIndex; |
| 377 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 378 | const GeometryPoolState& getGeomPoolState() { |
| 379 | return fGeomPoolStateStack.back(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 380 | } |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 381 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 382 | // The state of the scissor is controlled by the clip manager |
| 383 | struct ScissorState { |
| 384 | bool fEnabled; |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 385 | SkIRect fRect; |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 386 | } fScissorState; |
| 387 | |
| 388 | // The final stencil settings to use as determined by the clip manager. |
| 389 | GrStencilSettings fStencilSettings; |
| 390 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 391 | // Helpers for setting up geometry state |
| 392 | void finalizeReservedVertices(); |
| 393 | void finalizeReservedIndices(); |
| 394 | |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 395 | private: |
| 396 | // GrDrawTarget overrides |
jvanverth@google.com | b75b0a0 | 2013-02-05 20:33:30 +0000 | [diff] [blame] | 397 | virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 398 | virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; |
| 399 | virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
| 400 | virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
| 401 | virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCount) SK_OVERRIDE; |
| 402 | virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount) SK_OVERRIDE; |
| 403 | virtual void releaseVertexArray() SK_OVERRIDE; |
| 404 | virtual void releaseIndexArray() SK_OVERRIDE; |
| 405 | virtual void geometrySourceWillPush() SK_OVERRIDE; |
| 406 | virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE; |
| 407 | |
| 408 | |
bsalomon@google.com | b635d39 | 2011-11-05 12:47:43 +0000 | [diff] [blame] | 409 | // called when the 3D context state is unknown. Subclass should emit any |
bsalomon@google.com | c8f7f47 | 2012-06-18 13:44:51 +0000 | [diff] [blame] | 410 | // assumed 3D context state and dirty any state cache. |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 411 | virtual void onResetContext(uint32_t resetBits) = 0; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 412 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 413 | // overridden by backend-specific derived class to create objects. |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 414 | virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 415 | const void* srcData, |
| 416 | size_t rowBytes) = 0; |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 417 | virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
| 418 | virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) = 0; |
robertphillips@google.com | adacc70 | 2013-10-14 21:53:24 +0000 | [diff] [blame] | 419 | virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
| 420 | virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 421 | virtual GrPath* onCreatePath(const SkPath& path, const SkStrokeRec&) = 0; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 422 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 423 | // overridden by backend-specific derived class to perform the clear and |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 424 | // clearRect. NULL rect means clear whole target. If canIgnoreRect is |
| 425 | // true, it is okay to perform a full clear instead of a partial clear |
| 426 | virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect) = 0; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 427 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 428 | // overridden by backend-specific derived class to perform the draw call. |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 429 | virtual void onGpuDraw(const DrawInfo&) = 0; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 430 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 431 | // overridden by backend-specific derived class to perform the path stenciling. |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 432 | virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) = 0; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 433 | virtual void onGpuDrawPath(const GrPath*, SkPath::FillType) = 0; |
commit-bot@chromium.org | ecc4536 | 2014-03-28 21:31:34 +0000 | [diff] [blame] | 434 | virtual void onGpuDrawPaths(int, const GrPath**, const SkMatrix*, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 435 | SkPath::FillType, SkStrokeRec::Style) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 436 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 437 | // overridden by backend-specific derived class to perform the read pixels. |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 438 | virtual bool onReadPixels(GrRenderTarget* target, |
| 439 | int left, int top, int width, int height, |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 440 | GrPixelConfig, |
| 441 | void* buffer, |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 442 | size_t rowBytes) = 0; |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 443 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 444 | // overridden by backend-specific derived class to perform the texture update |
bsalomon@google.com | 9c68058 | 2013-02-06 18:17:50 +0000 | [diff] [blame] | 445 | virtual bool onWriteTexturePixels(GrTexture* texture, |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 446 | int left, int top, int width, int height, |
| 447 | GrPixelConfig config, const void* buffer, |
| 448 | size_t rowBytes) = 0; |
| 449 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame] | 450 | // overridden by backend-specific derived class to perform the resolve |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 451 | virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
| 452 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 453 | // width and height may be larger than rt (if underlying API allows it). |
| 454 | // Should attach the SB to the RT. Returns false if compatible sb could |
| 455 | // not be created. |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 456 | virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int height) = 0; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 457 | |
| 458 | // attaches an existing SB to an existing RT. |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 459 | virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTarget*) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 460 | |
| 461 | // The GrGpu typically records the clients requested state and then flushes |
| 462 | // deltas from previous state at draw time. This function does the |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 463 | // backend-specific flush of the state. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 464 | // returns false if current state is unsupported. |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 465 | virtual bool flushGraphicsState(DrawType, const GrDeviceCoordTexture* dstCopy) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 466 | |
bsalomon@google.com | edc177d | 2011-08-05 15:46:40 +0000 | [diff] [blame] | 467 | // clears the entire stencil buffer to 0 |
| 468 | virtual void clearStencil() = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 469 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 470 | // Given a rt, find or create a stencil buffer and attach it |
| 471 | bool attachStencilBufferToRenderTarget(GrRenderTarget* target); |
| 472 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 473 | // GrDrawTarget overrides |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 474 | virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 475 | virtual void onStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 476 | virtual void onDrawPath(const GrPath*, SkPath::FillType, |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 477 | const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
commit-bot@chromium.org | ecc4536 | 2014-03-28 21:31:34 +0000 | [diff] [blame] | 478 | virtual void onDrawPaths(int, const GrPath**, const SkMatrix*, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 479 | SkPath::FillType, SkStrokeRec::Style, |
| 480 | const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 481 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 482 | // readies the pools to provide vertex/index data. |
| 483 | void prepareVertexPool(); |
| 484 | void prepareIndexPool(); |
| 485 | |
bsalomon@google.com | b635d39 | 2011-11-05 12:47:43 +0000 | [diff] [blame] | 486 | void resetContext() { |
bsalomon@google.com | c8f7f47 | 2012-06-18 13:44:51 +0000 | [diff] [blame] | 487 | // We call this because the client may have messed with the |
| 488 | // stencil buffer. Perhaps we should detect whether it is a |
| 489 | // internally created stencil buffer and if so skip the invalidate. |
| 490 | fClipMaskManager.invalidateStencilMask(); |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 491 | this->onResetContext(fResetBits); |
| 492 | fResetBits = 0; |
bsalomon@google.com | b635d39 | 2011-11-05 12:47:43 +0000 | [diff] [blame] | 493 | ++fResetTimestamp; |
| 494 | } |
| 495 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 496 | void handleDirtyContext() { |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 497 | if (fResetBits) { |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 498 | this->resetContext(); |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 502 | enum { |
| 503 | kPreallocGeomPoolStateStackCnt = 4, |
| 504 | }; |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 505 | typedef SkTInternalLList<GrGpuObject> ObjectList; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 506 | SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoolStateStack; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 507 | ResetTimestamp fResetTimestamp; |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 508 | uint32_t fResetBits; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 509 | GrVertexBufferAllocPool* fVertexPool; |
| 510 | GrIndexBufferAllocPool* fIndexPool; |
| 511 | // counts number of uses of vertex/index pool in the geometry stack |
| 512 | int fVertexPoolUseCnt; |
| 513 | int fIndexPoolUseCnt; |
bsalomon@google.com | 6438695 | 2013-02-08 21:22:44 +0000 | [diff] [blame] | 514 | // these are mutable so they can be created on-demand |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 515 | mutable GrIndexBuffer* fQuadIndexBuffer; |
skia.committer@gmail.com | 66a4a4c | 2013-05-11 07:01:34 +0000 | [diff] [blame] | 516 | // Used to abandon/release all resources created by this GrGpu. TODO: Move this |
bsalomon@google.com | 76202b8 | 2013-05-10 19:08:22 +0000 | [diff] [blame] | 517 | // functionality to GrResourceCache. |
commit-bot@chromium.org | 089a780 | 2014-05-02 21:38:22 +0000 | [diff] [blame] | 518 | ObjectList fObjectList; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 519 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 520 | typedef GrDrawTarget INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | #endif |