aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrGpu.cpp27
-rw-r--r--src/gpu/GrGpu.h16
-rw-r--r--src/gpu/GrTest.cpp20
-rw-r--r--src/gpu/gl/GrGpuGL.cpp38
-rw-r--r--src/gpu/gl/GrGpuGL.h131
5 files changed, 135 insertions, 97 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index ac76e1503c..297f2bf9ef 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -277,9 +277,6 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
void GrGpu::draw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& info) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds)) {
- return;
- }
this->onDraw(ds, info);
}
@@ -287,25 +284,14 @@ void GrGpu::stencilPath(const GrOptDrawState& ds,
const GrPath* path,
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
-
- if (!this->flushGraphicsState(ds)) {
- return;
- }
-
- this->pathRendering()->stencilPath(path, stencilSettings);
+ this->onStencilPath(ds, path, stencilSettings);
}
-
void GrGpu::drawPath(const GrOptDrawState& ds,
const GrPath* path,
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
-
- if (!this->flushGraphicsState(ds)) {
- return;
- }
-
- this->pathRendering()->drawPath(path, stencilSettings);
+ this->onDrawPath(ds, path, stencilSettings);
}
void GrGpu::drawPaths(const GrOptDrawState& ds,
@@ -317,12 +303,7 @@ void GrGpu::drawPaths(const GrOptDrawState& ds,
int count,
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
-
- if (!this->flushGraphicsState(ds)) {
- return;
- }
-
pathRange->willDrawPaths(indices, indexType, count);
- this->pathRendering()->drawPaths(pathRange, indices, indexType, transformValues,
- transformType, count, stencilSettings);
+ this->onDrawPaths(ds, pathRange, indices, indexType, transformValues,
+ transformType, count, stencilSettings);
}
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 7f4eb53899..611b7a51fe 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -436,6 +436,16 @@ private:
// overridden by backend-specific derived class to perform the draw call.
virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) = 0;
+ virtual void onStencilPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) = 0;
+ virtual void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) = 0;
+ virtual void onDrawPaths(const GrOptDrawState&,
+ const GrPathRange*,
+ const void* indices,
+ GrDrawTarget::PathIndexType,
+ const float transformValues[],
+ GrDrawTarget::PathTransformType,
+ int count,
+ const GrStencilSettings&) = 0;
// overridden by backend-specific derived class to perform the read pixels.
virtual bool onReadPixels(GrRenderTarget* target,
@@ -461,12 +471,6 @@ private:
// attaches an existing SB to an existing RT.
virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTarget*) = 0;
- // The GrGpu typically records the clients requested state and then flushes
- // deltas from previous state at draw time. This function does the
- // backend-specific flush of the state.
- // returns false if current state is unsupported.
- virtual bool flushGraphicsState(const GrOptDrawState&) = 0;
-
// clears target's entire stencil buffer to 0
virtual void clearStencil(GrRenderTarget* target) = 0;
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 7038c10966..7f2848faec 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -115,6 +115,20 @@ private:
void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK_OVERRIDE {}
+ void onStencilPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) SK_OVERRIDE {
+ }
+
+ void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) SK_OVERRIDE {}
+
+ void onDrawPaths(const GrOptDrawState&,
+ const GrPathRange*,
+ const void* indices,
+ GrDrawTarget::PathIndexType,
+ const float transformValues[],
+ GrDrawTarget::PathTransformType,
+ int count,
+ const GrStencilSettings&) SK_OVERRIDE {}
+
bool onReadPixels(GrRenderTarget* target,
int left, int top, int width, int height,
GrPixelConfig,
@@ -140,13 +154,11 @@ private:
return false;
}
- bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE { return false; }
-
void clearStencil(GrRenderTarget* target) SK_OVERRIDE {}
- void didAddGpuTraceMarker() SK_OVERRIDE { }
+ void didAddGpuTraceMarker() SK_OVERRIDE {}
- void didRemoveGpuTraceMarker() SK_OVERRIDE { }
+ void didRemoveGpuTraceMarker() SK_OVERRIDE {}
typedef GrGpu INHERITED;
};
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 7d3920fad9..1fea77a096 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1337,7 +1337,7 @@ void GrGLGpu::flushScissor(const GrClipMaskManager::ScissorState& scissorState,
this->disableScissor();
}
-bool GrGLGpu::flushGraphicsState(const GrOptDrawState& optState) {
+bool GrGLGpu::flushGLState(const GrOptDrawState& optState) {
// GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
SkASSERT(optState.getRenderTarget());
@@ -1827,6 +1827,10 @@ GrGLenum gPrimitiveType2GLMode[] = {
#endif
void GrGLGpu::onDraw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& info) {
+ if (!this->flushGLState(ds)) {
+ return;
+ }
+
size_t indexOffsetInBytes;
this->setupGeometry(ds, info, &indexOffsetInBytes);
@@ -1860,6 +1864,38 @@ void GrGLGpu::onDraw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& inf
#endif
}
+void GrGLGpu::onStencilPath(const GrOptDrawState& ds,
+ const GrPath* path,
+ const GrStencilSettings& stencil) {
+ if (!this->flushGLState(ds)) {
+ return;
+ }
+ fPathRendering->stencilPath(path, stencil);
+}
+
+void GrGLGpu::onDrawPath(const GrOptDrawState& ds, const GrPath* path,
+ const GrStencilSettings& stencil) {
+ if (!this->flushGLState(ds)) {
+ return;
+ }
+ fPathRendering->drawPath(path, stencil);
+}
+
+void GrGLGpu::onDrawPaths(const GrOptDrawState& ds,
+ const GrPathRange* pathRange,
+ const void* indices,
+ GrDrawTarget::PathIndexType indexType,
+ const float transformValues[],
+ GrDrawTarget::PathTransformType transformType,
+ int count,
+ const GrStencilSettings& stencil) {
+ if (!this->flushGLState(ds)) {
+ return;
+ }
+ fPathRendering->drawPaths(pathRange, indices, indexType, transformValues,
+ transformType, count, stencil);
+}
+
void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
if (rt->needsResolve()) {
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 9e892f8f1d..7137bc708f 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -30,9 +30,9 @@
class GrGLGpu : public GrGpu {
public:
GrGLGpu(const GrGLContext& ctx, GrContext* context);
- virtual ~GrGLGpu();
+ ~GrGLGpu() SK_OVERRIDE;
- virtual void contextAbandoned() SK_OVERRIDE;
+ void contextAbandoned() SK_OVERRIDE;
const GrGLContext& glContext() const { return fGLContext; }
@@ -48,27 +48,26 @@ public:
return static_cast<GrGLPathRendering*>(pathRendering());
}
- virtual void discard(GrRenderTarget*) SK_OVERRIDE;
+ void discard(GrRenderTarget*) SK_OVERRIDE;
// Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL
// state.
void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
// GrGpu overrides
- virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig,
- GrPixelConfig surfaceConfig) const SK_OVERRIDE;
- virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig,
- GrPixelConfig surfaceConfig) const SK_OVERRIDE;
- virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const SK_OVERRIDE;
- virtual bool readPixelsWillPayForYFlip(
- GrRenderTarget* renderTarget,
- int left, int top,
- int width, int height,
- GrPixelConfig config,
- size_t rowBytes) const SK_OVERRIDE;
- virtual bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE;
-
- virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OVERRIDE;
+ GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig,
+ GrPixelConfig surfaceConfig) const SK_OVERRIDE;
+ GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig,
+ GrPixelConfig surfaceConfig) const SK_OVERRIDE;
+ bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const SK_OVERRIDE;
+ bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget,
+ int left, int top,
+ int width, int height,
+ GrPixelConfig config,
+ size_t rowBytes) const SK_OVERRIDE;
+ bool fullReadPixelsIsFasterThanPartial() const SK_OVERRIDE;
+
+ bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OVERRIDE;
// These functions should be used to bind GL objects. They track the GL state and skip redundant
// bindings. Making the equivalent glBind calls directly will confuse the state tracking.
@@ -105,65 +104,71 @@ public:
const SkIPoint& dstPoint) SK_OVERRIDE;
protected:
- virtual void buildProgramDesc(const GrOptDrawState&,
- const GrProgramDesc::DescInfo&,
- GrGpu::DrawType,
- GrProgramDesc*) SK_OVERRIDE;
+ void buildProgramDesc(const GrOptDrawState&,
+ const GrProgramDesc::DescInfo&,
+ GrGpu::DrawType,
+ GrProgramDesc*) SK_OVERRIDE;
private:
// GrGpu overrides
- virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE;
-
- virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
- const void* srcData,
- size_t rowBytes) SK_OVERRIDE;
- virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
- const void* srcData) SK_OVERRIDE;
- virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
- virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
- virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE;
- virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) SK_OVERRIDE;
- virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt,
- int width,
- int height) SK_OVERRIDE;
- virtual bool attachStencilBufferToRenderTarget(
- GrStencilBuffer* sb,
- GrRenderTarget* rt) SK_OVERRIDE;
-
- virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
- bool canIgnoreRect) SK_OVERRIDE;
-
- virtual void onClearStencilClip(GrRenderTarget*,
- const SkIRect& rect,
- bool insideClip) SK_OVERRIDE;
-
- virtual bool onReadPixels(GrRenderTarget* target,
- int left, int top,
- int width, int height,
- GrPixelConfig,
- void* buffer,
+ void onResetContext(uint32_t resetBits) SK_OVERRIDE;
+
+ GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
+ const void* srcData,
+ size_t rowBytes) SK_OVERRIDE;
+ GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
+ const void* srcData) SK_OVERRIDE;
+ GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
+ GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
+ GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE;
+ GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) SK_OVERRIDE;
+ bool createStencilBufferForRenderTarget(GrRenderTarget* rt,
+ int width, int height) SK_OVERRIDE;
+ bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTarget* rt) SK_OVERRIDE;
+
+ void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
+ bool canIgnoreRect) SK_OVERRIDE;
+
+ void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) SK_OVERRIDE;
+
+ bool onReadPixels(GrRenderTarget* target,
+ int left, int top,
+ int width, int height,
+ GrPixelConfig,
+ void* buffer,
+ size_t rowBytes) SK_OVERRIDE;
+
+ bool onWriteTexturePixels(GrTexture* texture,
+ int left, int top, int width, int height,
+ GrPixelConfig config, const void* buffer,
size_t rowBytes) SK_OVERRIDE;
- virtual bool onWriteTexturePixels(GrTexture* texture,
- int left, int top, int width, int height,
- GrPixelConfig config, const void* buffer,
- size_t rowBytes) SK_OVERRIDE;
+ void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE;
- virtual void onResolveRenderTarget(GrRenderTarget* target) SK_OVERRIDE;
+ void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK_OVERRIDE;
+ void onStencilPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) SK_OVERRIDE;
+ void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&) SK_OVERRIDE;
+ void onDrawPaths(const GrOptDrawState&,
+ const GrPathRange*,
+ const void* indices,
+ GrDrawTarget::PathIndexType,
+ const float transformValues[],
+ GrDrawTarget::PathTransformType,
+ int count,
+ const GrStencilSettings&) SK_OVERRIDE;
- virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) SK_OVERRIDE;
-
-
- virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE;
- virtual bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE;
+ void clearStencil(GrRenderTarget*) SK_OVERRIDE;
// GrDrawTarget overrides
- virtual void didAddGpuTraceMarker() SK_OVERRIDE;
- virtual void didRemoveGpuTraceMarker() SK_OVERRIDE;
+ void didAddGpuTraceMarker() SK_OVERRIDE;
+ void didRemoveGpuTraceMarker() SK_OVERRIDE;
// binds texture unit in GL
void setTextureUnit(int unitIdx);
+ // Flushes state from GrOptDrawState to GL. Returns false if the state couldn't be set.
+ bool flushGLState(const GrOptDrawState&);
+
// Sets up vertex attribute pointers and strides. On return indexOffsetInBytes gives the offset
// an into the index buffer. It does not account for drawInfo.startIndex() but rather the start
// index is relative to the returned offset.