GrDrawTarget.h revision 8dc7c3a839b38b73af34cc2674a06f49eb1ce527
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; 345bf99f1ca8f30287803b594d06c60a7b6796ad45joshualittclass GrGeometryProcessor; 3564aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.comclass GrPath; 36b85a0aab6905af8b329539b7573a7555b727d5e5cdaltonclass GrPathRange; 37e36914cb205699526988127a827d1a76c9a98d39egdanielclass GrPipeline; 3812b4e27ae1a29460e91a59f38122483e1faec697sugoi@google.com 39a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.orgclass GrDrawTarget : public SkRefCnt { 40bcce8926524827775539874346dd424a9510dbc9bsalomon@google.compublic: 41bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com SK_DECLARE_INST_COUNT(GrDrawTarget) 42bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com 4355b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRange::PathIndexType PathIndexType; 4455b24afc178e641e17a5664beba7ab2b4982c91acdalton typedef GrPathRendering::PathTransformType PathTransformType; 45ccdaa0422501e5cbcba53d6bd19f2736f1beaef3kkinnunen 46ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /////////////////////////////////////////////////////////////////////////// 47ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 486e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context may not be fully constructed and should not be used during GrDrawTarget 496e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // construction. 506e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrDrawTarget(GrContext* context); 5125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual ~GrDrawTarget(); 52ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 53ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 5418c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com * Gets the capabilities of the draw target. 5518c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com */ 56c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com const GrDrawTargetCaps* caps() const { return fCaps.get(); } 5718c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com 5818c9c198f571997463d9a7134dbd88298e592ec2bsalomon@google.com /** 59f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * There are two types of "sources" of geometry (vertices and indices) for 60e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * draw calls made on the target. When performing an indexed draw, the 61e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indices and vertices can use different source types. Once a source is 62934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * specified it can be used for multiple draws. However, the time at which 63934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * the geometry data is no longer editable depends on the source type. 6425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 6525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Sometimes it is necessary to perform a draw while upstack code has 66e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * already specified geometry that it isn't finished with. So there are push 67e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and pop methods. This allows the client to push the sources, draw 68e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * something using alternate sources, and then pop to restore the original 69e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * sources. 70e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 71e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Aside from pushes and pops, a source remains valid until another source 72e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is set or resetVertexSource / resetIndexSource is called. Drawing from 73e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * a reset source is an error. 74e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 75f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * The two types of sources are: 761c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 77f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 1. Reserve. This is most useful when the caller has data it must 7825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * transform before drawing and is not long-lived. The caller requests 7925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * that the draw target make room for some amount of vertex and/or index 8025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data. The target provides ptrs to hold the vertex and/or index data. 8125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * 82d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * The data is writable up until the next drawIndexed, drawNonIndexed, 83e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * drawIndexedInstances, drawRect, copySurface, or pushGeometrySource. At 84e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * this point the data is frozen and the ptrs are no longer valid. 851c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 86e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Where the space is allocated and how it is uploaded to the GPU is 87e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * subclass-dependent. 88e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * 89f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * 2. Vertex and Index Buffers. This is most useful for geometry that will 90e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * is long-lived. When the data in the buffer is consumed depends on the 91d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * GrDrawTarget subclass. For deferred subclasses the caller has to 92e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * guarantee that the data is still available in the buffers at playback. 93e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * (TODO: Make this more automatic as we have done for read/write pixels) 941c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com */ 951c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com 961c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com /** 97e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * Reserves space for vertices and/or indices. Zero can be specifed as 98e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * either the vertex or index count if the caller desires to only reserve 99d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * space for only indices or only vertices. If zero is specifed for 100e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * vertexCount then the vertex source will be unmodified and likewise for 101e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * indexCount. 102ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 103e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the function returns true then the reserve suceeded and the vertices 104e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * and indices pointers will point to the space created. 105ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 106e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * If the target cannot make space for the request then this function will 107e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * return false. If vertexCount was non-zero then upon failure the vertex 108e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * source is reset and likewise for indexCount. 109ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 110e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * The pointers to the space allocated for vertices and indices remain valid 111e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * until a drawIndexed, drawNonIndexed, drawIndexedInstances, drawRect, 112e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * copySurface, or push/popGeomtrySource is called. At that point logically a 113e4617bf6d45cdde07f89e341ebf5c485916bf0b2bsalomon@google.com * snapshot of the data is made and the pointers are invalid. 1141c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com * 115e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertexCount the number of vertices to reserve space for. Can be 1168dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * 0. Vertex size is queried from the current GrPipelineBuilder. 11725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indexCount the number of indices to reserve space for. Can be 0. 118e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com * @param vertices will point to reserved vertex space if vertexCount is 119d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com * non-zero. Illegal to pass NULL if vertexCount > 0. 12025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * @param indices will point to reserved index space if indexCount is 12125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * non-zero. Illegal to pass NULL if indexCount > 0. 12225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 123b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexAndIndexSpace(int vertexCount, 1249853ccef19c200be93a6211f32589fa82a53067cjoshualitt size_t vertexStride, 12597805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com int indexCount, 12697805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** vertices, 12797805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void** indices); 12825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 129ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 130ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Provides hints to caller about the number of vertices and indices 131ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * that can be allocated cheaply. This can be useful if caller is reserving 132ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * space but doesn't know exactly how much geometry is needed. 133ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 134ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Also may hint whether the draw target should be flushed first. This is 135ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * useful for deferred targets. 136ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 137ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount in: hint about how many vertices the caller would 138b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com * like to allocate. Vertex size is queried from the 1398dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * current GrPipelineBuilder. 140ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of vertices that can be 141ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 142ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 143ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount in: hint about how many indices the caller would 144ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * like to allocate. 145ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * out: a hint about the number of indices that can be 146ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * allocated cheaply. Negative means no hint. 147ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Ignored if NULL. 148ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 149ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @return true if target should be flushed based on the input values. 150ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1519853ccef19c200be93a6211f32589fa82a53067cjoshualitt virtual bool geometryHints(size_t vertexStride, int* vertexCount, int* indexCount) const; 152ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 153ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 154ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of vertex data for the next draw. Data does not have to be 155934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * in the buffer until drawIndexed, drawNonIndexed, or drawIndexedInstances. 156ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 157ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer vertex buffer containing vertex data. Must be 158ae683921ffda9108147a29da7319c7eee4dc9245skia.committer@gmail.com * unlocked before draw call. Vertex size is queried 1598dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * from current GrPipelineBuilder. 160ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1619853ccef19c200be93a6211f32589fa82a53067cjoshualitt void setVertexSourceToBuffer(const GrVertexBuffer* buffer, size_t vertexStride); 162ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 163ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 164ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Sets source of index data for the next indexed draw. Data does not have 165934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com * to be in the buffer until drawIndexed. 166ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 167ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param buffer index buffer containing indices. Must be unlocked 168ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * before indexed draw call. 169ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 170ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com void setIndexSourceToBuffer(const GrIndexBuffer* buffer); 171d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 17225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 17325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets vertex source. Drawing from reset vertices is illegal. Set vertex 17425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * source to reserved, array, or buffer before next draw. May be able to free 17525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * up temporary storage allocated by setVertexSourceToArray or 17625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * reserveVertexSpace. 17725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 17825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void resetVertexSource(); 179d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 18025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 18125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Resets index source. Indexed Drawing from reset indices is illegal. Set 18225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * index source to reserved, array, or buffer before next indexed draw. May 18325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be able to free up temporary storage allocated by setIndexSourceToArray 18425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * or reserveIndexSpace. 18525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 18697805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com void resetIndexSource(); 187d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 18897805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com /** 18997805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com * Query to find out if the vertex or index source is reserved. 19097805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com */ 19197805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com bool hasReservedVerticesOrIndices() const { 19273d98aace4f74acc39d8de33484c8aec8e917739bsalomon@google.com return kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc || 19397805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc; 19497805382d89b717de3355312a79a957ea4a864c9bsalomon@google.com } 195ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 196ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 19725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pushes and resets the vertex/index sources. Any reserved vertex / index 19825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * data is finalized (i.e. cannot be updated after the matching pop but can 19925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * be drawn from). Must be balanced by a pop. 20025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 20125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void pushGeometrySource(); 20225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com 20325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 20425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com * Pops the vertex / index sources from the matching push. 20525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com */ 20625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void popGeometrySource(); 20764aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 20825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com /** 209ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws indexed geometry using the current state and current vertex / index 210ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 211ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 212ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 213ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 214ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 215ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startIndex first index to read from index src. 216ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 217ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param indexCount the number of index elements to read. The index count 218ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * is effectively trimmed to the last completely 219ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * specified primitive. 220d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 221d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 222ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2238dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawIndexed(GrPipelineBuilder*, 22456995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2259853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 22625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 22725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startIndex, 22825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int vertexCount, 229d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int indexCount, 230d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 231ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 232ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com /** 233ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Draws non-indexed geometry using the current state and current vertex 234ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * sources. 235ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 236ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param type The type of primitives to draw. 237ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param startVertex the vertex in the vertex array/buffer corresponding 238ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * to index 0 239ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * @param vertexCount one greater than the max index. 240d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * @param devBounds optional bounds hint. This is a promise from the caller, 241d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com * not a request for clipping. 242ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2438dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawNonIndexed(GrPipelineBuilder*, 24456995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 2459853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 24625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int startVertex, 247d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com int vertexCount, 248d62e88e5af39347a8fc2a5abdf5feb67d7ea256dbsalomon@google.com const SkRect* devBounds = NULL); 249ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 2504d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt // TODO devbounds should live on the batch 25144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt void drawBatch(GrPipelineBuilder*, GrBatch*, const SkRect* devBounds = NULL); 2524d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt 25386afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com /** 25464aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * Draws path into the stencil buffer. The fill must be either even/odd or 25564aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com * winding (not inverse or hairline). It will respect the HW antialias flag 2568dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * on the GrPipelineBuilder (if possible in the 3D API). Note, we will never have an inverse 2578dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * fill with stencil path 25864aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com */ 2598dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 2608dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPathRendering::FillType); 26164aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 26264aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com /** 26332184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org * Draws a path. Fill must not be a hairline. It will respect the HW 2648dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * antialias flag on the GrPipelineBuilder (if possible in the 3D API). 265c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org */ 2668dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, 2678dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel GrPathRendering::FillType); 268c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org 269c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org /** 27055b24afc178e641e17a5664beba7ab2b4982c91acdalton * Draws the aggregate path from combining multiple. Note that this will not 27155b24afc178e641e17a5664beba7ab2b4982c91acdalton * always be equivalent to back-to-back calls to drawPath(). It will respect 2728dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API). 2739b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org * 27455b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param pathRange Source paths to draw from 27555b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indices Array of path indices to draw 27655b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param indexType Data type of the array elements in indexBuffer 27755b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformValues Array of transforms for the individual paths 27855b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param transformType Type of transforms in transformBuffer 27955b24afc178e641e17a5664beba7ab2b4982c91acdalton * @param count Number of paths to draw 280b85a0aab6905af8b329539b7573a7555b727d5e5cdalton * @param fill Fill type for drawing all the paths 281b85a0aab6905af8b329539b7573a7555b727d5e5cdalton */ 2828dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel void drawPaths(GrPipelineBuilder*, 28356995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 2842e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt const GrPathRange* pathRange, 28555b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 28655b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType indexType, 28755b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 28855b24afc178e641e17a5664beba7ab2b4982c91acdalton PathTransformType transformType, 2899853ccef19c200be93a6211f32589fa82a53067cjoshualitt int count, 29092e496f96abbd664888f0c8a7d546ab02e703bf7joshualitt GrPathRendering::FillType fill); 291b85a0aab6905af8b329539b7573a7555b727d5e5cdalton 2929b62aa156bcf1db6f11af9302bf8bb8ef2567142commit-bot@chromium.org /** 2930406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * Helper function for drawing rects. It performs a geometry src push and pop 2940406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com * and thus will finalize any reserved geometry. 295044679ef8c08e1f01afadf5bc08251fe8597df81skia.committer@gmail.com * 296c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param rect the rect to draw 297c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * @param localRect optional rect that specifies local coords to map onto 298c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * rect. If NULL then rect serves as the local coords. 2998fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * @param localMatrix Optional local matrix. The local coordinates are specified by localRect, 3008fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * or if it is NULL by rect. This matrix applies to the coordinate implied by 3018fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * that rectangle before it is input to GrCoordTransforms that read local 3028fc6c2d82c1f30ff82274334c01f0799def6a609joshualitt * coordinates 30386afc2ae27fec84c01eb0e81a32766bdaf67dca8bsalomon@google.com */ 3044d8da81562852e0ff7e18b66ee1cebd50ad81ee8joshualitt void drawRect(GrPipelineBuilder* pipelineBuilder, 3052e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 3068059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkMatrix& viewMatrix, 3079853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 308fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 3090406b9e1faee06c6ecb2732a1bcf3b0e53104e07bsalomon@google.com const SkMatrix* localMatrix) { 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: 577dad7794dcbf205a6d0f3c5c44e251897f5256f09robertphillips friend class GrTargetCommands; // for PipelineInfo 578dad7794dcbf205a6d0f3c5c44e251897f5256f09robertphillips 57925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum GeometrySrcType { 58025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kNone_GeometrySrcType, //<! src has not been specified 58125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kReserved_GeometrySrcType, //<! src was set using reserve*Space 58225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer 58325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 584d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 58525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com struct GeometrySrcState { 58625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fVertexSrc; 58725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 58825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 58925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrVertexBuffer* fVertexBuffer; 59025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 59125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fVertexCount; 59225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 593d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 59425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com GeometrySrcType fIndexSrc; 59525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com union { 59625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is buffer 59725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com const GrIndexBuffer* fIndexBuffer; 59825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // valid if src type is reserved or array 59925fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com int fIndexCount; 60025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 601d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 602b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t fVertexSize; 60325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com }; 604934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com 605934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com int indexCountInCurrentSource() const { 606934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com const GeometrySrcState& src = this->getGeomSrc(); 607934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com switch (src.fIndexSrc) { 608934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kNone_GeometrySrcType: 609934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 610934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kReserved_GeometrySrcType: 611934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return src.fIndexCount; 612934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com case kBuffer_GeometrySrcType: 613089a780c3355129eefc942246534bc1f126b8ccbcommit-bot@chromium.org return static_cast<int>(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); 614934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com default: 61588cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org SkFAIL("Unexpected Index Source."); 616934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com return 0; 617934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 618934c570297c1b1f99cb4ca8d012d468a7eddf73fbsalomon@google.com } 619a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com 6206e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* getContext() { return fContext; } 6216e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com const GrContext* getContext() const { return fContext; } 6226e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com 62302ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclasses must call this in their destructors to ensure all vertex 62402ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // and index sources have been released (including those held by 62502ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // pushGeometrySource()) 62602ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com void releaseGeometry(); 62702ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 62802ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // accessors for derived classes 62902ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com const GeometrySrcState& getGeomSrc() const { return fGeoSrcStateStack.back(); } 630b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com // it is preferable to call this rather than getGeomSrc()->fVertexSize because of the assert. 631b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com size_t getVertexSize() const { 63202ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // the vertex layout is only valid if a vertex source has been specified. 633f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); 634b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com return this->getGeomSrc().fVertexSize; 635a47a48dca5045d71cbc5de343404045209a13e15bsalomon@google.com } 6365782d712ffc31557d0cb12d5a220cebb783f6895bsalomon@google.com 637bcce8926524827775539874346dd424a9510dbc9bsalomon@google.com // Subclass must initialize this in its constructor. 638c26d94fd7dc0b00cd6d0e42d28285f4a38aff021bsalomon@google.com SkAutoTUnref<const GrDrawTargetCaps> fCaps; 63902ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com 6402a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; } 6412a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org 642651713408c5a5d9565665967ad09981250c7a8c9joshualitt // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required 643651713408c5a5d9565665967ad09981250c7a8c9joshualitt // but couldn't be made. Otherwise, returns true. This method needs to be protected because it 644651713408c5a5d9565665967ad09981250c7a8c9joshualitt // needs to be accessed by GLPrograms to setup a correct drawstate 64550785a3d10b53bea5beb6e18431a2449860be237bsalomon bool setupDstReadIfNecessary(const GrPipelineBuilder&, 646e36914cb205699526988127a827d1a76c9a98d39egdaniel const GrProcOptInfo& colorPOI, 647e36914cb205699526988127a827d1a76c9a98d39egdaniel const GrProcOptInfo& coveragePOI, 6489853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrDeviceCoordTexture* dstCopy, 6499853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect* drawBounds); 650651713408c5a5d9565665967ad09981250c7a8c9joshualitt 651e36914cb205699526988127a827d1a76c9a98d39egdaniel struct PipelineInfo { 652e36914cb205699526988127a827d1a76c9a98d39egdaniel PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor, 65344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const GrPrimitiveProcessor* primProc, 65444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const SkRect* devBounds, GrDrawTarget* target); 655e36914cb205699526988127a827d1a76c9a98d39egdaniel 656e36914cb205699526988127a827d1a76c9a98d39egdaniel PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor, 65744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt const GrBatch* batch, const SkRect* devBounds, 65844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt GrDrawTarget* target); 659e36914cb205699526988127a827d1a76c9a98d39egdaniel 660e36914cb205699526988127a827d1a76c9a98d39egdaniel bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const { 661e36914cb205699526988127a827d1a76c9a98d39egdaniel return fPipelineBuilder->willBlendWithDst(primProc); 662e36914cb205699526988127a827d1a76c9a98d39egdaniel } 663e36914cb205699526988127a827d1a76c9a98d39egdaniel private: 664e36914cb205699526988127a827d1a76c9a98d39egdaniel friend class GrDrawTarget; 665e36914cb205699526988127a827d1a76c9a98d39egdaniel 666e36914cb205699526988127a827d1a76c9a98d39egdaniel bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } 667e36914cb205699526988127a827d1a76c9a98d39egdaniel 668e36914cb205699526988127a827d1a76c9a98d39egdaniel GrPipelineBuilder* fPipelineBuilder; 669e36914cb205699526988127a827d1a76c9a98d39egdaniel GrScissorState* fScissor; 670e36914cb205699526988127a827d1a76c9a98d39egdaniel GrProcOptInfo fColorPOI; 671e36914cb205699526988127a827d1a76c9a98d39egdaniel GrProcOptInfo fCoveragePOI; 672e36914cb205699526988127a827d1a76c9a98d39egdaniel GrDeviceCoordTexture fDstCopy; 673e36914cb205699526988127a827d1a76c9a98d39egdaniel }; 674e36914cb205699526988127a827d1a76c9a98d39egdaniel 675e36914cb205699526988127a827d1a76c9a98d39egdaniel void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); 676e36914cb205699526988127a827d1a76c9a98d39egdaniel 67754fac8b04a2583590c55d7b1e9339288c7370b28robertphillips // A subclass can optionally overload this function to be notified before 67854fac8b04a2583590c55d7b1e9339288c7370b28robertphillips // vertex and index space is reserved. 67954fac8b04a2583590c55d7b1e9339288c7370b28robertphillips virtual void willReserveVertexAndIndexSpace(int vertexCount, 68054fac8b04a2583590c55d7b1e9339288c7370b28robertphillips size_t vertexStride, 68154fac8b04a2583590c55d7b1e9339288c7370b28robertphillips int indexCount) {} 68254fac8b04a2583590c55d7b1e9339288c7370b28robertphillips 68302ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.comprivate: 684f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 685f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture as a dst for copySurface. This function 686f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * populates the dstDesc's config, flags, and origin so as to maximize efficiency and guarantee 687f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * success of the copySurface call. 688f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 689f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { 690f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { 691f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fOrigin = kDefault_GrSurfaceOrigin; 6926bc1b5fab8554a9cb643277b4867965dd4535cd6bsalomon dstDesc->fFlags = kRenderTarget_GrSurfaceFlag; 693f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon dstDesc->fConfig = src->config(); 694f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 695f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon } 696f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 697f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Internal implementation of canCopySurface. */ 698f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon bool internalCanCopySurface(const GrSurface* dst, 699f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 700f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& clippedSrcRect, 701f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& clippedDstRect); 702f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 70325fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to allocate space for reserved geom 704a63389843dd18003382d61c2e4610af09ed07d38jvanverth@google.com virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; 70525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; 70625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // implemented by subclass to handle release of reserved geom space 70725fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedVertexSpace() = 0; 70825fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void releaseReservedIndexSpace() = 0; 70902ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com // subclass overrides to be notified just before geo src state is pushed/popped. 71025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPush() = 0; 71125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; 71225fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // subclass called to perform drawing 713e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&) = 0; 714e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawBatch(GrBatch*, const PipelineInfo&) = 0; 7155478d427c6e67c986a3390162c8fec77c466058ajoshualitt // TODO copy in order drawbuffer onDrawRect to here 7168dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual void onDrawRect(GrPipelineBuilder*, 7172e3b3e369d79e78f7635d4c20e83a47ab571bdf2joshualitt GrColor color, 7188059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkMatrix& viewMatrix, 7199853ccef19c200be93a6211f32589fa82a53067cjoshualitt const SkRect& rect, 720fd03d4a829efe2d77a712fd991927c55f59a2ffecommit-bot@chromium.org const SkRect* localRect, 7215478d427c6e67c986a3390162c8fec77c466058ajoshualitt const SkMatrix* localMatrix) = 0; 72232184d81629e39809bb9e915286d8fe971a8ed68commit-bot@chromium.org 7238dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual void onStencilPath(const GrPipelineBuilder&, 72456995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrPathProcessor*, 7259853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7263e79124a69d4806f0a1a776090bff718e1b90970bsalomon const GrScissorState&, 7272c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&) = 0; 728e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawPath(const GrPathProcessor*, 7299853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPath*, 7302c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 731e36914cb205699526988127a827d1a76c9a98d39egdaniel const PipelineInfo&) = 0; 732e36914cb205699526988127a827d1a76c9a98d39egdaniel virtual void onDrawPaths(const GrPathProcessor*, 7339853ccef19c200be93a6211f32589fa82a53067cjoshualitt const GrPathRange*, 73455b24afc178e641e17a5664beba7ab2b4982c91acdalton const void* indices, 73555b24afc178e641e17a5664beba7ab2b4982c91acdalton PathIndexType, 73655b24afc178e641e17a5664beba7ab2b4982c91acdalton const float transformValues[], 7372c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt PathTransformType, 73855b24afc178e641e17a5664beba7ab2b4982c91acdalton int count, 7392c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt const GrStencilSettings&, 740e36914cb205699526988127a827d1a76c9a98d39egdaniel const PipelineInfo&) = 0; 74164aef2bacd1f5c25ffd9347aabd6265c9b60c0f4bsalomon@google.com 74263b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, 74363b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon GrRenderTarget* renderTarget) = 0; 74463b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 745f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** The subclass will get a chance to copy the surface for falling back to the default 746f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon implementation, which simply draws a rectangle (and fails if dst isn't a render target). It 747f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon should assume that any clipping has already been performed on the rect and point. It won't 748f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon be called if the copy can be skipped. */ 749f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCopySurface(GrSurface* dst, 750f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon GrSurface* src, 751f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 752f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 753f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon 754f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** Indicates whether onCopySurface would succeed. It should assume that any clipping has 755f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon already been performed on the rect and point. It won't be called if the copy can be 756f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon skipped. */ 757f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onCanCopySurface(const GrSurface* dst, 758f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const GrSurface* src, 759f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIRect& srcRect, 760f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon const SkIPoint& dstPoint) = 0; 761f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon /** 762f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * This will be called before allocating a texture to be a dst for onCopySurface. Only the 763f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * dstDesc's config, flags, and origin need be set by the function. If the subclass cannot 764f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * create a surface that would succeed its implementation of onCopySurface, it should return 765f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon * false. The base class will fall back to creating a render target to draw into using the src. 766f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon */ 767f90a02b42ac7a1ed59460760c6ce03f6f975f22bbsalomon virtual bool onInitCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) = 0; 76863b21962867af0f98e12a3ccbe5eef76b7ecc3aabsalomon 769e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com // helpers for reserving vertex and index space. 770b75b0a0b8492e14c7728e0a0881f87dc64ce60f9jvanverth@google.com bool reserveVertexSpace(size_t vertexSize, 771e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com int vertexCount, 772e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com void** vertices); 773e3d7095c2374a423815e662020459832f389a40fbsalomon@google.com bool reserveIndexSpace(int indexCount, void** indices); 774d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 775e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // called by drawIndexed and drawNonIndexed. Use a negative indexCount to 776e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com // indicate non-indexed drawing. 7778dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel bool checkDraw(const GrPipelineBuilder&, 77856995b5cc00c9c83bd5fcf86bca9a67e939a96cbjoshualitt const GrGeometryProcessor*, 7799853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrPrimitiveType type, 7809853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startVertex, 7819853ccef19c200be93a6211f32589fa82a53067cjoshualitt int startIndex, 7829853ccef19c200be93a6211f32589fa82a53067cjoshualitt int vertexCount, 783e826262939dac3e67cb5ce66d4b9faeb8e2538e6bsalomon@google.com int indexCount) const; 78425fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com // called when setting a new vert/idx source to unref prev vb/ib 78525fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousVertexSource(); 78625fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com void releasePreviousIndexSource(); 787d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 788a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org // Check to see if this set of draw commands has been sent out 789a8916ffd90c04dc6cc1fb9ba94af2ff950284fadcommit-bot@chromium.org virtual bool isIssued(uint32_t drawID) { return true; } 7909853ccef19c200be93a6211f32589fa82a53067cjoshualitt void getPathStencilSettingsForFilltype(GrPathRendering::FillType, 7918dc7c3a839b38b73af34cc2674a06f49eb1ce527egdaniel const GrStencilAttachment*, 7929853ccef19c200be93a6211f32589fa82a53067cjoshualitt GrStencilSettings*); 793a702415d9e80f5631181143c293498de924e8ae4joshualitt virtual GrClipMaskManager* clipMaskManager() = 0; 7948dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual bool setupClip(GrPipelineBuilder*, 7956be6f7cb66b277e7b1ce13d09b635fb8e09a2f68bsalomon GrPipelineBuilder::AutoRestoreFragmentProcessors*, 7966be6f7cb66b277e7b1ce13d09b635fb8e09a2f68bsalomon GrPipelineBuilder::AutoRestoreStencil*, 7976be6f7cb66b277e7b1ce13d09b635fb8e09a2f68bsalomon GrScissorState*, 7988059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt const SkRect* devBounds) = 0; 7997475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com 80025fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com enum { 80125fb21f5df904c6f111bbf8f07e6a6c339416d09bsalomon@google.com kPreallocGeoSrcStateStackCnt = 4, 802ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com }; 80302ddc8b85ace91b15feb329a6a1d5d62b2b846c6bsalomon@google.com SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcStateStack; 8046e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTarget. 8056e4e65066a7c0dbc9bfbfe4b8f5d49c3d8a79b59bsalomon@google.com GrContext* fContext; 8062a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org // To keep track that we always have at least as many debug marker adds as removes 8072a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org int fGpuTraceMarkerCount; 8082a05de0c049a8648942a55016126a1f92e1c14d6commit-bot@chromium.org GrTraceMarkerSet fActiveTraceMarkers; 8093eee3834fba1d2e29dfb61adcb97e4624b6a3ac8egdaniel GrTraceMarkerSet fStoredTraceMarkers; 810fa35e3ddcc9d130ce87c927218bdf27879c38711reed@google.com 811a4de8c257ea0be8ff7081f645249b6afe5c48e7ecommit-bot@chromium.org typedef SkRefCnt INHERITED; 812ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}; 813ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 814329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt/* 815329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * This class is JUST for clip mask manager. Everyone else should just use draw target above. 816329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 8176db519c42471aaaa8a8e1a3ece314014481ab832joshualittclass GrClipTarget : public GrDrawTarget { 8186db519c42471aaaa8a8e1a3ece314014481ab832joshualittpublic: 819329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipTarget(GrContext* context) : INHERITED(context) { 820329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt fClipMaskManager.setClipTarget(this); 821329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt } 822329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 823329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt /* Clip mask manager needs access to the context. 824329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt * TODO we only need a very small subset of context in the CMM. 825329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt */ 826329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrContext* getContext() { return INHERITED::getContext(); } 827329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt const GrContext* getContext() const { return INHERITED::getContext(); } 828329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8296db519c42471aaaa8a8e1a3ece314014481ab832joshualitt /** 8306db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * Clip Mask Manager(and no one else) needs to clear private stencil bits. 8316db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * ClipTarget subclass sets clip bit in the stencil buffer. The subclass 8326db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * is free to clear the remaining bits to zero if masked clears are more 8336db519c42471aaaa8a8e1a3ece314014481ab832joshualitt * expensive than clearing all bits. 8346db519c42471aaaa8a8e1a3ece314014481ab832joshualitt */ 8356db519c42471aaaa8a8e1a3ece314014481ab832joshualitt virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* = NULL) = 0; 8366db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 8373bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt /** 8383bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * Release any resources that are cached but not currently in use. This 8393bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt * is intended to give an application some recourse when resources are low. 8403bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt */ 84136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein void purgeResources() override { 8423bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // The clip mask manager can rebuild all its clip masks so just 8433bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt // get rid of them all. 8443bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt fClipMaskManager.purgeResources(); 8453bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt }; 8463bdd7dce5e8393aeed0a64b583e1077f5159d516joshualitt 847329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualittprotected: 848329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt GrClipMaskManager fClipMaskManager; 849329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8506db519c42471aaaa8a8e1a3ece314014481ab832joshualittprivate: 85136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein GrClipMaskManager* clipMaskManager() override { return &fClipMaskManager; } 852329bf4862e9d5e05363c2b071d8ca475a0ef1952joshualitt 8538dd688b7569df569a672a8a67b2db86a9d376cfcegdaniel virtual bool setupClip(GrPipelineBuilder*, 8546be6f7cb66b277e7b1ce13d09b635fb8e09a2f68bsalomon GrPipelineBuilder::AutoRestoreFragmentProcessors*, 8556be6f7cb66b277e7b1ce13d09b635fb8e09a2f68bsalomon GrPipelineBuilder::AutoRestoreStencil*, 8568059eb9f6e24ed609393fbda4ad71edea03ac258joshualitt GrScissorState* scissorState, 85736352bf5e38f45a70ee4f4fc132a38048d38206dmtklein const SkRect* devBounds) override; 8582c93efeb6f2dd652eb2575c04124d82952f020c7joshualitt 8596db519c42471aaaa8a8e1a3ece314014481ab832joshualitt typedef GrDrawTarget INHERITED; 8606db519c42471aaaa8a8e1a3ece314014481ab832joshualitt}; 8616db519c42471aaaa8a8e1a3ece314014481ab832joshualitt 862ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif 863