/* Copyright 2011 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef GrGpu_DEFINED #define GrGpu_DEFINED #include "GrDrawTarget.h" #include "GrPathRenderer.h" #include "GrRect.h" #include "GrRefCnt.h" #include "GrTexture.h" class GrContext; class GrIndexBufferAllocPool; class GrResource; class GrVertexBufferAllocPool; /** * Gpu usage statistics. */ struct GrGpuStats { uint32_t fVertexCnt; //resetContext(); fContextIsDirty = false; } } // used to save and restore state when the GrGpu needs // to make its geometry pools available internally class AutoInternalDrawGeomRestore { public: AutoInternalDrawGeomRestore(GrGpu* gpu) : fAgsr(gpu) { fGpu = gpu; fVertexPoolWasInUse = gpu->fVertexPoolInUse; fIndexPoolWasInUse = gpu->fIndexPoolInUse; gpu->fVertexPoolInUse = fVertexPoolWasInUse || (kBuffer_GeometrySrcType != gpu->fGeometrySrc.fVertexSrc); gpu->fIndexPoolInUse = fIndexPoolWasInUse || (kBuffer_GeometrySrcType != gpu->fGeometrySrc.fIndexSrc);; fSavedPoolVertexBuffer = gpu->fCurrPoolVertexBuffer; fSavedPoolStartVertex = gpu->fCurrPoolStartVertex; fSavedPoolIndexBuffer = gpu->fCurrPoolIndexBuffer; fSavedPoolStartIndex = gpu->fCurrPoolStartIndex; fSavedReservedGeometry = gpu->fReservedGeometry; gpu->fReservedGeometry.fLocked = false; } ~AutoInternalDrawGeomRestore() { fGpu->fCurrPoolVertexBuffer = fSavedPoolVertexBuffer; fGpu->fCurrPoolStartVertex = fSavedPoolStartVertex; fGpu->fCurrPoolIndexBuffer = fSavedPoolIndexBuffer; fGpu->fCurrPoolStartIndex = fSavedPoolStartIndex; fGpu->fVertexPoolInUse = fVertexPoolWasInUse; fGpu->fIndexPoolInUse = fIndexPoolWasInUse; fGpu->fReservedGeometry = fSavedReservedGeometry; } private: AutoGeometrySrcRestore fAgsr; GrGpu* fGpu; const GrVertexBuffer* fSavedPoolVertexBuffer; int fSavedPoolStartVertex; const GrIndexBuffer* fSavedPoolIndexBuffer; int fSavedPoolStartIndex; bool fVertexPoolWasInUse; bool fIndexPoolWasInUse; ReservedGeometry fSavedReservedGeometry; }; typedef GrDrawTarget INHERITED; }; #endif