GrDrawTarget.h revision 44701df5ce572ac3cccec785cf52103d3d5d14a5
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 1144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt#include "GrClip.h" 126db519c42471aaaa8a8e1a3ece314014481ab832joshualitt#include "GrClipMaskManager.h" 132a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org#include "GrContext.h" 148072caa80384292858d31ae34b7e19768875866bjoshualitt#include "GrPathProcessor.h" 158072caa80384292858d31ae34b7e19768875866bjoshualitt#include "GrPrimitiveProcessor.h" 16934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com#include "GrIndexBuffer.h" 17ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen#include "GrPathRendering.h" 188dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel#include "GrPipelineBuilder.h" 192a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org#include "GrTraceMarker.h" 207eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt#include "GrVertexBuffer.h" 21ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 228d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com#include "SkClipStack.h" 23a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org#include "SkMatrix.h" 2412b4e27ae1a29460e91a59f38122483e1faec697sugoi@google.com#include "SkPath.h" 259b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org#include "SkStrokeRec.h" 26a2d71482db8b6d752a51c96da74768d7dfc27932robertphillips@google.com#include "SkTArray.h" 27a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org#include "SkTLazy.h" 28a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org#include "SkTypes.h" 298d67c0711b52226db59158a0cfce09f35badd96absalomon@google.com#include "SkXfermode.h" 3097c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo 314d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualittclass GrBatch; 3244701df5ce572ac3cccec785cf52103d3d5d14a5joshualittclass GrClip; 33c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.comclass GrDrawTargetCaps; 3464aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.comclass GrPath; 35b85a0aab6905af8b329539b7573a7555b727d5e5cdaltonclass GrPathRange; 36e36914cb205699526988127a827d1a76c9a98d39egdanielclass GrPipeline; 3712b4e27ae1a29460e91a59f38122483e1faec697sugoi@google.com 38a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.orgclass GrDrawTarget : public SkRefCnt { 39bcce8926524827775539874346dd424a9510dbc9bsalomon@google.compublic: 40bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com SK_DECLARE_INST_COUNT(GrDrawTarget) 41bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com 4255b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRange::PathIndexType PathIndexType; 4355b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRendering::PathTransformType PathTransformType; 44ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen 45ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /////////////////////////////////////////////////////////////////////////// 46ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 476e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context may not be fully constructed and should not be used during GrDrawTarget 486e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // construction. 496e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrDrawTarget(GrContext* context); 5025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual ~GrDrawTarget(); 51ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 52ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 5318c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com * Gets the capabilities of the draw target. 5418c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com */ 55c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com const GrDrawTargetCaps* caps() const { return fCaps.get(); } 5618c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com 5718c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com /** 58f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * There are two types of "sources" of geometry (vertices and indices) for 59e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * draw calls made on the target. When performing an indexed draw, the 60e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indices and vertices can use different source types. Once a source is 61934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * specified it can be used for multiple draws. However, the time at which 62934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * the geometry data is no longer editable depends on the source type. 6325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 6425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Sometimes it is necessary to perform a draw while upstack code has 65e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * already specified geometry that it isn't finished with. So there are push 66e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and pop methods. This allows the client to push the sources, draw 67e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * something using alternate sources, and then pop to restore the original 68e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * sources. 69e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 70e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Aside from pushes and pops, a source remains valid until another source 71e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is set or resetVertexSource / resetIndexSource is called. Drawing from 72e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * a reset source is an error. 73e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 74f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * The two types of sources are: 751c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 76f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 1. Reserve. This is most useful when the caller has data it must 7725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * transform before drawing and is not long-lived. The caller requests 7825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * that the draw target make room for some amount of vertex and/or index 7925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data. The target provides ptrs to hold the vertex and/or index data. 8025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 81d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * The data is writable up until the next drawIndexed, drawNonIndexed, 82e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * drawIndexedInstances, drawRect, copySurface, or pushGeometrySource. At 83e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * this point the data is frozen and the ptrs are no longer valid. 841c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 85e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Where the space is allocated and how it is uploaded to the GPU is 86e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * subclass-dependent. 87e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 88f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 2. Vertex and Index Buffers. This is most useful for geometry that will 89e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is long-lived. When the data in the buffer is consumed depends on the 90d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * GrDrawTarget subclass. For deferred subclasses the caller has to 91e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * guarantee that the data is still available in the buffers at playback. 92e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * (TODO: Make this more automatic as we have done for read/write pixels) 931c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com */ 941c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com 951c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com /** 96e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Reserves space for vertices and/or indices. Zero can be specifed as 97e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * either the vertex or index count if the caller desires to only reserve 98d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * space for only indices or only vertices. If zero is specifed for 99e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * vertexCount then the vertex source will be unmodified and likewise for 100e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indexCount. 101ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 102e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the function returns true then the reserve suceeded and the vertices 103e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and indices pointers will point to the space created. 104ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 105e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the target cannot make space for the request then this function will 106e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * return false. If vertexCount was non-zero then upon failure the vertex 107e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * source is reset and likewise for indexCount. 108ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 109e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * The pointers to the space allocated for vertices and indices remain valid 110e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * until a drawIndexed, drawNonIndexed, drawIndexedInstances, drawRect, 111e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * copySurface, or push/popGeomtrySource is called. At that point logically a 112e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * snapshot of the data is made and the pointers are invalid. 1131c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 114e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertexCount the number of vertices to reserve space for. Can be 1158dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * 0. Vertex size is queried from the current GrPipelineBuilder. 11625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indexCount the number of indices to reserve space for. Can be 0. 117e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertices will point to reserved vertex space if vertexCount is 118d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * non-zero. Illegal to pass NULL if vertexCount > 0. 11925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indices will point to reserved index space if indexCount is 12025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * non-zero. Illegal to pass NULL if indexCount > 0. 12125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 122b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexAndIndexSpace(int vertexCount, 1239853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 12497805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com int indexCount, 12597805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** vertices, 12697805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** indices); 12725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 128ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 129ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Provides hints to caller about the number of vertices and indices 130ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * that can be allocated cheaply. This can be useful if caller is reserving 131ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * space but doesn't know exactly how much geometry is needed. 132ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 133ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Also may hint whether the draw target should be flushed first. This is 134ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * useful for deferred targets. 135ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 136ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount in: hint about how many vertices the caller would 137b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * like to allocate. Vertex size is queried from the 1388dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * current GrPipelineBuilder. 139ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of vertices that can be 140ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 141ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 142ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount in: hint about how many indices the caller would 143ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * like to allocate. 144ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of indices that can be 145ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 146ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 147ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 148ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @return true if target should be flushed based on the input values. 149ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1509853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) const; 151ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 152ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 153ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of vertex data for the next draw. Data does not have to be 154934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the buffer until drawIndexed, drawNonIndexed, or drawIndexedInstances. 155ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 156ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer vertex buffer containing vertex data. Must be 157ae683921ffda9108147a29da7319c7eee4dc9245skia.committer@gmail.com * unlocked before draw call. Vertex size is queried 1588dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * from current GrPipelineBuilder. 159ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1609853ccef19c200be93a6211f32589fa82a53067cjoshualitt void setVertexSourceToBuffer(const GrVertexBuffer* buffer, size_t vertexStride); 161ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 162ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 163ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of index data for the next indexed draw. Data does not have 164934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * to be in the buffer until drawIndexed. 165ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 166ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer index buffer containing indices. Must be unlocked 167ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * before indexed draw call. 168ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 169ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void setIndexSourceToBuffer(const GrIndexBuffer* buffer); 170d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 17125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 17225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets vertex source. Drawing from reset vertices is illegal. Set vertex 17325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * source to reserved, array, or buffer before next draw. May be able to free 17425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * up temporary storage allocated by setVertexSourceToArray or 17525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * reserveVertexSpace. 17625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 17725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void resetVertexSource(); 178d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 17925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 18025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets index source. Indexed Drawing from reset indices is illegal. Set 18125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * index source to reserved, array, or buffer before next indexed draw. May 18225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be able to free up temporary storage allocated by setIndexSourceToArray 18325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * or reserveIndexSpace. 18425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 18597805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void resetIndexSource(); 186d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 18797805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com /** 18897805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com * Query to find out if the vertex or index source is reserved. 18997805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com */ 19097805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com bool hasReservedVerticesOrIndices() const { 19173d98aace4f74acc39d8de33484c8aec8e917739bsalomon@google.com return kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc || 19297805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc; 19397805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com } 194ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 195ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 19625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pushes and resets the vertex/index sources. Any reserved vertex / index 19725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data is finalized (i.e. cannot be updated after the matching pop but can 19825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be drawn from). Must be balanced by a pop. 19925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 20025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void pushGeometrySource(); 20125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 20225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 20325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pops the vertex / index sources from the matching push. 20425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 20525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void popGeometrySource(); 20664aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 20725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 208ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws indexed geometry using the current state and current vertex / index 209ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 210ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 211ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 212ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 213ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 214ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startIndex first index to read from index src. 215ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 216ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount the number of index elements to read. The index count 217ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * is effectively trimmed to the last completely 218ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * specified primitive. 219d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 220d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 221ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2228dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawIndexed(GrPipelineBuilder*, 22356995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2249853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 22525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 22625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startIndex, 22725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 228d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int indexCount, 229d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 230ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 231ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 232ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws non-indexed geometry using the current state and current vertex 233ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 234ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 235ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 236ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 237ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 238ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 239d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 240d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 241ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2428dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawNonIndexed(GrPipelineBuilder*, 24356995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2449853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 24525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 246d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int vertexCount, 247d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 248ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 2494d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt // TODO devbounds should live on the batch 25044701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt void drawBatch(GrPipelineBuilder*, GrBatch*, const SkRect* devBounds = NULL); 2514d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt 25286afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com /** 25364aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * Draws path into the stencil buffer. The fill must be either even/odd or 25464aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * winding (not inverse or hairline). It will respect the HW antialias flag 2558dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * on the GrPipelineBuilder (if possible in the 3D API). Note, we will never have an inverse 2568dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * fill with stencil path 25764aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com */ 2588dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 2598dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPathRendering::FillType); 26064aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 26164aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com /** 26232184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org * Draws a path. Fill must not be a hairline. It will respect the HW 2638dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * antialias flag on the GrPipelineBuilder (if possible in the 3D API). 264c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org */ 2658dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 2668dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPathRendering::FillType); 267c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org 268c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org /** 26955b24afc178e641e17a5664beba7ab2b4982c91acdalton * Draws the aggregate path from combining multiple. Note that this will not 27055b24afc178e641e17a5664beba7ab2b4982c91acdalton * always be equivalent to back-to-back calls to drawPath(). It will respect 2718dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API). 2729b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org * 27355b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param pathRange Source paths to draw from 27455b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indices Array of path indices to draw 27555b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indexType Data type of the array elements in indexBuffer 27655b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformValues Array of transforms for the individual paths 27755b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformType Type of transforms in transformBuffer 27855b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param count Number of paths to draw 279b85a0aab6905af8b329539b7573a7555b727d5e5cdalton * @param fill Fill type for drawing all the paths 280b85a0aab6905af8b329539b7573a7555b727d5e5cdalton */ 2818dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawPaths(GrPipelineBuilder*, 28256995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 2832e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt const GrPathRange* pathRange, 28455b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 28555b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType indexType, 28655b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 28755b24afc178e641e17a5664beba7ab2b4982c91acdalton PathTransformType transformType, 2889853ccef19c200be93a6211f32589fa82a53067cjoshualitt int count, 28992e496f96abbd664888f0c8a7d546ab02e703bf7joshualitt GrPathRendering::FillType fill); 290b85a0aab6905af8b329539b7573a7555b727d5e5cdalton 2919b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org /** 2920406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * Helper function for drawing rects. It performs a geometry src push and pop 2930406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * and thus will finalize any reserved geometry. 294044679ef8c08e1f01afadf5bc08251fe8597df81skia.committer@gmail.com * 295c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param rect the rect to draw 296c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param localRect optional rect that specifies local coords to map onto 297c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * rect. If NULL then rect serves as the local coords. 2988fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * @param localMatrix Optional local matrix. The local coordinates are specified by localRect, 2998fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * or if it is NULL by rect. This matrix applies to the coordinate implied by 3008fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * that rectangle before it is input to GrCoordTransforms that read local 3018fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * coordinates 30286afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com */ 3034d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void drawRect(GrPipelineBuilder* pipelineBuilder, 3042e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 3058059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkMatrix& viewMatrix, 3069853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 307fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 3080406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com const SkMatrix* localMatrix) { 3090406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com AutoGeometryPush agp(this); 3104d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt this->onDrawRect(pipelineBuilder, color, viewMatrix, rect, localRect, localMatrix); 3110406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com } 3123976825a21532e254311b90b4a9046e25717e335jvanverth@google.com 313cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com /** 314c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * Helper for drawRect when the caller doesn't need separate local rects or matrices. 315cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com */ 3168dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM, 3178dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel const SkRect& rect) { 3188059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt this->drawRect(ds, color, viewM, rect, NULL, NULL); 319cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com } 3208dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM, 3218059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkIRect& irect) { 3224469938e92d779dff05e745559e67907bbf21e78reed@google.com SkRect rect = SkRect::Make(irect); 3238059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt this->drawRect(ds, color, viewM, rect, NULL, NULL); 324cf939ae54842fc7408ee68a41427086962b4c3dcbsalomon@google.com } 32586afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com 32686afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com /** 327934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * This call is used to draw multiple instances of some geometry with a 328934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * given number of vertices (V) and indices (I) per-instance. The indices in 329934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * the index source must have the form i[k+I] == i[k] + V. Also, all indices 330934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a 331934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * concrete example, the following index buffer for drawing a series of 332934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * quads each as two triangles each satisfies these conditions with V=4 and 333934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * I=6: 334934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * (0,1,2,0,2,3, 4,5,6,4,6,7, 8,9,10,8,10,11, ...) 335934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * 336934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * The call assumes that the pattern of indices fills the entire index 337934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * source. The size of the index buffer limits the number of instances that 338934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * can be drawn by the GPU in a single draw. However, the caller may specify 339934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * any (positive) number for instanceCount and if necessary multiple GPU 340d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * draws will be issued. Moreover, when drawIndexedInstances is called 341934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * multiple times it may be possible for GrDrawTarget to group them into a 342934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * single GPU draw. 343934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * 344934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param type the type of primitives to draw 345934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param instanceCount the number of instances to draw. Each instance 346934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * consists of verticesPerInstance vertices indexed by 347934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * indicesPerInstance indices drawn as the primitive 348934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * type specified by type. 349934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param verticesPerInstance The number of vertices in each instance (V 350934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the above description). 351934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * @param indicesPerInstance The number of indices in each instance (I 352934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the above description). 353d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 354d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 355934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com */ 3568dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawIndexedInstances(GrPipelineBuilder*, 35756995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 3589853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 359d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int instanceCount, 360d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int verticesPerInstance, 361d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int indicesPerInstance, 362d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 363934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com 364934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com /** 3658dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * Clear the passed in render target. Ignores the GrPipelineBuilder and clip. Clears the whole 3668dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * thing if rect is NULL, otherwise just the rect. If canIgnoreRect is set then the entire 3678dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * render target can be optionally cleared. 3680b335c1ac100aeacf79a4c98a052286fd46661e7bsalomon@google.com */ 3699853ccef19c200be93a6211f32589fa82a53067cjoshualitt void clear(const SkIRect* rect, 3709853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrColor color, 3719853ccef19c200be93a6211f32589fa82a53067cjoshualitt bool canIgnoreRect, 37263b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon GrRenderTarget* renderTarget); 373a9493a3c78f6eb82635ece960b4f16918b885428skia.committer@gmail.com 374e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com /** 37589c62980c1eb50b2090f33312086c7e8c66739b4bsalomon * Discards the contents render target. 37628361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org **/ 37789c62980c1eb50b2090f33312086c7e8c66739b4bsalomon virtual void discard(GrRenderTarget*) = 0; 37828361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org 37928361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org /** 3802a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * Called at start and end of gpu trace marking 3812a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start 3822a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org * and end of a code block respectively 383a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org */ 3843eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void addGpuTraceMarker(const GrGpuTraceMarker* marker); 3853eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void removeGpuTraceMarker(const GrGpuTraceMarker* marker); 3863eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel 3873eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel /** 3883eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * Takes the current active set of markers and stores them for later use. Any current marker 3893eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * in the active set is removed from the active set and the targets remove function is called. 3903eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * These functions do not work as a stack so you cannot call save a second time before calling 3913eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * restore. Also, it is assumed that when restore is called the current active set of markers 3923eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * is empty. When the stored markers are added back into the active set, the targets add marker 3933eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel * is called. 3943eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel */ 3953eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void saveActiveTraceMarkers(); 3963eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel void restoreActiveTraceMarkers(); 397a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org 398a3baf3be0e2a3128fb73bd41d40d130f75a4dc86commit-bot@chromium.org /** 399e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * Copies a pixel rectangle from one surface to another. This call may finalize 400e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * reserved vertex/index data (as though a draw call was made). The src pixels 401e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * copied are specified by srcRect. They are copied to a rect of the same 402e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * size in dst with top left at dstPoint. If the src rect is clipped by the 403e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * src bounds then pixel values in the dst rect corresponding to area clipped 404e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * by the src rect are not overwritten. This method can fail and return false 405e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * depending on the type of surface, configs, etc, and the backend-specific 406e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * limitations. If rect is clipped out entirely by the src or dst bounds then 407e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * true is returned since there is no actual copy necessary to succeed. 408e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com */ 409f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool copySurface(GrSurface* dst, 410f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon GrSurface* src, 411f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 412f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint); 413116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com /** 414f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * Function that determines whether a copySurface call would succeed without actually 415116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com * performing the copy. 416116ad84d3126b0db22b2312ca59ed70e5c56f6fcbsalomon@google.com */ 417f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool canCopySurface(const GrSurface* dst, 418f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 419f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 420f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint); 421eb85117c05471e1a55ce387cbc38279f857a4584bsalomon@google.com 422eb85117c05471e1a55ce387cbc38279f857a4584bsalomon@google.com /** 423ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com * Release any resources that are cached but not currently in use. This 424ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com * is intended to give an application some recourse when resources are low. 425ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com */ 426ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com virtual void purgeResources() {}; 427ff17584e1c15f68ccc296be517e8a6776a9ddabdrobertphillips@google.com 42825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com //////////////////////////////////////////////////////////////////////////// 4291c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com 430a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org class AutoReleaseGeometry : public ::SkNoncopyable { 431ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com public: 432ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com AutoReleaseGeometry(GrDrawTarget* target, 43325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 4349853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 43525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int indexCount); 43625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com AutoReleaseGeometry(); 43725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com ~AutoReleaseGeometry(); 4385782d712ffc31557d0cb12d5a220cebb783f6895bsalomon@google.com bool set(GrDrawTarget* target, 43925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 4409853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 44125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int indexCount); 44249f085dddff10473b6ebf832a974288300224e60bsalomon bool succeeded() const { return SkToBool(fTarget); } 443f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org void* vertices() const { SkASSERT(this->succeeded()); return fVertices; } 444f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org void* indices() const { SkASSERT(this->succeeded()); return fIndices; } 445972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org SkPoint* positions() const { 446972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org return static_cast<SkPoint*>(this->vertices()); 447ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com } 448ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 449ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com private: 45025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void reset(); 451d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 452ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com GrDrawTarget* fTarget; 453ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void* fVertices; 454ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void* fIndices; 455ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 456ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 45725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com //////////////////////////////////////////////////////////////////////////// 458ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 4590406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com /** 4600406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * Saves the geometry src state at construction and restores in the destructor. It also saves 4610406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * and then restores the vertex attrib state. 4620406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com */ 463a0b40280a49a8a43af7929ead3b3489951c58501commit-bot@chromium.org class AutoGeometryPush : public ::SkNoncopyable { 4640406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com public: 4659853ccef19c200be93a6211f32589fa82a53067cjoshualitt AutoGeometryPush(GrDrawTarget* target) { 46649f085dddff10473b6ebf832a974288300224e60bsalomon SkASSERT(target); 4670406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com fTarget = target; 4680406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com target->pushGeometrySource(); 4690406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com } 4700406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com 4710406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com ~AutoGeometryPush() { fTarget->popGeometrySource(); } 4720406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com 4730406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com private: 4740406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com GrDrawTarget* fTarget; 47525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 476ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 477a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org /////////////////////////////////////////////////////////////////////////// 478a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // Draw execution tracking (for font atlases and other resources) 479a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org class DrawToken { 480a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org public: 481a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org DrawToken(GrDrawTarget* drawTarget, uint32_t drawID) : 482a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org fDrawTarget(drawTarget), fDrawID(drawID) {} 4837475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 48449f085dddff10473b6ebf832a974288300224e60bsalomon bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID); } 4857475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 486a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org private: 487a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org GrDrawTarget* fDrawTarget; 488a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org uint32_t fDrawID; // this may wrap, but we're doing direct comparison 489a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // so that should be okay 490a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org }; 4917475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 492a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } 4937475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 4943322fa432a96fdc94d54f2475faf918dfa05b919joshualitt /** 4953322fa432a96fdc94d54f2475faf918dfa05b919joshualitt * Used to communicate draws to GPUs / subclasses 4963322fa432a96fdc94d54f2475faf918dfa05b919joshualitt */ 4973322fa432a96fdc94d54f2475faf918dfa05b919joshualitt class DrawInfo { 4983322fa432a96fdc94d54f2475faf918dfa05b919joshualitt public: 4994d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt DrawInfo() { fDevBounds = NULL; } 5003322fa432a96fdc94d54f2475faf918dfa05b919joshualitt DrawInfo(const DrawInfo& di) { (*this) = di; } 5013322fa432a96fdc94d54f2475faf918dfa05b919joshualitt DrawInfo& operator =(const DrawInfo& di); 5023322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5033322fa432a96fdc94d54f2475faf918dfa05b919joshualitt GrPrimitiveType primitiveType() const { return fPrimitiveType; } 5043322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int startVertex() const { return fStartVertex; } 5053322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int startIndex() const { return fStartIndex; } 5063322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int vertexCount() const { return fVertexCount; } 5073322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int indexCount() const { return fIndexCount; } 5083322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int verticesPerInstance() const { return fVerticesPerInstance; } 5093322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int indicesPerInstance() const { return fIndicesPerInstance; } 5103322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int instanceCount() const { return fInstanceCount; } 5113322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5124d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; } 5134d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setStartVertex(int startVertex) { fStartVertex = startVertex; } 5144d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setStartIndex(int startIndex) { fStartIndex = startIndex; } 5154d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setVertexCount(int vertexCount) { fVertexCount = vertexCount; } 5164d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setIndexCount(int indexCount) { fIndexCount = indexCount; } 5174d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setVerticesPerInstance(int verticesPerI) { fVerticesPerInstance = verticesPerI; } 5184d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setIndicesPerInstance(int indicesPerI) { fIndicesPerInstance = indicesPerI; } 5194d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void setInstanceCount(int instanceCount) { fInstanceCount = instanceCount; } 5204d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt 5213322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isIndexed() const { return fIndexCount > 0; } 5223322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#ifdef SK_DEBUG 5233322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isInstanced() const; // this version is longer because of asserts 5243322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#else 5253322fa432a96fdc94d54f2475faf918dfa05b919joshualitt bool isInstanced() const { return fInstanceCount > 0; } 5263322fa432a96fdc94d54f2475faf918dfa05b919joshualitt#endif 5273322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5283322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // adds or remove instances 5293322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustInstanceCount(int instanceOffset); 5303322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // shifts the start vertex 5313322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustStartVertex(int vertexOffset); 5323322fa432a96fdc94d54f2475faf918dfa05b919joshualitt // shifts the start index 5333322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void adjustStartIndex(int indexOffset); 5343322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5353322fa432a96fdc94d54f2475faf918dfa05b919joshualitt void setDevBounds(const SkRect& bounds) { 5363322fa432a96fdc94d54f2475faf918dfa05b919joshualitt fDevBoundsStorage = bounds; 5373322fa432a96fdc94d54f2475faf918dfa05b919joshualitt fDevBounds = &fDevBoundsStorage; 5383322fa432a96fdc94d54f2475faf918dfa05b919joshualitt } 5397eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } 5407eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } 5417eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt void setVertexBuffer(const GrVertexBuffer* vb) { 5427eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt fVertexBuffer.reset(vb); 5437eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt } 5447eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt void setIndexBuffer(const GrIndexBuffer* ib) { 5457eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt fIndexBuffer.reset(ib); 5467eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt } 5473322fa432a96fdc94d54f2475faf918dfa05b919joshualitt const SkRect* getDevBounds() const { return fDevBounds; } 5483322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5493322fa432a96fdc94d54f2475faf918dfa05b919joshualitt private: 5503322fa432a96fdc94d54f2475faf918dfa05b919joshualitt friend class GrDrawTarget; 5513322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5523322fa432a96fdc94d54f2475faf918dfa05b919joshualitt GrPrimitiveType fPrimitiveType; 5533322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5543322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fStartVertex; 5553322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fStartIndex; 5563322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fVertexCount; 5573322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fIndexCount; 5583322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5593322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fInstanceCount; 5603322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fVerticesPerInstance; 5613322fa432a96fdc94d54f2475faf918dfa05b919joshualitt int fIndicesPerInstance; 5623322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5633322fa432a96fdc94d54f2475faf918dfa05b919joshualitt SkRect fDevBoundsStorage; 5643322fa432a96fdc94d54f2475faf918dfa05b919joshualitt SkRect* fDevBounds; 5653322fa432a96fdc94d54f2475faf918dfa05b919joshualitt 5667eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer; 5677eb8c7b00a5d776bebaf33a8687357df95c1aa43joshualitt GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer; 5683322fa432a96fdc94d54f2475faf918dfa05b919joshualitt }; 5692c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 570371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon /** 571371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon * Used to populate the vertex and index buffer on the draw info before onDraw is called. 572371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon */ 573371bcbcb9fa7f9acba265de9de5dd23f62a64a86bsalomon virtual void setDrawBuffers(DrawInfo*, size_t vertexStride) = 0;; 5742c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt bool programUnitTest(int maxStages); 5752c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 576ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comprotected: 57725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum GeometrySrcType { 57825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kNone_GeometrySrcType, //<! src has not been specified 57925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kReserved_GeometrySrcType, //<! src was set using reserve*Space 58025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer 58125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 582d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 58325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com struct GeometrySrcState { 58425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fVertexSrc; 58525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 58625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 58725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrVertexBuffer* fVertexBuffer; 58825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 58925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fVertexCount; 59025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 591d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 59225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fIndexSrc; 59325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 59425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 59525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrIndexBuffer* fIndexBuffer; 59625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 59725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fIndexCount; 59825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 599d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 600b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t fVertexSize; 60125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 602934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com 603934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com int indexCountInCurrentSource() const { 604934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com const GeometrySrcState& src = this->getGeomSrc(); 605934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com switch (src.fIndexSrc) { 606934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kNone_GeometrySrcType: 607934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 608934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kReserved_GeometrySrcType: 609934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return src.fIndexCount; 610934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kBuffer_GeometrySrcType: 611089a780c3355129eefc942246534bc1f126b8ccbcommit-bot@chromium.org return static_cast<int>(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); 612934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com default: 61388cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org SkFAIL("Unexpected Index Source."); 614934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 615934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 616934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 617a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com 6186e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* getContext() { return fContext; } 6196e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com const GrContext* getContext() const { return fContext; } 6206e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com 62102ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclasses must call this in their destructors to ensure all vertex 62202ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // and index sources have been released (including those held by 62302ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // pushGeometrySource()) 62402ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com void releaseGeometry(); 62502ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 62602ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // accessors for derived classes 62702ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com const GeometrySrcState& getGeomSrc() const { return fGeoSrcStateStack.back(); } 628b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com // it is preferable to call this rather than getGeomSrc()->fVertexSize because of the assert. 629b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t getVertexSize() const { 63002ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // the vertex layout is only valid if a vertex source has been specified. 631f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); 632b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com return this->getGeomSrc().fVertexSize; 633a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com } 6345782d712ffc31557d0cb12d5a220cebb783f6895bsalomon@google.com 635bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com // Subclass must initialize this in its constructor. 636c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com SkAutoTUnref<const GrDrawTargetCaps> fCaps; 63702ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 6382a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; } 6392a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org 640651713408c5a5d9565665967ad09981250c7a8c9joshualitt // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required 641651713408c5a5d9565665967ad09981250c7a8c9joshualitt // but couldn't be made. Otherwise, returns true. This method needs to be protected because it 642651713408c5a5d9565665967ad09981250c7a8c9joshualitt // needs to be accessed by GLPrograms to setup a correct drawstate 64350785a3d10b53bea5beb6e18431a2449860be237bsalomon bool setupDstReadIfNecessary(const GrPipelineBuilder&, 644e36914cb205699526988127a827d1a76c9a98d39egdaniel const GrProcOptInfo& colorPOI, 645e36914cb205699526988127a827d1a76c9a98d39egdaniel const GrProcOptInfo& coveragePOI, 6469853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrDeviceCoordTexture* dstCopy, 6479853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect* drawBounds); 648651713408c5a5d9565665967ad09981250c7a8c9joshualitt 649e36914cb205699526988127a827d1a76c9a98d39egdaniel struct PipelineInfo { 650e36914cb205699526988127a827d1a76c9a98d39egdaniel PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor, 65144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const GrPrimitiveProcessor* primProc, 65244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const SkRect* devBounds, GrDrawTarget* target); 653e36914cb205699526988127a827d1a76c9a98d39egdaniel 654e36914cb205699526988127a827d1a76c9a98d39egdaniel PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor, 65544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const GrBatch* batch, const SkRect* devBounds, 65644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt GrDrawTarget* target); 657e36914cb205699526988127a827d1a76c9a98d39egdaniel 658e36914cb205699526988127a827d1a76c9a98d39egdaniel bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const { 659e36914cb205699526988127a827d1a76c9a98d39egdaniel return fPipelineBuilder->willBlendWithDst(primProc); 660e36914cb205699526988127a827d1a76c9a98d39egdaniel } 661e36914cb205699526988127a827d1a76c9a98d39egdaniel private: 662e36914cb205699526988127a827d1a76c9a98d39egdaniel friend class GrDrawTarget; 663e36914cb205699526988127a827d1a76c9a98d39egdaniel 664e36914cb205699526988127a827d1a76c9a98d39egdaniel bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } 665e36914cb205699526988127a827d1a76c9a98d39egdaniel 666e36914cb205699526988127a827d1a76c9a98d39egdaniel GrPipelineBuilder* fPipelineBuilder; 667e36914cb205699526988127a827d1a76c9a98d39egdaniel GrScissorState* fScissor; 668e36914cb205699526988127a827d1a76c9a98d39egdaniel GrProcOptInfo fColorPOI; 669e36914cb205699526988127a827d1a76c9a98d39egdaniel GrProcOptInfo fCoveragePOI; 670e36914cb205699526988127a827d1a76c9a98d39egdaniel GrDeviceCoordTexture fDstCopy; 671e36914cb205699526988127a827d1a76c9a98d39egdaniel }; 672e36914cb205699526988127a827d1a76c9a98d39egdaniel 673e36914cb205699526988127a827d1a76c9a98d39egdaniel void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); 674e36914cb205699526988127a827d1a76c9a98d39egdaniel 67554fac8b04a2583590c55d7b1e9339288c7370b28robertphillips // A subclass can optionally overload this function to be notified before 67654fac8b04a2583590c55d7b1e9339288c7370b28robertphillips // vertex and index space is reserved. 67754fac8b04a2583590c55d7b1e9339288c7370b28robertphillips virtual void willReserveVertexAndIndexSpace(int vertexCount, 67854fac8b04a2583590c55d7b1e9339288c7370b28robertphillips size_t vertexStride, 67954fac8b04a2583590c55d7b1e9339288c7370b28robertphillips int indexCount) {} 68054fac8b04a2583590c55d7b1e9339288c7370b28robertphillips 68102ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.comprivate: 682f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 683f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture as a dst for copySurface. This function 684f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * populates the dstDesc's config, flags, and origin so as to maximize efficiency and guarantee 685f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * success of the copySurface call. 686f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 687f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { 688f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { 689f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fOrigin = kDefault_GrSurfaceOrigin; 6906bc1b5fab8554a9cb643277b4867965dd4535cd6bsalomon dstDesc->fFlags = kRenderTarget_GrSurfaceFlag; 691f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fConfig = src->config(); 692f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 693f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 694f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 695f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Internal implementation of canCopySurface. */ 696f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool internalCanCopySurface(const GrSurface* dst, 697f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 698f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& clippedSrcRect, 699f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& clippedDstRect); 700f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 70125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to allocate space for reserved geom 702a63389843dd18003382d61c2e4610af09ed07d38jvanverth@google.com virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; 70325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; 70425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to handle release of reserved geom space 70525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedVertexSpace() = 0; 70625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedIndexSpace() = 0; 70702ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclass overrides to be notified just before geo src state is pushed/popped. 70825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPush() = 0; 70925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 71025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // subclass called to perform drawing 711e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&) = 0; 712e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawBatch(GrBatch*, const PipelineInfo&) = 0; 7135478d427c6e67c986a3390162c8fec77c466058ajoshualitt // TODO copy in order drawbuffer onDrawRect to here 7148dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual void onDrawRect(GrPipelineBuilder*, 7152e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 7168059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkMatrix& viewMatrix, 7179853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 718fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 7195478d427c6e67c986a3390162c8fec77c466058ajoshualitt const SkMatrix* localMatrix) = 0; 72032184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org 7218dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual void onStencilPath(const GrPipelineBuilder&, 72256995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 7239853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7243e79124a69d4806f0a1a776090bff718e1b90970bsalomon const GrScissorState&, 7252c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&) = 0; 726e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawPath(const GrPathProcessor*, 7279853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7282c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 729e36914cb205699526988127a827d1a76c9a98d39egdaniel const PipelineInfo&) = 0; 730e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawPaths(const GrPathProcessor*, 7319853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPathRange*, 73255b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 73355b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType, 73455b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 7352c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt PathTransformType, 73655b24afc178e641e17a5664beba7ab2b4982c91acdalton int count, 7372c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 738e36914cb205699526988127a827d1a76c9a98d39egdaniel const PipelineInfo&) = 0; 73964aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 74063b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, 74163b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon GrRenderTarget* renderTarget) = 0; 74263b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 743f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** The subclass will get a chance to copy the surface for falling back to the default 744f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon implementation, which simply draws a rectangle (and fails if dst isn't a render target). It 745f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon should assume that any clipping has already been performed on the rect and point. It won't 746f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon be called if the copy can be skipped. */ 747f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCopySurface(GrSurface* dst, 748f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon GrSurface* src, 749f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 750f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 751f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 752f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Indicates whether onCopySurface would succeed. It should assume that any clipping has 753f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon already been performed on the rect and point. It won't be called if the copy can be 754f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon skipped. */ 755f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCanCopySurface(const GrSurface* dst, 756f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 757f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 758f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 759f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 760f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture to be a dst for onCopySurface. Only the 761f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * dstDesc's config, flags, and origin need be set by the function. If the subclass cannot 762f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * create a surface that would succeed its implementation of onCopySurface, it should return 763f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * false. The base class will fall back to creating a render target to draw into using the src. 764f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 765f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onInitCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) = 0; 76663b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 767e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com // helpers for reserving vertex and index space. 768b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexSpace(size_t vertexSize, 769e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com int vertexCount, 770e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com void** vertices); 771e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com bool reserveIndexSpace(int indexCount, void** indices); 772d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 773e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // called by drawIndexed and drawNonIndexed. Use a negative indexCount to 774e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // indicate non-indexed drawing. 7758dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel bool checkDraw(const GrPipelineBuilder&, 77656995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 7779853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 7789853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startVertex, 7799853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startIndex, 7809853ccef19c200be93a6211f32589fa82a53067cjoshualitt int vertexCount, 781e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com int indexCount) const; 78225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // called when setting a new vert/idx source to unref prev vb/ib 78325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousVertexSource(); 78425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousIndexSource(); 785d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 786a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // Check to see if this set of draw commands has been sent out 787a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org virtual bool isIssued(uint32_t drawID) { return true; } 7889853ccef19c200be93a6211f32589fa82a53067cjoshualitt void getPathStencilSettingsForFilltype(GrPathRendering::FillType, 7899853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrStencilBuffer*, 7909853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrStencilSettings*); 791a702415d9e80f5631181143c293498de924e8ae4joshualitt virtual GrClipMaskManager* clipMaskManager() = 0; 7928dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual bool setupClip(GrPipelineBuilder*, 7938dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPipelineBuilder::AutoRestoreEffects* are, 7948dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPipelineBuilder::AutoRestoreStencil* ars, 7958059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt GrScissorState* scissorState, 7968059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkRect* devBounds) = 0; 7977475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 79825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum { 79925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kPreallocGeoSrcStateStackCnt = 4, 800ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 80102ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcStateStack; 8026e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTarget. 8036e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* fContext; 8042a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org // To keep track that we always have at least as many debug marker adds as removes 8052a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org int fGpuTraceMarkerCount; 8062a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org GrTraceMarkerSet fActiveTraceMarkers; 8073eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel GrTraceMarkerSet fStoredTraceMarkers; 808fa35e3ddcc9d130ce87c927218bdf27879c38711reed@google.com 809a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org typedef SkRefCnt INHERITED; 810ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}; 811ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 812329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt/* 813329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * This class is JUST for clip mask manager. Everyone else should just use draw target above. 814329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 8156db519c42471aaaa8a8e1a3ece314014481ab832joshualittclass GrClipTarget : public GrDrawTarget { 8166db519c42471aaaa8a8e1a3ece314014481ab832joshualittpublic: 817329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipTarget(GrContext* context) : INHERITED(context) { 818329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt fClipMaskManager.setClipTarget(this); 819329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt } 820329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 821329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt /* Clip mask manager needs access to the context. 822329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * TODO we only need a very small subset of context in the CMM. 823329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 824329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrContext* getContext() { return INHERITED::getContext(); } 825329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt const GrContext* getContext() const { return INHERITED::getContext(); } 826329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8276db519c42471aaaa8a8e1a3ece314014481ab832joshualitt /** 8286db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * Clip Mask Manager(and no one else) needs to clear private stencil bits. 8296db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * ClipTarget subclass sets clip bit in the stencil buffer. The subclass 8306db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * is free to clear the remaining bits to zero if masked clears are more 8316db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * expensive than clearing all bits. 8326db519c42471aaaa8a8e1a3ece314014481ab832joshualitt */ 8336db519c42471aaaa8a8e1a3ece314014481ab832joshualitt virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* = NULL) = 0; 8346db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 8353bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt /** 8363bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * Release any resources that are cached but not currently in use. This 8373bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * is intended to give an application some recourse when resources are low. 8383bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt */ 83972c9faab45124e08c85f70ca38536914862d947cmtklein void purgeResources() SK_OVERRIDE { 8403bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // The clip mask manager can rebuild all its clip masks so just 8413bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // get rid of them all. 8423bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt fClipMaskManager.purgeResources(); 8433bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt }; 8443bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt 845329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualittprotected: 846329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipMaskManager fClipMaskManager; 847329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8486db519c42471aaaa8a8e1a3ece314014481ab832joshualittprivate: 849912ed6ebb8e2813e72ed7a3dec3b6710ba7e7405tfarina GrClipMaskManager* clipMaskManager() SK_OVERRIDE { return &fClipMaskManager; } 850329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8518dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual bool setupClip(GrPipelineBuilder*, 8528dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPipelineBuilder::AutoRestoreEffects* are, 8538dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPipelineBuilder::AutoRestoreStencil* ars, 8548059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt GrScissorState* scissorState, 8558059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkRect* devBounds) SK_OVERRIDE; 8562c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 8576db519c42471aaaa8a8e1a3ece314014481ab832joshualitt typedef GrDrawTarget INHERITED; 8586db519c42471aaaa8a8e1a3ece314014481ab832joshualitt}; 8596db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 860ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif 861