Initial CL to create Reorder command builder behind a flag
BUG=skia: Review URL: https://codereview.chromium.org/1129943004
This commit is contained in:
parent
fc00a7c501
commit
3b58d75170
@ -173,6 +173,8 @@
|
||||
'<(skia_src_path)/gpu/GrRenderTargetPriv.h',
|
||||
'<(skia_src_path)/gpu/GrReducedClip.cpp',
|
||||
'<(skia_src_path)/gpu/GrReducedClip.h',
|
||||
'<(skia_src_path)/gpu/GrReorderCommandBuilder.h',
|
||||
'<(skia_src_path)/gpu/GrReorderCommandBuilder.cpp',
|
||||
'<(skia_src_path)/gpu/GrResourceCache.cpp',
|
||||
'<(skia_src_path)/gpu/GrResourceCache.h',
|
||||
'<(skia_src_path)/gpu/GrResourceProvider.cpp',
|
||||
|
@ -7,6 +7,17 @@
|
||||
|
||||
#include "GrCommandBuilder.h"
|
||||
|
||||
#include "GrInOrderCommandBuilder.h"
|
||||
#include "GrReorderCommandBuilder.h"
|
||||
|
||||
GrCommandBuilder* GrCommandBuilder::Create(GrGpu* gpu, bool reorder) {
|
||||
if (reorder) {
|
||||
return SkNEW_ARGS(GrReorderCommandBuilder, (gpu));
|
||||
} else {
|
||||
return SkNEW_ARGS(GrInOrderCommandBuilder, (gpu));
|
||||
}
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrCommandBuilder::recordClear(const SkIRect* rect,
|
||||
GrColor color,
|
||||
bool canIgnoreRect,
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
typedef GrTargetCommands::Cmd Cmd;
|
||||
typedef GrTargetCommands::State State;
|
||||
|
||||
GrCommandBuilder(GrGpu* gpu) : fCommands(gpu) { }
|
||||
static GrCommandBuilder* Create(GrGpu* gpu, bool reorder);
|
||||
|
||||
virtual ~GrCommandBuilder() {}
|
||||
|
||||
@ -69,6 +69,8 @@ protected:
|
||||
typedef GrTargetCommands::CopySurface CopySurface;
|
||||
typedef GrTargetCommands::XferBarrier XferBarrier;
|
||||
|
||||
GrCommandBuilder(GrGpu* gpu) : fCommands(gpu) {}
|
||||
|
||||
GrTargetCommands::CmdBuffer* cmdBuffer() { return fCommands.cmdBuffer(); }
|
||||
GrBatchTarget* batchTarget() { return fCommands.batchTarget(); }
|
||||
|
||||
|
@ -224,6 +224,7 @@ public:
|
||||
protected:
|
||||
friend class GrCommandBuilder; // for PipelineInfo
|
||||
friend class GrInOrderCommandBuilder; // for PipelineInfo
|
||||
friend class GrReorderCommandBuilder; // for PipelineInfo
|
||||
friend class GrTargetCommands; // for PipelineInfo
|
||||
|
||||
GrContext* getContext() { return fContext; }
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context)
|
||||
: INHERITED(context)
|
||||
, fCommands(SkNEW_ARGS(GrInOrderCommandBuilder, (context->getGpu())))
|
||||
, fCommands(GrCommandBuilder::Create(context->getGpu(), false))
|
||||
, fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
|
||||
, fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
|
||||
, fPipelineBuffer(kPipelineBufferMinReserve)
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define GrInOrderDrawBuffer_DEFINED
|
||||
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrInOrderCommandBuilder.h"
|
||||
#include "GrCommandBuilder.h"
|
||||
#include "SkChunkAlloc.h"
|
||||
|
||||
/**
|
||||
|
46
src/gpu/GrReorderCommandBuilder.cpp
Normal file
46
src/gpu/GrReorderCommandBuilder.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GrReorderCommandBuilder.h"
|
||||
|
||||
static bool intersect(const SkRect& a, const SkRect& b) {
|
||||
SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
|
||||
b.fLeft <= b.fRight && b.fTop <= b.fBottom);
|
||||
return a.fLeft < b.fRight && b.fLeft < a.fRight &&
|
||||
a.fTop < b.fBottom && b.fTop < a.fBottom;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, GrBatch* batch) {
|
||||
// Check if there is a Batch Draw we can batch with by linearly searching back until we either
|
||||
// 1) check every draw
|
||||
// 2) intersect with something
|
||||
// 3) find a 'blocker'
|
||||
if (!this->cmdBuffer()->empty()) {
|
||||
GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
|
||||
|
||||
do {
|
||||
if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
|
||||
DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get());
|
||||
|
||||
if (previous->fState->getPipeline()->isEqual(*state->getPipeline()) &&
|
||||
previous->fBatch->combineIfPossible(batch)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (intersect(previous->fBatch->bounds(), batch->bounds())) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// TODO temporary until we can navigate the other types of commands
|
||||
break;
|
||||
}
|
||||
} while (reverseIter.previous());
|
||||
}
|
||||
|
||||
return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch,
|
||||
this->batchTarget()));
|
||||
}
|
58
src/gpu/GrReorderCommandBuilder.h
Normal file
58
src/gpu/GrReorderCommandBuilder.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 GrReorderCommandBuilder_DEFINED
|
||||
#define GrReorderCommandBuilder_DEFINED
|
||||
|
||||
#include "GrCommandBuilder.h"
|
||||
|
||||
class GrReorderCommandBuilder : public GrCommandBuilder {
|
||||
public:
|
||||
typedef GrCommandBuilder::Cmd Cmd;
|
||||
typedef GrCommandBuilder::State State;
|
||||
|
||||
GrReorderCommandBuilder(GrGpu* gpu) : INHERITED(gpu) {}
|
||||
|
||||
Cmd* recordDrawBatch(State*, GrBatch*) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrScissorState&,
|
||||
const GrStencilSettings&) override {
|
||||
SkFAIL("Unsupported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Cmd* recordDrawPath(State*,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
const GrStencilSettings&) override {
|
||||
SkFAIL("Unsupported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Cmd* recordDrawPaths(State*,
|
||||
GrInOrderDrawBuffer*,
|
||||
const GrPathProcessor*,
|
||||
const GrPathRange*,
|
||||
const void*,
|
||||
GrDrawTarget::PathIndexType,
|
||||
const float transformValues[],
|
||||
GrDrawTarget::PathTransformType ,
|
||||
int,
|
||||
const GrStencilSettings&,
|
||||
const GrDrawTarget::PipelineInfo&) override {
|
||||
SkFAIL("Unsupported\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GrCommandBuilder INHERITED;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -65,6 +65,7 @@ public:
|
||||
private:
|
||||
friend class GrCommandBuilder;
|
||||
friend class GrInOrderDrawBuffer; // This goes away when State becomes just a pipeline
|
||||
friend class GrReorderCommandBuilder;
|
||||
|
||||
typedef GrGpu::DrawArgs DrawArgs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user