Refactor GrGpu path rendering functions to GrPathRendering
GrGpu, GrGLGpu, GrPathRendering, GrGLPathRendering all duplicated each others' path rendering related member functions. Make GrPathRending the logical extension of GrGpu by removing the methods from GrGpu. Similarly to the GL variants. Changes includes and forward declarations due to removing GrDrawTarget.h include from GrGpu.h. This was necessary due to GrDrawTarget.h including GrPathRendering.h, and now GrPathRendering.h includes GrGpu.h. (Also GrGpu.h does not need GrDrawTarget.h anymore). Very slight runtime improvement on x86_64: desk_fontwipe.skp_1 836us -> 841us 1.01x desk_silkfinance.skp_1 2.01ms -> 2.01ms 1x desk_forecastio.skp_1 7.03ms -> 7.05ms 1x desk_weather.skp_1 3.74ms -> 3.74ms 1x desk_twitter.skp_1 8.02ms -> 8.01ms 1x desk_mapsvg.skp_1 5.24ms -> 5.23ms 1x desk_pokemonwiki.skp_1 7.06ms -> 7.03ms 1x desk_sfgate.skp_1 3.19ms -> 3.17ms 1x tabl_cuteoverload.skp_1 2.66ms -> 2.64ms 0.99x ... tabl_transformice.skp_1 3.06ms -> 2.98ms 0.98x tabl_googlecalendar.skp_1 11.3ms -> 11ms 0.97x tabl_gamedeksiam.skp_1 12.8ms -> 12.4ms 0.97x desk_samoasvg.skp_1 10.6ms -> 10.3ms 0.97x tabl_worldjournal.skp_1 4.44ms -> 4.3ms 0.97x Review URL: https://codereview.chromium.org/1157683006
This commit is contained in:
parent
d772491274
commit
cabe20cafd
@ -15,9 +15,11 @@
|
||||
#include "SkTypes.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawContext.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrPaint.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrResourceKey.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "GrBatchFontCache.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrFontAtlasSizes.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrRectanizer.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "GrBatchAtlas.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPendingProgramElement.h"
|
||||
#include "GrPipeline.h"
|
||||
#include "GrTRecorder.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
#include "GrIndexBuffer.h"
|
||||
#include "GrPathRendering.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrRenderTargetPriv.h"
|
||||
#include "GrStencilAttachment.h"
|
||||
@ -300,29 +301,3 @@ void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
|
||||
this->onDraw(args, *verts);
|
||||
} while ((verts = iter.next()));
|
||||
}
|
||||
|
||||
void GrGpu::stencilPath(const GrPath* path, const StencilPathState& state) {
|
||||
this->handleDirtyContext();
|
||||
this->onStencilPath(path, state);
|
||||
}
|
||||
|
||||
void GrGpu::drawPath(const DrawArgs& args,
|
||||
const GrPath* path,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
this->handleDirtyContext();
|
||||
this->onDrawPath(args, path, stencilSettings);
|
||||
}
|
||||
|
||||
void GrGpu::drawPaths(const DrawArgs& args,
|
||||
const GrPathRange* pathRange,
|
||||
const void* indices,
|
||||
GrDrawTarget::PathIndexType indexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType transformType,
|
||||
int count,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
this->handleDirtyContext();
|
||||
pathRange->willDrawPaths(indices, indexType, count);
|
||||
this->onDrawPaths(args, pathRange, indices, indexType, transformValues,
|
||||
transformType, count, stencilSettings);
|
||||
}
|
||||
|
@ -8,21 +8,30 @@
|
||||
#ifndef GrGpu_DEFINED
|
||||
#define GrGpu_DEFINED
|
||||
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrPathRendering.h"
|
||||
#include "GrPipelineBuilder.h"
|
||||
#include "GrProgramDesc.h"
|
||||
#include "GrStencil.h"
|
||||
#include "GrTraceMarker.h"
|
||||
#include "GrXferProcessor.h"
|
||||
#include "SkPath.h"
|
||||
|
||||
class GrBatchTracker;
|
||||
class GrContext;
|
||||
struct GrGLInterface;
|
||||
class GrIndexBuffer;
|
||||
class GrNonInstancedVertices;
|
||||
class GrPath;
|
||||
class GrPathRange;
|
||||
class GrPathRenderer;
|
||||
class GrPathRendererChain;
|
||||
class GrPathRendering;
|
||||
class GrPipeline;
|
||||
class GrPrimitiveProcessor;
|
||||
class GrRenderTarget;
|
||||
class GrStencilAttachment;
|
||||
class GrSurface;
|
||||
class GrTexture;
|
||||
class GrVertexBuffer;
|
||||
class GrVertices;
|
||||
|
||||
class GrGpu : public SkRefCnt {
|
||||
@ -47,7 +56,7 @@ public:
|
||||
*/
|
||||
const GrCaps* caps() const { return fCaps.get(); }
|
||||
|
||||
GrPathRendering* pathRendering() { return fPathRendering.get(); }
|
||||
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
|
||||
@ -299,27 +308,6 @@ public:
|
||||
|
||||
void draw(const DrawArgs&, const GrVertices&);
|
||||
|
||||
/** None of these params are optional, pointers used just to avoid making copies. */
|
||||
struct StencilPathState {
|
||||
bool fUseHWAA;
|
||||
GrRenderTarget* fRenderTarget;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrStencilSettings* fStencil;
|
||||
const GrScissorState* fScissor;
|
||||
};
|
||||
|
||||
void stencilPath(const GrPath*, const StencilPathState&);
|
||||
|
||||
void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&);
|
||||
void drawPaths(const DrawArgs&,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
GrDrawTarget::PathIndexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType,
|
||||
int count,
|
||||
const GrStencilSettings&);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Debugging and Stats
|
||||
|
||||
@ -439,19 +427,7 @@ private:
|
||||
|
||||
// overridden by backend-specific derived class to perform the draw call.
|
||||
virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0;
|
||||
virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0;
|
||||
|
||||
virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) = 0;
|
||||
virtual void onDrawPaths(const DrawArgs&,
|
||||
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,
|
||||
int left, int top, int width, int height,
|
||||
GrPixelConfig,
|
||||
@ -502,6 +478,7 @@ private:
|
||||
// The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
|
||||
GrContext* fContext;
|
||||
|
||||
friend class GrPathRendering;
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "GrGpuResource.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "GrAtlas.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawContext.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrLayerCache.h"
|
||||
|
@ -83,7 +83,7 @@ protected:
|
||||
|
||||
private:
|
||||
// Notify when paths will be drawn in case this is a lazy-loaded path range.
|
||||
friend class GrGpu;
|
||||
friend class GrPathRendering;
|
||||
void willDrawPaths(const void* indices, PathIndexType, int count) const;
|
||||
template<typename IndexType> void willDrawPaths(const void* indices, int count) const;
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
#define GrPathRendering_DEFINED
|
||||
|
||||
#include "SkPath.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrPathRange.h"
|
||||
|
||||
class SkDescriptor;
|
||||
class SkTypeface;
|
||||
class GrPath;
|
||||
class GrGpu;
|
||||
class GrStencilSettings;
|
||||
class GrStrokeInfo;
|
||||
|
||||
@ -127,14 +127,67 @@ public:
|
||||
virtual GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*,
|
||||
const GrStrokeInfo&) = 0;
|
||||
|
||||
virtual void stencilPath(const GrPath*, const GrStencilSettings&) = 0;
|
||||
virtual void drawPath(const GrPath*, const GrStencilSettings&) = 0;
|
||||
virtual void drawPaths(const GrPathRange*, const void* indices, PathIndexType,
|
||||
const float transformValues[], PathTransformType, int count,
|
||||
const GrStencilSettings&) = 0;
|
||||
protected:
|
||||
GrPathRendering() { }
|
||||
/** None of these params are optional, pointers used just to avoid making copies. */
|
||||
struct StencilPathArgs {
|
||||
StencilPathArgs(bool useHWAA,
|
||||
GrRenderTarget* renderTarget,
|
||||
const SkMatrix* viewMatrix,
|
||||
const GrScissorState* scissor,
|
||||
const GrStencilSettings* stencil)
|
||||
: fUseHWAA(useHWAA)
|
||||
, fRenderTarget(renderTarget)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fScissor(scissor)
|
||||
, fStencil(stencil) {
|
||||
}
|
||||
bool fUseHWAA;
|
||||
GrRenderTarget* fRenderTarget;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrScissorState* fScissor;
|
||||
const GrStencilSettings* fStencil;
|
||||
};
|
||||
|
||||
void stencilPath(const StencilPathArgs& args, const GrPath* path) {
|
||||
fGpu->handleDirtyContext();
|
||||
this->onStencilPath(args, path);
|
||||
}
|
||||
|
||||
struct DrawPathArgs : public GrGpu::DrawArgs {
|
||||
DrawPathArgs(const GrPrimitiveProcessor* primProc,
|
||||
const GrPipeline* pipeline,
|
||||
const GrProgramDesc* desc,
|
||||
const GrBatchTracker* batchTracker,
|
||||
const GrStencilSettings* stencil)
|
||||
: DrawArgs(primProc, pipeline, desc, batchTracker)
|
||||
, fStencil(stencil) {
|
||||
}
|
||||
|
||||
const GrStencilSettings* fStencil;
|
||||
};
|
||||
|
||||
void drawPath(const DrawPathArgs& args, const GrPath* path) {
|
||||
fGpu->handleDirtyContext();
|
||||
this->onDrawPath(args, path);
|
||||
}
|
||||
|
||||
void drawPaths(const DrawPathArgs& args, const GrPathRange* pathRange, const void* indices,
|
||||
PathIndexType indexType, const float transformValues[],
|
||||
PathTransformType transformType, int count) {
|
||||
fGpu->handleDirtyContext();
|
||||
pathRange->willDrawPaths(indices, indexType, count);
|
||||
this->onDrawPaths(args, pathRange, indices, indexType, transformValues, transformType,
|
||||
count);
|
||||
}
|
||||
protected:
|
||||
GrPathRendering(GrGpu* gpu)
|
||||
: fGpu(gpu) {
|
||||
}
|
||||
virtual void onStencilPath(const StencilPathArgs&, const GrPath*) = 0;
|
||||
virtual void onDrawPath(const DrawPathArgs&, const GrPath*) = 0;
|
||||
virtual void onDrawPaths(const DrawPathArgs&, const GrPathRange*, const void*, PathIndexType,
|
||||
const float[], PathTransformType, int) = 0;
|
||||
|
||||
GrGpu* fGpu;
|
||||
private:
|
||||
GrPathRendering& operator=(const GrPathRendering&);
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "GrColor.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrPendingFragmentStage.h"
|
||||
#include "GrPrimitiveProcessor.h"
|
||||
#include "GrProgramDesc.h"
|
||||
#include "GrStencil.h"
|
||||
#include "GrTypesPriv.h"
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "GrResourceProvider.h"
|
||||
|
||||
#include "GrGpu.h"
|
||||
#include "GrIndexBuffer.h"
|
||||
#include "GrPathRendering.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrResourceKey.h"
|
||||
#include "GrVertexBuffer.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "GrPipelineBuilder.h"
|
||||
#include "GrCaps.h"
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrGpu.h"
|
||||
|
||||
#include "SkData.h"
|
||||
|
@ -55,14 +55,9 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
|
||||
}
|
||||
|
||||
void GrTargetCommands::StencilPath::execute(GrGpu* gpu) {
|
||||
GrGpu::StencilPathState state;
|
||||
state.fRenderTarget = fRenderTarget.get();
|
||||
state.fScissor = &fScissor;
|
||||
state.fStencil = &fStencil;
|
||||
state.fUseHWAA = fUseHWAA;
|
||||
state.fViewMatrix = &fViewMatrix;
|
||||
|
||||
gpu->stencilPath(this->path(), state);
|
||||
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix, &fScissor,
|
||||
&fStencil);
|
||||
gpu->pathRendering()->stencilPath(args, this->path());
|
||||
}
|
||||
|
||||
void GrTargetCommands::DrawPath::execute(GrGpu* gpu) {
|
||||
@ -71,9 +66,9 @@ void GrTargetCommands::DrawPath::execute(GrGpu* gpu) {
|
||||
fState->fBatchTracker);
|
||||
fState->fCompiled = true;
|
||||
}
|
||||
DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
|
||||
&fState->fDesc, &fState->fBatchTracker);
|
||||
gpu->drawPath(args, this->path(), fStencilSettings);
|
||||
GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
|
||||
&fState->fDesc, &fState->fBatchTracker, &fStencilSettings);
|
||||
gpu->pathRendering()->drawPath(args, this->path());
|
||||
}
|
||||
|
||||
void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) {
|
||||
@ -82,12 +77,10 @@ void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) {
|
||||
fState->fBatchTracker);
|
||||
fState->fCompiled = true;
|
||||
}
|
||||
DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
|
||||
&fState->fDesc, &fState->fBatchTracker);
|
||||
gpu->drawPaths(args, this->pathRange(),
|
||||
fIndices, fIndexType,
|
||||
fTransforms, fTransformType,
|
||||
fCount, fStencilSettings);
|
||||
GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
|
||||
&fState->fDesc, &fState->fBatchTracker, &fStencilSettings);
|
||||
gpu->pathRendering()->drawPaths(args, this->pathRange(), fIndices, fIndexType, fTransforms,
|
||||
fTransformType, fCount);
|
||||
}
|
||||
|
||||
void GrTargetCommands::DrawBatch::execute(GrGpu*) {
|
||||
|
@ -201,19 +201,6 @@ private:
|
||||
|
||||
void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override {}
|
||||
|
||||
void onStencilPath(const GrPath* path, const StencilPathState& state) override {}
|
||||
|
||||
void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) override {}
|
||||
|
||||
void onDrawPaths(const DrawArgs&,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
GrDrawTarget::PathIndexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType,
|
||||
int count,
|
||||
const GrStencilSettings&) override {}
|
||||
|
||||
bool onReadPixels(GrRenderTarget* target,
|
||||
int left, int top, int width, int height,
|
||||
GrPixelConfig,
|
||||
|
@ -1951,43 +1951,6 @@ void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrGLGpu::onStencilPath(const GrPath* path, const StencilPathState& state) {
|
||||
this->flushColorWrite(false);
|
||||
this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
|
||||
|
||||
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(state.fRenderTarget);
|
||||
SkISize size = SkISize::Make(rt->width(), rt->height());
|
||||
this->glPathRendering()->setProjectionMatrix(*state.fViewMatrix, size, rt->origin());
|
||||
this->flushScissor(*state.fScissor, rt->getViewport(), rt->origin());
|
||||
this->flushHWAAState(rt, state.fUseHWAA);
|
||||
this->flushRenderTarget(rt, NULL);
|
||||
|
||||
fPathRendering->stencilPath(path, *state.fStencil);
|
||||
}
|
||||
|
||||
void GrGLGpu::onDrawPath(const DrawArgs& args, const GrPath* path,
|
||||
const GrStencilSettings& stencil) {
|
||||
if (!this->flushGLState(args)) {
|
||||
return;
|
||||
}
|
||||
fPathRendering->drawPath(path, stencil);
|
||||
}
|
||||
|
||||
void GrGLGpu::onDrawPaths(const DrawArgs& args,
|
||||
const GrPathRange* pathRange,
|
||||
const void* indices,
|
||||
GrDrawTarget::PathIndexType indexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType transformType,
|
||||
int count,
|
||||
const GrStencilSettings& stencil) {
|
||||
if (!this->flushGLState(args)) {
|
||||
return;
|
||||
}
|
||||
fPathRendering->drawPaths(pathRange, indices, indexType, transformValues,
|
||||
transformType, count, stencil);
|
||||
}
|
||||
|
||||
void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) {
|
||||
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
|
||||
if (rt->needsResolve()) {
|
||||
|
@ -157,16 +157,6 @@ private:
|
||||
void onResolveRenderTarget(GrRenderTarget* target) override;
|
||||
|
||||
void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override;
|
||||
void onStencilPath(const GrPath*, const StencilPathState&) override;
|
||||
void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) override;
|
||||
void onDrawPaths(const DrawArgs&,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
GrDrawTarget::PathIndexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType,
|
||||
int count,
|
||||
const GrStencilSettings&) override;
|
||||
|
||||
void clearStencil(GrRenderTarget*) override;
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "SkStream.h"
|
||||
#include "SkTypeface.h"
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
|
||||
#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(fGpu->glInterface(), RET, X)
|
||||
#define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
|
||||
#define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->gpu()->glInterface(), RET, X)
|
||||
|
||||
|
||||
static const GrGLenum gIndexType2GLType[] = {
|
||||
@ -60,7 +60,7 @@ static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) {
|
||||
}
|
||||
|
||||
GrGLPathRendering::GrGLPathRendering(GrGLGpu* gpu)
|
||||
: fGpu(gpu) {
|
||||
: GrPathRendering(gpu) {
|
||||
const GrGLInterface* glInterface = gpu->glInterface();
|
||||
fCaps.stencilThenCoverSupport =
|
||||
NULL != glInterface->fFunctions.fStencilThenCoverFillPath &&
|
||||
@ -92,12 +92,12 @@ void GrGLPathRendering::resetContext() {
|
||||
}
|
||||
|
||||
GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const GrStrokeInfo& stroke) {
|
||||
return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke));
|
||||
return SkNEW_ARGS(GrGLPath, (this->gpu(), inPath, stroke));
|
||||
}
|
||||
|
||||
GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* pathGenerator,
|
||||
const GrStrokeInfo& stroke) {
|
||||
return SkNEW_ARGS(GrGLPathRange, (fGpu, pathGenerator, stroke));
|
||||
return SkNEW_ARGS(GrGLPathRange, (this->gpu(), pathGenerator, stroke));
|
||||
}
|
||||
|
||||
GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
|
||||
@ -133,7 +133,7 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
|
||||
const GrGLuint basePathID = this->genPaths(numPaths);
|
||||
|
||||
// Init the basePathID as the template path.
|
||||
GrGLPath::InitPathObject(fGpu, basePathID, SkPath(), stroke);
|
||||
GrGLPath::InitPathObject(this->gpu(), basePathID, SkPath(), stroke);
|
||||
|
||||
GrGLenum status;
|
||||
GL_CALL_RET(status, PathMemoryGlyphIndexArray(basePathID, GR_GL_STANDARD_FONT_FORMAT,
|
||||
@ -150,13 +150,25 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
|
||||
// a pseudo PathGenerator whose sole purpose is to track the approximate gpu
|
||||
// memory size.
|
||||
const size_t gpuMemorySize = fontDataLength / 4;
|
||||
return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke));
|
||||
return SkNEW_ARGS(GrGLPathRange, (this->gpu(), basePathID, numPaths, gpuMemorySize, stroke));
|
||||
}
|
||||
|
||||
void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings& stencilSettings) {
|
||||
void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* path) {
|
||||
GrGLGpu* gpu = this->gpu();
|
||||
SkASSERT(gpu->caps()->shaderCaps()->pathRenderingSupport());
|
||||
gpu->flushColorWrite(false);
|
||||
gpu->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
|
||||
|
||||
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fRenderTarget);
|
||||
SkISize size = SkISize::Make(rt->width(), rt->height());
|
||||
this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin());
|
||||
gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin());
|
||||
gpu->flushHWAAState(rt, args.fUseHWAA);
|
||||
gpu->flushRenderTarget(rt, NULL);
|
||||
|
||||
const GrGLPath* glPath = static_cast<const GrGLPath*>(path);
|
||||
|
||||
this->flushPathStencilSettings(stencilSettings);
|
||||
this->flushPathStencilSettings(*args.fStencil);
|
||||
SkASSERT(!fHWPathStencilSettings.isTwoSided());
|
||||
|
||||
GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
|
||||
@ -171,10 +183,13 @@ void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings&
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& stencilSettings) {
|
||||
void GrGLPathRendering::onDrawPath(const DrawPathArgs& args, const GrPath* path) {
|
||||
if (!this->gpu()->flushGLState(args)) {
|
||||
return;
|
||||
}
|
||||
const GrGLPath* glPath = static_cast<const GrGLPath*>(path);
|
||||
|
||||
this->flushPathStencilSettings(stencilSettings);
|
||||
this->flushPathStencilSettings(*args.fStencil);
|
||||
SkASSERT(!fHWPathStencilSettings.isTwoSided());
|
||||
|
||||
GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
|
||||
@ -191,17 +206,19 @@ void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& st
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLPathRendering::drawPaths(const GrPathRange* pathRange,
|
||||
const void* indices, PathIndexType indexType,
|
||||
const float transformValues[], PathTransformType transformType,
|
||||
int count, const GrStencilSettings& stencilSettings) {
|
||||
SkASSERT(fGpu->caps()->shaderCaps()->pathRenderingSupport());
|
||||
void GrGLPathRendering::onDrawPaths(const DrawPathArgs& args, const GrPathRange* pathRange,
|
||||
const void* indices, PathIndexType indexType,
|
||||
const float transformValues[], PathTransformType transformType,
|
||||
int count) {
|
||||
if (!this->gpu()->flushGLState(args)) {
|
||||
return;
|
||||
}
|
||||
this->flushPathStencilSettings(*args.fStencil);
|
||||
SkASSERT(!fHWPathStencilSettings.isTwoSided());
|
||||
|
||||
|
||||
const GrGLPathRange* glPathRange = static_cast<const GrGLPathRange*>(pathRange);
|
||||
|
||||
this->flushPathStencilSettings(stencilSettings);
|
||||
SkASSERT(!fHWPathStencilSettings.isTwoSided());
|
||||
|
||||
GrGLenum fillMode =
|
||||
gr_stencil_op_to_gl_path_rendering_fill_mode(
|
||||
fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
|
||||
@ -257,7 +274,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix,
|
||||
const SkISize& renderTargetSize,
|
||||
GrSurfaceOrigin renderTargetOrigin) {
|
||||
|
||||
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
|
||||
SkASSERT(this->gpu()->glCaps().shaderCaps()->pathRenderingSupport());
|
||||
|
||||
if (renderTargetOrigin == fHWProjectionMatrixState.fRenderTargetOrigin &&
|
||||
renderTargetSize == fHWProjectionMatrixState.fRenderTargetSize &&
|
||||
@ -389,3 +406,7 @@ inline void GrGLPathRendering::stencilThenCoverStrokePathInstanced(
|
||||
GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
|
||||
coverMode, transformType, transformValues));
|
||||
}
|
||||
|
||||
inline GrGLGpu* GrGLPathRendering::gpu() {
|
||||
return static_cast<GrGLGpu*>(fGpu);
|
||||
}
|
||||
|
@ -39,11 +39,6 @@ public:
|
||||
virtual GrPathRange* createGlyphs(const SkTypeface*,
|
||||
const SkDescriptor*,
|
||||
const GrStrokeInfo&) override;
|
||||
void stencilPath(const GrPath*, const GrStencilSettings&) override;
|
||||
void drawPath(const GrPath*, const GrStencilSettings&) override;
|
||||
virtual void drawPaths(const GrPathRange*, const void* indices, PathIndexType,
|
||||
const float transformValues[], PathTransformType, int count,
|
||||
const GrStencilSettings&) override;
|
||||
|
||||
/* Called when the 3D context state is unknown. */
|
||||
void resetContext();
|
||||
@ -67,6 +62,11 @@ public:
|
||||
GrGLuint genPaths(GrGLsizei range);
|
||||
GrGLvoid deletePaths(GrGLuint path, GrGLsizei range);
|
||||
|
||||
protected:
|
||||
void onStencilPath(const StencilPathArgs&, const GrPath*) override;
|
||||
void onDrawPath(const DrawPathArgs&, const GrPath*) override;
|
||||
void onDrawPaths(const DrawPathArgs&, const GrPathRange*, const void* indices, PathIndexType,
|
||||
const float transformValues[], PathTransformType, int count) override;
|
||||
private:
|
||||
/**
|
||||
* Mark certain functionality as not supported if the driver version is too
|
||||
@ -129,8 +129,8 @@ private:
|
||||
GrGLGetMatrix<Size>(destMatrix, combined);
|
||||
}
|
||||
};
|
||||
GrGLGpu* gpu();
|
||||
|
||||
GrGLGpu* fGpu;
|
||||
SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator;
|
||||
Caps fCaps;
|
||||
MatrixState fHWProjectionMatrixState;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "GrGLShaderVar.h"
|
||||
#include "GrGLSL.h"
|
||||
#include "GrGLXferProcessor.h"
|
||||
#include "GrPathProcessor.h"
|
||||
#include "GrPipeline.h"
|
||||
#include "GrXferProcessor.h"
|
||||
#include "SkXfermode.h"
|
||||
|
Loading…
Reference in New Issue
Block a user