зеркало из https://github.com/mozilla/moz-skia.git
Put drawPath in GrBatch.
TODO: Implement path range version of this (and preserve combining consecutive ranges). Review URL: https://codereview.chromium.org/1301823002
This commit is contained in:
Родитель
f7d602a458
Коммит
add79ef7cb
|
@ -235,6 +235,7 @@
|
|||
'<(skia_src_path)/gpu/batches/GrDrawBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrDrawAtlasBatch.cpp',
|
||||
'<(skia_src_path)/gpu/batches/GrDrawAtlasBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrDrawPathBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrDrawVerticesBatch.cpp',
|
||||
'<(skia_src_path)/gpu/batches/GrDrawVerticesBatch.h',
|
||||
'<(skia_src_path)/gpu/batches/GrRectBatchFactory.h',
|
||||
|
|
|
@ -30,18 +30,6 @@ void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) {
|
|||
fCommands->recordDrawBatch(batch, *this->caps());
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::onDrawPath(const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
const GrStencilSettings& stencilSettings,
|
||||
const PipelineInfo& pipelineInfo) {
|
||||
GrPipelineOptimizations opts;
|
||||
StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInfo, &opts);
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
fCommands->recordDrawPath(state, pathProc, path, stencilSettings);
|
||||
}
|
||||
|
||||
void GrBufferedDrawTarget::onDrawPaths(const GrPathProcessor* pathProc,
|
||||
const GrPathRange* pathRange,
|
||||
const void* indices,
|
||||
|
|
|
@ -73,10 +73,6 @@ private:
|
|||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
const PipelineInfo&) override;
|
||||
void onDrawPaths(const GrPathProcessor*,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
|
|
|
@ -27,10 +27,6 @@ public:
|
|||
void flush(GrGpu* gpu, GrResourceProvider* rp) { fCommands.flush(gpu, rp); }
|
||||
|
||||
virtual Cmd* recordDrawBatch(GrBatch*, const GrCaps&) = 0;
|
||||
virtual Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&) = 0;
|
||||
virtual Cmd* recordDrawPaths(State*,
|
||||
GrBufferedDrawTarget*,
|
||||
const GrPathProcessor*,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "batches/GrCopySurfaceBatch.h"
|
||||
#include "batches/GrDiscardBatch.h"
|
||||
#include "batches/GrDrawBatch.h"
|
||||
#include "batches/GrDrawPathBatch.h"
|
||||
#include "batches/GrRectBatchFactory.h"
|
||||
#include "batches/GrStencilPathBatch.h"
|
||||
|
||||
|
@ -130,8 +131,6 @@ void GrDrawTarget::flush() {
|
|||
}
|
||||
|
||||
void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch) {
|
||||
// TODO some kind of checkdraw, but not at this level
|
||||
|
||||
// Setup clip
|
||||
GrScissorState scissorState;
|
||||
GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
|
||||
|
@ -147,6 +146,7 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
|
|||
|
||||
GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, batch, &bounds,
|
||||
this);
|
||||
|
||||
if (!pipelineInfo.valid()) {
|
||||
return;
|
||||
}
|
||||
|
@ -226,34 +226,44 @@ void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder,
|
|||
const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
GrPathRendering::FillType fill) {
|
||||
// TODO: extract portions of checkDraw that are relevant to path rendering.
|
||||
SkASSERT(path);
|
||||
SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
|
||||
|
||||
SkRect devBounds = path->getBounds();
|
||||
pathProc->viewMatrix().mapRect(&devBounds);
|
||||
GrDrawPathBatch* batch = GrDrawPathBatch::Create(pathProc, path);
|
||||
|
||||
// This looks like drawBatch() but there is an added wrinkle that stencil settings get inserted
|
||||
// after setupClip() but before onDrawBatch(). TODO: Figure out a better model for handling
|
||||
// stencil settings WRT interactions between pipeline(builder), clipmaskmanager, and batches.
|
||||
|
||||
// Setup clip
|
||||
GrScissorState scissorState;
|
||||
GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
|
||||
GrPipelineBuilder::AutoRestoreStencil ars;
|
||||
if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &devBounds)) {
|
||||
return;
|
||||
if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->bounds())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set stencil settings for path
|
||||
// Ensure the render target has a stencil buffer and get the stencil settings.
|
||||
GrStencilSettings stencilSettings;
|
||||
GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
|
||||
GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
|
||||
this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
|
||||
batch->setStencilSettings(stencilSettings);
|
||||
|
||||
// Don't compute a bounding box for dst copy texture, we'll opt
|
||||
// instead for it to just copy the entire dst. Realistically this is a moot
|
||||
// point, because any context that supports NV_path_rendering will also
|
||||
// support NV_blend_equation_advanced.
|
||||
GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, batch, NULL, this);
|
||||
|
||||
GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pathProc, &devBounds,
|
||||
this);
|
||||
if (!pipelineInfo.valid()) {
|
||||
return;
|
||||
}
|
||||
if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
|
||||
this->onDrawBatch(batch);
|
||||
batch->unref();
|
||||
}
|
||||
|
||||
void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
|
||||
|
|
|
@ -243,10 +243,6 @@ private:
|
|||
|
||||
virtual void onFlush() = 0;
|
||||
|
||||
virtual void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
const PipelineInfo&) = 0;
|
||||
virtual void onDrawPaths(const GrPathProcessor*,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
|
|
|
@ -33,12 +33,6 @@ private:
|
|||
void onReset() override;
|
||||
void onFlush() override;
|
||||
|
||||
void onDrawPath(const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&,
|
||||
const PipelineInfo&) override {
|
||||
SkFAIL("Only batch implemented\n");
|
||||
}
|
||||
void onDrawPaths(const GrPathProcessor*,
|
||||
const GrPathRange*,
|
||||
const void* indices,
|
||||
|
|
|
@ -41,16 +41,6 @@ GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(GrBatch* batch,
|
|||
return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch));
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd*
|
||||
GrInOrderCommandBuilder::recordDrawPath(State* state,
|
||||
const GrPathProcessor* pathProc,
|
||||
const GrPath* path,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPath, (state, path));
|
||||
dp->fStencilSettings = stencilSettings;
|
||||
return dp;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd*
|
||||
GrInOrderCommandBuilder::recordDrawPaths(State* state,
|
||||
GrBufferedDrawTarget* bufferedDrawTarget,
|
||||
|
|
|
@ -18,10 +18,6 @@ public:
|
|||
GrInOrderCommandBuilder() : INHERITED() { }
|
||||
|
||||
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
|
||||
Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&) override;
|
||||
Cmd* recordDrawPaths(State*,
|
||||
GrBufferedDrawTarget*,
|
||||
const GrPathProcessor*,
|
||||
|
|
|
@ -19,14 +19,6 @@ public:
|
|||
|
||||
Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override;
|
||||
|
||||
Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&) override {
|
||||
SkFAIL("Unsupported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Cmd* recordDrawPaths(State*,
|
||||
GrBufferedDrawTarget*,
|
||||
const GrPathProcessor*,
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrDrawPathBatch_DEFINED
|
||||
#define GrDrawPathBatch_DEFINED
|
||||
|
||||
#include "GrDrawBatch.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrPath.h"
|
||||
#include "GrPathRendering.h"
|
||||
#include "GrPathProcessor.h"
|
||||
|
||||
class GrDrawPathBatch final : public GrDrawBatch {
|
||||
public:
|
||||
// This must return the concrete type because we install the stencil settings late :(
|
||||
static GrDrawPathBatch* Create(const GrPathProcessor* primProc, const GrPath* path) {
|
||||
return SkNEW_ARGS(GrDrawPathBatch, (primProc, path));
|
||||
}
|
||||
|
||||
const char* name() const override { return "DrawPath"; }
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.printf("PATH: 0x%p", fPath.get());
|
||||
return string;
|
||||
}
|
||||
|
||||
virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const {
|
||||
fPrimitiveProcessor->getInvariantOutputColor(out);
|
||||
}
|
||||
|
||||
virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const {
|
||||
fPrimitiveProcessor->getInvariantOutputCoverage(out);
|
||||
}
|
||||
|
||||
void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings = stencil; }
|
||||
|
||||
private:
|
||||
GrBatchTracker* tracker() { return reinterpret_cast<GrBatchTracker*>(&fWhatchamacallit); }
|
||||
GrDrawPathBatch(const GrPathProcessor* primProc, const GrPath* path)
|
||||
: fPrimitiveProcessor(primProc)
|
||||
, fPath(path) {
|
||||
fBounds = path->getBounds();
|
||||
primProc->viewMatrix().mapRect(&fBounds);
|
||||
this->initClassID<GrDrawPathBatch>();
|
||||
}
|
||||
|
||||
virtual void initBatchTracker(const GrPipelineOptimizations& opts) {
|
||||
fPrimitiveProcessor->initBatchTracker(this->tracker(), opts);
|
||||
}
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
|
||||
|
||||
void onPrepare(GrBatchFlushState*) override {}
|
||||
|
||||
void onDraw(GrBatchFlushState* state) override {
|
||||
GrProgramDesc desc;
|
||||
state->gpu()->buildProgramDesc(&desc, *fPrimitiveProcessor.get(),
|
||||
*this->pipeline(), *this->tracker());
|
||||
GrPathRendering::DrawPathArgs args(fPrimitiveProcessor.get(), this->pipeline(),
|
||||
&desc, this->tracker(), &fStencilSettings);
|
||||
state->gpu()->pathRendering()->drawPath(args, fPath.get());
|
||||
}
|
||||
|
||||
GrPendingProgramElement<const GrPathProcessor> fPrimitiveProcessor;
|
||||
PathBatchTracker fWhatchamacallit; // TODO: delete this
|
||||
GrStencilSettings fStencilSettings;
|
||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче