GrDrawTarget.h revision 56995b5cc00c9c83bd5fcf86bca9a67e939a96cb
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2010 Google Inc. 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 6ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 7ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 8ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#ifndef GrDrawTarget_DEFINED 9ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GrDrawTarget_DEFINED 10ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 118d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com#include "GrClipData.h" 126db519c42471aaaa8a8e1a3ece314014481ab832joshualitt#include "GrClipMaskManager.h" 132a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org#include "GrContext.h" 149381363050ec9d3e724076a8e9152bfa9a8de1d1tomhudson@google.com#include "GrDrawState.h" 15934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com#include "GrIndexBuffer.h" 16ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen#include "GrPathRendering.h" 172a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org#include "GrTraceMarker.h" 187eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt#include "GrVertexBuffer.h" 19ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 208d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com#include "SkClipStack.h" 21a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org#include "SkMatrix.h" 2212b4e27ae1a29460e91a59f38122483e1faec697sugoi@google.com#include "SkPath.h" 239b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org#include "SkStrokeRec.h" 24a2d71482db8b6d752a51c96da74768d7dfc27932robertphillips@google.com#include "SkTArray.h" 25a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org#include "SkTLazy.h" 26a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org#include "SkTypes.h" 278d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com#include "SkXfermode.h" 2897c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo 29a2d71482db8b6d752a51c96da74768d7dfc27932robertphillips@google.comclass GrClipData; 30c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.comclass GrDrawTargetCaps; 3164aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.comclass GrPath; 32b85a0aab6905af8b329539b7573a7555b727d5e5cdaltonclass GrPathRange; 3312b4e27ae1a29460e91a59f38122483e1faec697sugoi@google.com 34a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.orgclass GrDrawTarget : public SkRefCnt { 35bcce8926524827775539874346dd424a9510dbc9bsalomon@google.compublic: 36bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com SK_DECLARE_INST_COUNT(GrDrawTarget) 37bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com 3855b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRange::PathIndexType PathIndexType; 3955b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRendering::PathTransformType PathTransformType; 40ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen 41ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /////////////////////////////////////////////////////////////////////////// 42ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 436e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context may not be fully constructed and should not be used during GrDrawTarget 446e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // construction. 456e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrDrawTarget(GrContext* context); 4625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual ~GrDrawTarget(); 47ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 48ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 4918c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com * Gets the capabilities of the draw target. 5018c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com */ 51c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com const GrDrawTargetCaps* caps() const { return fCaps.get(); } 5218c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com 5318c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com /** 54ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets the current clip to the region specified by clip. All draws will be 55ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * clipped against this clip if kClip_StateBit is enabled. 56ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 575aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * Setting the clip may (or may not) zero out the client's stencil bits. 585aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * 59ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param description of the clipping region 60ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 61beb1af78d016d2700c350487a383c6bcfa7e2e20robertphillips@google.com void setClip(const GrClipData* clip); 62ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 63ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 64ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Gets the current clip. 65ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 66ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @return the clip. 67ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 68beb1af78d016d2700c350487a383c6bcfa7e2e20robertphillips@google.com const GrClipData* getClip() const; 69ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 70a5d056ae0b04021dfb44c2c7a3d6a34e060261b8bsalomon@google.com /** 71f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * There are two types of "sources" of geometry (vertices and indices) for 72e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * draw calls made on the target. When performing an indexed draw, the 73e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indices and vertices can use different source types. Once a source is 74934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * specified it can be used for multiple draws. However, the time at which 75934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * the geometry data is no longer editable depends on the source type. 7625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 7725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Sometimes it is necessary to perform a draw while upstack code has 78e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * already specified geometry that it isn't finished with. So there are push 79e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and pop methods. This allows the client to push the sources, draw 80e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * something using alternate sources, and then pop to restore the original 81e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * sources. 82e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 83e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Aside from pushes and pops, a source remains valid until another source 84e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is set or resetVertexSource / resetIndexSource is called. Drawing from 85e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * a reset source is an error. 86e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 87f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * The two types of sources are: 881c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 89f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 1. Reserve. This is most useful when the caller has data it must 9025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * transform before drawing and is not long-lived. The caller requests 9125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * that the draw target make room for some amount of vertex and/or index 9225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data. The target provides ptrs to hold the vertex and/or index data. 9325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 94d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * The data is writable up until the next drawIndexed, drawNonIndexed, 95e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * drawIndexedInstances, drawRect, copySurface, or pushGeometrySource. At 96e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * this point the data is frozen and the ptrs are no longer valid. 971c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 98e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Where the space is allocated and how it is uploaded to the GPU is 99e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * subclass-dependent. 100e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 101f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 2. Vertex and Index Buffers. This is most useful for geometry that will 102e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is long-lived. When the data in the buffer is consumed depends on the 103d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * GrDrawTarget subclass. For deferred subclasses the caller has to 104e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * guarantee that the data is still available in the buffers at playback. 105e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * (TODO: Make this more automatic as we have done for read/write pixels) 1061c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com */ 1071c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com 1081c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com /** 109e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Reserves space for vertices and/or indices. Zero can be specifed as 110e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * either the vertex or index count if the caller desires to only reserve 111d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * space for only indices or only vertices. If zero is specifed for 112e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * vertexCount then the vertex source will be unmodified and likewise for 113e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indexCount. 114ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 115e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the function returns true then the reserve suceeded and the vertices 116e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and indices pointers will point to the space created. 117ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 118e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the target cannot make space for the request then this function will 119e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * return false. If vertexCount was non-zero then upon failure the vertex 120e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * source is reset and likewise for indexCount. 121ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 122e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * The pointers to the space allocated for vertices and indices remain valid 123e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * until a drawIndexed, drawNonIndexed, drawIndexedInstances, drawRect, 124e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * copySurface, or push/popGeomtrySource is called. At that point logically a 125e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * snapshot of the data is made and the pointers are invalid. 1261c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 127e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertexCount the number of vertices to reserve space for. Can be 128b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * 0. Vertex size is queried from the current GrDrawState. 12925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indexCount the number of indices to reserve space for. Can be 0. 130e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertices will point to reserved vertex space if vertexCount is 131d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * non-zero. Illegal to pass NULL if vertexCount > 0. 13225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indices will point to reserved index space if indexCount is 13325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * non-zero. Illegal to pass NULL if indexCount > 0. 13425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 135b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexAndIndexSpace(int vertexCount, 1369853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 13797805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com int indexCount, 13897805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** vertices, 13997805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** indices); 14025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 141ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 142ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Provides hints to caller about the number of vertices and indices 143ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * that can be allocated cheaply. This can be useful if caller is reserving 144ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * space but doesn't know exactly how much geometry is needed. 145ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 146ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Also may hint whether the draw target should be flushed first. This is 147ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * useful for deferred targets. 148ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 149ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount in: hint about how many vertices the caller would 150b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * like to allocate. Vertex size is queried from the 151b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * current GrDrawState. 152ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of vertices that can be 153ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 154ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 155ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount in: hint about how many indices the caller would 156ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * like to allocate. 157ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of indices that can be 158ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 159ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 160ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 161ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @return true if target should be flushed based on the input values. 162ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1639853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) const; 164ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 165ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 166ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of vertex data for the next draw. Data does not have to be 167934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the buffer until drawIndexed, drawNonIndexed, or drawIndexedInstances. 168ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 169ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer vertex buffer containing vertex data. Must be 170ae683921ffda9108147a29da7319c7eee4dc9245skia.committer@gmail.com * unlocked before draw call. Vertex size is queried 171b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * from current GrDrawState. 172ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1739853ccef19c200be93a6211f32589fa82a53067cjoshualitt void setVertexSourceToBuffer(const GrVertexBuffer* buffer, size_t vertexStride); 174ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 175ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 176ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of index data for the next indexed draw. Data does not have 177934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * to be in the buffer until drawIndexed. 178ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 179ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer index buffer containing indices. Must be unlocked 180ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * before indexed draw call. 181ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 182ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void setIndexSourceToBuffer(const GrIndexBuffer* buffer); 183d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 18425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 18525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets vertex source. Drawing from reset vertices is illegal. Set vertex 18625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * source to reserved, array, or buffer before next draw. May be able to free 18725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * up temporary storage allocated by setVertexSourceToArray or 18825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * reserveVertexSpace. 18925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 19025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void resetVertexSource(); 191d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 19225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 19325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets index source. Indexed Drawing from reset indices is illegal. Set 19425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * index source to reserved, array, or buffer before next indexed draw. May 19525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be able to free up temporary storage allocated by setIndexSourceToArray 19625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * or reserveIndexSpace. 19725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 19897805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void resetIndexSource(); 199d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 20097805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com /** 20197805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com * Query to find out if the vertex or index source is reserved. 20297805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com */ 20397805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com bool hasReservedVerticesOrIndices() const { 20473d98aace4f74acc39d8de33484c8aec8e917739bsalomon@google.com return kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc || 20597805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc; 20697805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com } 207ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 208ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 20925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pushes and resets the vertex/index sources. Any reserved vertex / index 21025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data is finalized (i.e. cannot be updated after the matching pop but can 21125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be drawn from). Must be balanced by a pop. 21225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 21325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void pushGeometrySource(); 21425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 21525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 21625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pops the vertex / index sources from the matching push. 21725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 21825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void popGeometrySource(); 21964aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 22025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 221ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws indexed geometry using the current state and current vertex / index 222ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 223ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 224ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 225ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 226ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 227ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startIndex first index to read from index src. 228ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 229ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount the number of index elements to read. The index count 230ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * is effectively trimmed to the last completely 231ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * specified primitive. 232d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 233d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 234ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2359853ccef19c200be93a6211f32589fa82a53067cjoshualitt void drawIndexed(GrDrawState*, 23656995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2379853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 23825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 23925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startIndex, 24025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 241d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int indexCount, 242d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 243ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 244ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 245ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws non-indexed geometry using the current state and current vertex 246ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 247ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 248ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 249ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 250ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 251ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 252d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 253d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 254ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2559853ccef19c200be93a6211f32589fa82a53067cjoshualitt void drawNonIndexed(GrDrawState*, 25656995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2579853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 25825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 259d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int vertexCount, 260d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 261ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 26286afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com /** 26364aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * Draws path into the stencil buffer. The fill must be either even/odd or 26464aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * winding (not inverse or hairline). It will respect the HW antialias flag 26592e496f96abbd664888f0c8a7d546ab02e703bf7joshualitt * on the draw state (if possible in the 3D API). Note, we will never have an inverse fill 26692e496f96abbd664888f0c8a7d546ab02e703bf7joshualitt * with stencil path 26764aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com */ 26856995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt void stencilPath(GrDrawState*, const GrPathProcessor*, const GrPath*,GrPathRendering::FillType); 26964aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 27064aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com /** 27132184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org * Draws a path. Fill must not be a hairline. It will respect the HW 272c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org * antialias flag on the draw state (if possible in the 3D API). 273c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org */ 27456995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt void drawPath(GrDrawState*, const GrPathProcessor*, const GrPath*, GrPathRendering::FillType); 275c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org 276c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org /** 27755b24afc178e641e17a5664beba7ab2b4982c91acdalton * Draws the aggregate path from combining multiple. Note that this will not 27855b24afc178e641e17a5664beba7ab2b4982c91acdalton * always be equivalent to back-to-back calls to drawPath(). It will respect 27955b24afc178e641e17a5664beba7ab2b4982c91acdalton * the HW antialias flag on the draw state (if possible in the 3D API). 2809b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org * 28155b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param pathRange Source paths to draw from 28255b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indices Array of path indices to draw 28355b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indexType Data type of the array elements in indexBuffer 28455b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformValues Array of transforms for the individual paths 28555b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformType Type of transforms in transformBuffer 28655b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param count Number of paths to draw 287b85a0aab6905af8b329539b7573a7555b727d5e5cdalton * @param fill Fill type for drawing all the paths 288b85a0aab6905af8b329539b7573a7555b727d5e5cdalton */ 2892e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt void drawPaths(GrDrawState*, 29056995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 2912e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt const GrPathRange* pathRange, 29255b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 29355b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType indexType, 29455b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 29555b24afc178e641e17a5664beba7ab2b4982c91acdalton PathTransformType transformType, 2969853ccef19c200be93a6211f32589fa82a53067cjoshualitt int count, 29792e496f96abbd664888f0c8a7d546ab02e703bf7joshualitt GrPathRendering::FillType fill); 298b85a0aab6905af8b329539b7573a7555b727d5e5cdalton 2999b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org /** 3000406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * Helper function for drawing rects. It performs a geometry src push and pop 3010406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * and thus will finalize any reserved geometry. 302044679ef8c08e1f01afadf5bc08251fe8597df81skia.committer@gmail.com * 303c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param rect the rect to draw 304c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param localRect optional rect that specifies local coords to map onto 305c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * rect. If NULL then rect serves as the local coords. 306c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param localMatrix optional matrix applied to localRect. If 307044679ef8c08e1f01afadf5bc08251fe8597df81skia.committer@gmail.com * srcRect is non-NULL and srcMatrix is non-NULL 308044679ef8c08e1f01afadf5bc08251fe8597df81skia.committer@gmail.com * then srcRect will be transformed by srcMatrix. 3093976825a21532e254311b90b4a9046e25717e335jvanverth@google.com * srcMatrix can be NULL when no srcMatrix is desired. 31086afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com */ 3119853ccef19c200be93a6211f32589fa82a53067cjoshualitt void drawRect(GrDrawState* ds, 3122e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 3139853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 314fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 3150406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com const SkMatrix* localMatrix) { 3160406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com AutoGeometryPush agp(this); 3172e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt this->onDrawRect(ds, color, rect, localRect, localMatrix); 3180406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com } 3193976825a21532e254311b90b4a9046e25717e335jvanverth@google.com 320cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com /** 321c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * Helper for drawRect when the caller doesn't need separate local rects or matrices. 322cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com */ 3232e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt void drawSimpleRect(GrDrawState* ds, GrColor color, const SkRect& rect) { 3242e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt this->drawRect(ds, color, rect, NULL, NULL); 325cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com } 3262e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt void drawSimpleRect(GrDrawState* ds, GrColor color, const SkIRect& irect) { 3274469938e92d779dff05e745559e67907bbf21e78reed@google.com SkRect rect = SkRect::Make(irect); 3282e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt this->drawRect(ds, color, rect, NULL, NULL); 329cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com } 33086afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com 33186afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com /** 332934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * This call is used to draw multiple instances of some geometry with a 333934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * given number of vertices (V) and indices (I) per-instance. The indices in 334934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * the index source must have the form i[k+I] == i[k] + V. Also, all indices 335934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a 336934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * concrete example, the following index buffer for drawing a series of 337934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * quads each as two triangles each satisfies these conditions with V=4 and 338934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * I=6: 339934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * (0,1,2,0,2,3, 4,5,6,4,6,7, 8,9,10,8,10,11, ...) 340934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * 341934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * The call assumes that the pattern of indices fills the entire index 342934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * source. The size of the index buffer limits the number of instances that 343934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * can be drawn by the GPU in a single draw. However, the caller may specify 344934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * any (positive) number for instanceCount and if necessary multiple GPU 345d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * draws will be issued. Moreover, when drawIndexedInstances is called 346934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * multiple times it may be possible for GrDrawTarget to group them into a 347934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * single GPU draw. 348934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * 349934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param type the type of primitives to draw 350934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param instanceCount the number of instances to draw. Each instance 351934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * consists of verticesPerInstance vertices indexed by 352934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * indicesPerInstance indices drawn as the primitive 353934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * type specified by type. 354934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param verticesPerInstance The number of vertices in each instance (V 355934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the above description). 356934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param indicesPerInstance The number of indices in each instance (I 357934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the above description). 358d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 359d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 360934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com */ 3619853ccef19c200be93a6211f32589fa82a53067cjoshualitt void drawIndexedInstances(GrDrawState*, 36256995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 3639853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 364d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int instanceCount, 365d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int verticesPerInstance, 366d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int indicesPerInstance, 367d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 368934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com 369934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com /** 37089c62980c1eb50b2090f33312086c7e8c66739b4bsalomon * Clear the passed in render target. Ignores the draw state and clip. Clears the whole thing if 37189c62980c1eb50b2090f33312086c7e8c66739b4bsalomon * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the entire render target 37289c62980c1eb50b2090f33312086c7e8c66739b4bsalomon * can be optionally cleared. 3730b335c1ac100aeacf79a4c98a052286fd46661e7bsalomon@google.com */ 3749853ccef19c200be93a6211f32589fa82a53067cjoshualitt void clear(const SkIRect* rect, 3759853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrColor color, 3769853ccef19c200be93a6211f32589fa82a53067cjoshualitt bool canIgnoreRect, 37763b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon GrRenderTarget* renderTarget); 378a9493a3c78f6eb82635ece960b4f16918b885428skia.committer@gmail.com 379e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com /** 38089c62980c1eb50b2090f33312086c7e8c66739b4bsalomon * Discards the contents render target. 38128361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org **/ 38289c62980c1eb50b2090f33312086c7e8c66739b4bsalomon virtual void discard(GrRenderTarget*) = 0; 38328361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org 38428361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org /** 3852a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * Called at start and end of gpu trace marking 3862a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start 3872a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * and end of a code block respectively 388a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org */ 3893eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void addGpuTraceMarker(const GrGpuTraceMarker* marker); 3903eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void removeGpuTraceMarker(const GrGpuTraceMarker* marker); 3913eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel 3923eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel /** 3933eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * Takes the current active set of markers and stores them for later use. Any current marker 3943eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * in the active set is removed from the active set and the targets remove function is called. 3953eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * These functions do not work as a stack so you cannot call save a second time before calling 3963eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * restore. Also, it is assumed that when restore is called the current active set of markers 3973eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * is empty. When the stored markers are added back into the active set, the targets add marker 3983eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * is called. 3993eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel */ 4003eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void saveActiveTraceMarkers(); 4013eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void restoreActiveTraceMarkers(); 402a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org 403a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org /** 404e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * Copies a pixel rectangle from one surface to another. This call may finalize 405e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * reserved vertex/index data (as though a draw call was made). The src pixels 406e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * copied are specified by srcRect. They are copied to a rect of the same 407e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * size in dst with top left at dstPoint. If the src rect is clipped by the 408e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * src bounds then pixel values in the dst rect corresponding to area clipped 409e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * by the src rect are not overwritten. This method can fail and return false 410e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * depending on the type of surface, configs, etc, and the backend-specific 411e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * limitations. If rect is clipped out entirely by the src or dst bounds then 412e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * true is returned since there is no actual copy necessary to succeed. 413e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com */ 414f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool copySurface(GrSurface* dst, 415f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon GrSurface* src, 416f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 417f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint); 418116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com /** 419f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * Function that determines whether a copySurface call would succeed without actually 420116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com * performing the copy. 421116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com */ 422f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool canCopySurface(const GrSurface* dst, 423f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 424f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 425f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint); 426eb85117c05471e1a55ce387cbc38279f857a4584bsalomon@google.com 427eb85117c05471e1a55ce387cbc38279f857a4584bsalomon@google.com /** 428ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com * Release any resources that are cached but not currently in use. This 429ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com * is intended to give an application some recourse when resources are low. 430ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com */ 431ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com virtual void purgeResources() {}; 432ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com 43325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com //////////////////////////////////////////////////////////////////////////// 4341c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com 435a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org class AutoReleaseGeometry : public ::SkNoncopyable { 436ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com public: 437ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com AutoReleaseGeometry(GrDrawTarget* target, 43825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 4399853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 44025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int indexCount); 44125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com AutoReleaseGeometry(); 44225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com ~AutoReleaseGeometry(); 4435782d712ffc31557d0cb12d5a220cebb783f6895bsalomon@google.com bool set(GrDrawTarget* target, 44425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 4459853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 44625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int indexCount); 44749f085dddff10473b6ebf832a974288300224e60bsalomon bool succeeded() const { return SkToBool(fTarget); } 448f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org void* vertices() const { SkASSERT(this->succeeded()); return fVertices; } 449f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org void* indices() const { SkASSERT(this->succeeded()); return fIndices; } 450972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org SkPoint* positions() const { 451972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org return static_cast<SkPoint*>(this->vertices()); 452ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com } 453ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 454ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com private: 45525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void reset(); 456d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 457ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com GrDrawTarget* fTarget; 458ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void* fVertices; 459ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void* fIndices; 460ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 461ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 46225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com //////////////////////////////////////////////////////////////////////////// 463ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 464a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org class AutoClipRestore : public ::SkNoncopyable { 465ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com public: 466ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com AutoClipRestore(GrDrawTarget* target) { 467ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com fTarget = target; 468ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com fClip = fTarget->getClip(); 469ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com } 470ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 4718d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com AutoClipRestore(GrDrawTarget* target, const SkIRect& newClip); 4728d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com 473ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com ~AutoClipRestore() { 474ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com fTarget->setClip(fClip); 475ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com } 476ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com private: 4778d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com GrDrawTarget* fTarget; 4788d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com const GrClipData* fClip; 4798d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com SkTLazy<SkClipStack> fStack; 4808d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com GrClipData fReplacementClip; 481ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 482d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 48325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com //////////////////////////////////////////////////////////////////////////// 484d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 4850406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com /** 4860406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * Saves the geometry src state at construction and restores in the destructor. It also saves 4870406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * and then restores the vertex attrib state. 4880406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com */ 489a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org class AutoGeometryPush : public ::SkNoncopyable { 4900406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com public: 4919853ccef19c200be93a6211f32589fa82a53067cjoshualitt AutoGeometryPush(GrDrawTarget* target) { 49249f085dddff10473b6ebf832a974288300224e60bsalomon SkASSERT(target); 4930406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com fTarget = target; 4940406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com target->pushGeometrySource(); 4950406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com } 4960406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com 4970406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com ~AutoGeometryPush() { fTarget->popGeometrySource(); } 4980406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com 4990406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com private: 5000406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com GrDrawTarget* fTarget; 50125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 502ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 503a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org /////////////////////////////////////////////////////////////////////////// 504a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // Draw execution tracking (for font atlases and other resources) 505a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org class DrawToken { 506a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org public: 507a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org DrawToken(GrDrawTarget* drawTarget, uint32_t drawID) : 508a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org fDrawTarget(drawTarget), fDrawID(drawID) {} 5097475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 51049f085dddff10473b6ebf832a974288300224e60bsalomon bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID); } 5117475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 512a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org private: 513a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org GrDrawTarget* fDrawTarget; 514a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org uint32_t fDrawID; // this may wrap, but we're doing direct comparison 515a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // so that should be okay 516a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org }; 5177475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 518a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } 5197475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 5203322fa432a96fdc94d54f2475faf918dfa05b919joshualitt /** 5213322fa432a96fdc94d54f2475faf918dfa05b919joshualitt * Used to communicate draws to GPUs / subclasses 5223322fa432a96fdc94d54f2475faf918dfa05b919joshualitt */ 5233322fa432a96fdc94d54f2475faf918dfa05b919joshualitt class DrawInfo { 5243322fa432a96fdc94d54f2475faf918dfa05b919joshualitt public: 5253322fa432a96fdc94d54f2475faf918dfa05b919joshualitt DrawInfo(const DrawInfo& di) { (*this) = di; } 5263322fa432a96fdc94d54f2475faf918dfa05b919joshualitt DrawInfo& operator =(const DrawInfo& di); 5273322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5283322fa432a96fdc94d54f2475faf918dfa05b919joshualitt GrPrimitiveType primitiveType() const { return fPrimitiveType; } 5293322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int startVertex() const { return fStartVertex; } 5303322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int startIndex() const { return fStartIndex; } 5313322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int vertexCount() const { return fVertexCount; } 5323322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int indexCount() const { return fIndexCount; } 5333322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int verticesPerInstance() const { return fVerticesPerInstance; } 5343322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int indicesPerInstance() const { return fIndicesPerInstance; } 5353322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int instanceCount() const { return fInstanceCount; } 5363322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5373322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isIndexed() const { return fIndexCount > 0; } 5383322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#ifdef SK_DEBUG 5393322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isInstanced() const; // this version is longer because of asserts 5403322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#else 5413322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isInstanced() const { return fInstanceCount > 0; } 5423322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#endif 5433322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5443322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // adds or remove instances 5453322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustInstanceCount(int instanceOffset); 5463322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // shifts the start vertex 5473322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustStartVertex(int vertexOffset); 5483322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // shifts the start index 5493322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustStartIndex(int indexOffset); 5503322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5513322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void setDevBounds(const SkRect& bounds) { 5523322fa432a96fdc94d54f2475faf918dfa05b919joshualitt fDevBoundsStorage = bounds; 5533322fa432a96fdc94d54f2475faf918dfa05b919joshualitt fDevBounds = &fDevBoundsStorage; 5543322fa432a96fdc94d54f2475faf918dfa05b919joshualitt } 5557eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } 5567eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } 5577eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt void setVertexBuffer(const GrVertexBuffer* vb) { 5587eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt fVertexBuffer.reset(vb); 5597eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt } 5607eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt void setIndexBuffer(const GrIndexBuffer* ib) { 5617eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt fIndexBuffer.reset(ib); 5627eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt } 5633322fa432a96fdc94d54f2475faf918dfa05b919joshualitt const SkRect* getDevBounds() const { return fDevBounds; } 5643322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5653322fa432a96fdc94d54f2475faf918dfa05b919joshualitt private: 5663322fa432a96fdc94d54f2475faf918dfa05b919joshualitt DrawInfo() { fDevBounds = NULL; } 5673322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5683322fa432a96fdc94d54f2475faf918dfa05b919joshualitt friend class GrDrawTarget; 5693322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5703322fa432a96fdc94d54f2475faf918dfa05b919joshualitt GrPrimitiveType fPrimitiveType; 5713322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5723322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fStartVertex; 5733322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fStartIndex; 5743322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fVertexCount; 5753322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fIndexCount; 5763322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5773322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fInstanceCount; 5783322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fVerticesPerInstance; 5793322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fIndicesPerInstance; 5803322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5813322fa432a96fdc94d54f2475faf918dfa05b919joshualitt SkRect fDevBoundsStorage; 5823322fa432a96fdc94d54f2475faf918dfa05b919joshualitt SkRect* fDevBounds; 5833322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5847eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer; 5857eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer; 5863322fa432a96fdc94d54f2475faf918dfa05b919joshualitt }; 5872c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 588371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon /** 589371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon * Used to populate the vertex and index buffer on the draw info before onDraw is called. 590371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon */ 591371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon virtual void setDrawBuffers(DrawInfo*, size_t vertexStride) = 0;; 5922c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt bool programUnitTest(int maxStages); 5932c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 594ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comprotected: 59525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum GeometrySrcType { 59625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kNone_GeometrySrcType, //<! src has not been specified 59725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kReserved_GeometrySrcType, //<! src was set using reserve*Space 59825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer 59925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 600d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 60125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com struct GeometrySrcState { 60225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fVertexSrc; 60325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 60425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 60525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrVertexBuffer* fVertexBuffer; 60625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 60725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fVertexCount; 60825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 609d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 61025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fIndexSrc; 61125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 61225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 61325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrIndexBuffer* fIndexBuffer; 61425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 61525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fIndexCount; 61625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 617d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 618b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t fVertexSize; 61925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 620934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com 621934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com int indexCountInCurrentSource() const { 622934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com const GeometrySrcState& src = this->getGeomSrc(); 623934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com switch (src.fIndexSrc) { 624934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kNone_GeometrySrcType: 625934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 626934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kReserved_GeometrySrcType: 627934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return src.fIndexCount; 628934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kBuffer_GeometrySrcType: 629089a780c3355129eefc942246534bc1f126b8ccbcommit-bot@chromium.org return static_cast<int>(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); 630934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com default: 63188cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org SkFAIL("Unexpected Index Source."); 632934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 633934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 634934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 635a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com 6366e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* getContext() { return fContext; } 6376e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com const GrContext* getContext() const { return fContext; } 6386e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com 63902ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclasses must call this in their destructors to ensure all vertex 64002ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // and index sources have been released (including those held by 64102ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // pushGeometrySource()) 64202ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com void releaseGeometry(); 64302ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 64402ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // accessors for derived classes 64502ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com const GeometrySrcState& getGeomSrc() const { return fGeoSrcStateStack.back(); } 646b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com // it is preferable to call this rather than getGeomSrc()->fVertexSize because of the assert. 647b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t getVertexSize() const { 64802ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // the vertex layout is only valid if a vertex source has been specified. 649f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); 650b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com return this->getGeomSrc().fVertexSize; 651a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com } 6525782d712ffc31557d0cb12d5a220cebb783f6895bsalomon@google.com 653bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com // Subclass must initialize this in its constructor. 654c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com SkAutoTUnref<const GrDrawTargetCaps> fCaps; 65502ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 6562a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; } 6572a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org 658651713408c5a5d9565665967ad09981250c7a8c9joshualitt // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required 659651713408c5a5d9565665967ad09981250c7a8c9joshualitt // but couldn't be made. Otherwise, returns true. This method needs to be protected because it 660651713408c5a5d9565665967ad09981250c7a8c9joshualitt // needs to be accessed by GLPrograms to setup a correct drawstate 6619853ccef19c200be93a6211f32589fa82a53067cjoshualitt bool setupDstReadIfNecessary(GrDrawState*, 66256995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPrimitiveProcessor*, 6639853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrDeviceCoordTexture* dstCopy, 6649853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect* drawBounds); 665651713408c5a5d9565665967ad09981250c7a8c9joshualitt 66602ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.comprivate: 667f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 668f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture as a dst for copySurface. This function 669f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * populates the dstDesc's config, flags, and origin so as to maximize efficiency and guarantee 670f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * success of the copySurface call. 671f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 672f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { 673f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { 674f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fOrigin = kDefault_GrSurfaceOrigin; 675f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag; 676f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fConfig = src->config(); 677f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 678f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 679f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 680f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Internal implementation of canCopySurface. */ 681f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool internalCanCopySurface(const GrSurface* dst, 682f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 683f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& clippedSrcRect, 684f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& clippedDstRect); 685f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 68602ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // A subclass can optionally overload this function to be notified before 68702ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // vertex and index space is reserved. 6889853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void willReserveVertexAndIndexSpace(int vertexCount, 6899853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 6909853ccef19c200be93a6211f32589fa82a53067cjoshualitt int indexCount) {} 69197805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com 69225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to allocate space for reserved geom 693a63389843dd18003382d61c2e4610af09ed07d38jvanverth@google.com virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; 69425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; 69525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to handle release of reserved geom space 69625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedVertexSpace() = 0; 69725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedIndexSpace() = 0; 69802ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclass overrides to be notified just before geo src state is pushed/popped. 69925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPush() = 0; 70025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 70125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // subclass called to perform drawing 7029853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void onDraw(const GrDrawState&, 70356995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 7049853ccef19c200be93a6211f32589fa82a53067cjoshualitt const DrawInfo&, 7059176e2c159089458b1e2226a94fab1af0fba32acjoshualitt const GrClipMaskManager::ScissorState&, 7069176e2c159089458b1e2226a94fab1af0fba32acjoshualitt const GrDeviceCoordTexture* dstCopy) = 0; 7075478d427c6e67c986a3390162c8fec77c466058ajoshualitt // TODO copy in order drawbuffer onDrawRect to here 7089853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void onDrawRect(GrDrawState*, 7092e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 7109853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 711fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 7125478d427c6e67c986a3390162c8fec77c466058ajoshualitt const SkMatrix* localMatrix) = 0; 71332184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org 7149853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void onStencilPath(const GrDrawState&, 71556995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 7169853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7172c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrClipMaskManager::ScissorState&, 7182c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&) = 0; 7199853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void onDrawPath(const GrDrawState&, 72056995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 7219853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7222c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrClipMaskManager::ScissorState&, 7232c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 724c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org const GrDeviceCoordTexture* dstCopy) = 0; 7259853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual void onDrawPaths(const GrDrawState&, 72656995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 7279853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPathRange*, 72855b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 72955b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType, 73055b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 7312c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt PathTransformType, 73255b24afc178e641e17a5664beba7ab2b4982c91acdalton int count, 7332c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrClipMaskManager::ScissorState&, 7342c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 7352c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrDeviceCoordTexture*) = 0; 73664aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 73763b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, 73863b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon GrRenderTarget* renderTarget) = 0; 73963b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 740f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** The subclass will get a chance to copy the surface for falling back to the default 741f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon implementation, which simply draws a rectangle (and fails if dst isn't a render target). It 742f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon should assume that any clipping has already been performed on the rect and point. It won't 743f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon be called if the copy can be skipped. */ 744f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCopySurface(GrSurface* dst, 745f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon GrSurface* src, 746f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 747f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 748f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 749f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Indicates whether onCopySurface would succeed. It should assume that any clipping has 750f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon already been performed on the rect and point. It won't be called if the copy can be 751f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon skipped. */ 752f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCanCopySurface(const GrSurface* dst, 753f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 754f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 755f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 756f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 757f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture to be a dst for onCopySurface. Only the 758f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * dstDesc's config, flags, and origin need be set by the function. If the subclass cannot 759f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * create a surface that would succeed its implementation of onCopySurface, it should return 760f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * false. The base class will fall back to creating a render target to draw into using the src. 761f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 762f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onInitCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) = 0; 76363b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 764e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com // helpers for reserving vertex and index space. 765b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexSpace(size_t vertexSize, 766e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com int vertexCount, 767e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com void** vertices); 768e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com bool reserveIndexSpace(int indexCount, void** indices); 769d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 770e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // called by drawIndexed and drawNonIndexed. Use a negative indexCount to 771e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // indicate non-indexed drawing. 7729853ccef19c200be93a6211f32589fa82a53067cjoshualitt bool checkDraw(const GrDrawState&, 77356995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 7749853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 7759853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startVertex, 7769853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startIndex, 7779853ccef19c200be93a6211f32589fa82a53067cjoshualitt int vertexCount, 778e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com int indexCount) const; 77925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // called when setting a new vert/idx source to unref prev vb/ib 78025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousVertexSource(); 78125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousIndexSource(); 782d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 783a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // Check to see if this set of draw commands has been sent out 784a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org virtual bool isIssued(uint32_t drawID) { return true; } 7859853ccef19c200be93a6211f32589fa82a53067cjoshualitt void getPathStencilSettingsForFilltype(GrPathRendering::FillType, 7869853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrStencilBuffer*, 7879853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrStencilSettings*); 788a702415d9e80f5631181143c293498de924e8ae4joshualitt virtual GrClipMaskManager* clipMaskManager() = 0; 7892c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt virtual bool setupClip(const SkRect* devBounds, 7902c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrDrawState::AutoRestoreEffects* are, 7912c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrDrawState::AutoRestoreStencil* ars, 7929853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrDrawState*, 7932c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrClipMaskManager::ScissorState* scissorState) = 0; 7947475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 79525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum { 79625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kPreallocGeoSrcStateStackCnt = 4, 797ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 79802ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcStateStack; 79902ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com const GrClipData* fClip; 8006e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTarget. 8016e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* fContext; 8022a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org // To keep track that we always have at least as many debug marker adds as removes 8032a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org int fGpuTraceMarkerCount; 8042a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org GrTraceMarkerSet fActiveTraceMarkers; 8053eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel GrTraceMarkerSet fStoredTraceMarkers; 806fa35e3ddcc9d130ce87c927218bdf27879c38711reed@google.com 807a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org typedef SkRefCnt INHERITED; 808ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}; 809ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 810329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt/* 811329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * This class is JUST for clip mask manager. Everyone else should just use draw target above. 812329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 8136db519c42471aaaa8a8e1a3ece314014481ab832joshualittclass GrClipTarget : public GrDrawTarget { 8146db519c42471aaaa8a8e1a3ece314014481ab832joshualittpublic: 815329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipTarget(GrContext* context) : INHERITED(context) { 816329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt fClipMaskManager.setClipTarget(this); 817329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt } 818329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 819329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt /* Clip mask manager needs access to the context. 820329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * TODO we only need a very small subset of context in the CMM. 821329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 822329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrContext* getContext() { return INHERITED::getContext(); } 823329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt const GrContext* getContext() const { return INHERITED::getContext(); } 824329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8256db519c42471aaaa8a8e1a3ece314014481ab832joshualitt /** 8266db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * Clip Mask Manager(and no one else) needs to clear private stencil bits. 8276db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * ClipTarget subclass sets clip bit in the stencil buffer. The subclass 8286db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * is free to clear the remaining bits to zero if masked clears are more 8296db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * expensive than clearing all bits. 8306db519c42471aaaa8a8e1a3ece314014481ab832joshualitt */ 8316db519c42471aaaa8a8e1a3ece314014481ab832joshualitt virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* = NULL) = 0; 8326db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 8333bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt /** 8343bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * Release any resources that are cached but not currently in use. This 8353bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * is intended to give an application some recourse when resources are low. 8363bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt */ 8373bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt virtual void purgeResources() SK_OVERRIDE { 8383bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // The clip mask manager can rebuild all its clip masks so just 8393bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // get rid of them all. 8403bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt fClipMaskManager.purgeResources(); 8413bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt }; 8423bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt 843329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualittprotected: 844329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipMaskManager fClipMaskManager; 845329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8466db519c42471aaaa8a8e1a3ece314014481ab832joshualittprivate: 847a702415d9e80f5631181143c293498de924e8ae4joshualitt GrClipMaskManager* clipMaskManager() { return &fClipMaskManager; } 848329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8492c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt virtual bool setupClip(const SkRect* devBounds, 8502c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrDrawState::AutoRestoreEffects* are, 8512c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrDrawState::AutoRestoreStencil* ars, 8529853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrDrawState*, 8532c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt GrClipMaskManager::ScissorState* scissorState) SK_OVERRIDE; 8542c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 8556db519c42471aaaa8a8e1a3ece314014481ab832joshualitt typedef GrDrawTarget INHERITED; 8566db519c42471aaaa8a8e1a3ece314014481ab832joshualitt}; 8576db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 858ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif 859