#include "GrDrawTarget.h"
#include "GrClipMaskManager.h"
+#include "GrPathRendering.h"
#include "SkPath.h"
class GrContext;
GrContext* getContext() { return this->INHERITED::getContext(); }
const GrContext* getContext() const { return this->INHERITED::getContext(); }
+ GrPathRendering* pathRendering() {
+ return fPathRendering.get();
+ }
+
+ // Called by GrContext when the underlying backend context has been destroyed.
+ // GrGpu should use this to ensure that no backend API calls will be made from
+ // here onward, including in its destructor. Subclasses should call
+ // INHERITED::contextAbandoned() if they override this.
+ virtual void contextAbandoned();
+
/**
* The GrGpu object normally assumes that no outsider is setting state
* within the underlying 3D API's context/device/whatever. This call informs
GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic);
/**
- * Creates a path object that can be stenciled using stencilPath(). It is
- * only legal to call this if the caps report support for path stenciling.
- */
- GrPath* createPath(const SkPath& path, const SkStrokeRec& stroke);
-
- /**
- * Creates a path range object that can be used to draw multiple paths via
- * drawPaths(). It is only legal to call this if the caps report support for
- * path rendering.
- */
- GrPathRange* createPathRange(size_t size, const SkStrokeRec&);
-
- /**
* Returns an index buffer that can be used to render quads.
* Six indices per quad: 0, 1, 2, 0, 2, 3, etc.
* The max number of quads can be queried using GrIndexBuffer::maxQuads().
GrPixelConfig config, const void* buffer,
size_t rowBytes);
- /**
- * Called to tell GrGpu that all GrGpuResources have been lost and should
- * be abandoned. Overrides must call INHERITED::abandonResources().
- */
- virtual void abandonResources();
-
- /**
- * Called to tell GrGpu to release all GrGpuResources. Overrides must call
- * INHERITED::releaseResources().
- */
- void releaseResources();
-
- /**
- * Add object to list of objects. Should only be called by GrGpuResource.
- * @param resource the resource to add.
- */
- void insertObject(GrGpuResource* object);
-
- /**
- * Remove object from list of objects. Should only be called by GrGpuResource.
- * @param resource the resource to remove.
- */
- void removeObject(GrGpuResource* object);
-
// GrDrawTarget overrides
virtual void clear(const SkIRect* rect,
GrColor color,
virtual void purgeResources() SK_OVERRIDE {
// The clip mask manager can rebuild all its clip masks so just
// get rid of them all.
- fClipMaskManager.releaseResources();
+ fClipMaskManager.purgeResources();
}
// After the client interacts directly with the 3D context state the GrGpu
// GrGpu subclass sets clip bit in the stencil buffer. The subclass is
// free to clear the remaining bits to zero if masked clears are more
// expensive than clearing all bits.
- virtual void clearStencilClip(const SkIRect& rect, bool insideClip) = 0;
+ virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) = 0;
enum PrivateDrawStateStateBits {
kFirstBit = (GrDrawState::kLastPublicStateBit << 1),
kDrawPaths_DrawType,
};
+ static bool IsPathRenderingDrawType(DrawType type) {
+ return kDrawPath_DrawType == type || kDrawPaths_DrawType == type;
+ }
+
+ GrContext::GPUStats* gpuStats() { return &fGPUStats; }
+
protected:
DrawType PrimTypeToDrawType(GrPrimitiveType type) {
switch (type) {
GrClipMaskManager fClipMaskManager;
+ GrContext::GPUStats fGPUStats;
+
struct GeometryPoolState {
const GrVertexBuffer* fPoolVertexBuffer;
int fPoolStartVertex;
void finalizeReservedVertices();
void finalizeReservedIndices();
+ SkAutoTDelete<GrPathRendering> fPathRendering;
+
private:
// GrDrawTarget overrides
virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE;
virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) = 0;
virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
- virtual GrPath* onCreatePath(const SkPath& path, const SkStrokeRec&) = 0;
- virtual GrPathRange* onCreatePathRange(size_t size, const SkStrokeRec&) = 0;
// overridden by backend-specific derived class to perform the clear and
// clearRect. NULL rect means clear whole target. If canIgnoreRect is
// true, it is okay to perform a full clear instead of a partial clear
- virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect) = 0;
+ virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
+ bool canIgnoreRect) = 0;
// overridden by backend-specific derived class to perform the draw call.
virtual void onGpuDraw(const DrawInfo&) = 0;
- // overridden by backend-specific derived class to perform the path stenciling.
- virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) = 0;
- virtual void onGpuDrawPath(const GrPath*, SkPath::FillType) = 0;
- virtual void onGpuDrawPaths(const GrPathRange*,
- const uint32_t indices[], int count,
- const float transforms[], PathTransformType,
- SkPath::FillType) = 0;
-
// overridden by backend-specific derived class to perform the read pixels.
virtual bool onReadPixels(GrRenderTarget* target,
int left, int top, int width, int height,
// returns false if current state is unsupported.
virtual bool flushGraphicsState(DrawType, const GrDeviceCoordTexture* dstCopy) = 0;
- // clears the entire stencil buffer to 0
- virtual void clearStencil() = 0;
+ // clears target's entire stencil buffer to 0
+ virtual void clearStencil(GrRenderTarget* target) = 0;
// Given a rt, find or create a stencil buffer and attach it
bool attachStencilBufferToRenderTarget(GrRenderTarget* target);
enum {
kPreallocGeomPoolStateStackCnt = 4,
};
- typedef SkTInternalLList<GrGpuResource> ObjectList;
SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoolStateStack;
ResetTimestamp fResetTimestamp;
uint32_t fResetBits;
int fIndexPoolUseCnt;
// these are mutable so they can be created on-demand
mutable GrIndexBuffer* fQuadIndexBuffer;
- // Used to abandon/release all resources created by this GrGpu. TODO: Move this
- // functionality to GrResourceCache.
- ObjectList fObjectList;
typedef GrDrawTarget INHERITED;
};