зеркало из https://github.com/mozilla/moz-skia.git
Remove unnecessary dirty clip flag in GrGpu, remove getUsableStencilBits()
Review URL: http://codereview.appspot.com/4828050/ git-svn-id: http://skia.googlecode.com/svn/trunk@2011 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
896d79da53
Коммит
dea2f8d863
|
@ -99,23 +99,6 @@ public:
|
|||
kCW_DrawFace,
|
||||
};
|
||||
|
||||
/**
|
||||
* The DrawTarget may reserve some of the high bits of the stencil. The draw
|
||||
* target will automatically trim reference and mask values so that the
|
||||
* client doesn't overwrite these bits.
|
||||
* The number of bits available is relative to the currently set render
|
||||
*target.
|
||||
* @return the number of bits usable by the draw target client.
|
||||
*/
|
||||
int getUsableStencilBits() const {
|
||||
int bits = fCurrDrawState.fRenderTarget->stencilBits();
|
||||
if (bits) {
|
||||
return bits - 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil settings to use for the next draw.
|
||||
* Changing the clip has the side-effect of possibly zeroing
|
||||
|
@ -1234,9 +1217,9 @@ protected:
|
|||
virtual void onDrawNonIndexed(GrPrimitiveType type,
|
||||
int startVertex,
|
||||
int vertexCount) = 0;
|
||||
// subclass overrides to be notified when clip is set.
|
||||
virtual void clipWillBeSet(const GrClip& clip) = 0;
|
||||
|
||||
// subclass overrides to be notified when clip is set. Must call
|
||||
// INHERITED::clipwillBeSet
|
||||
virtual void clipWillBeSet(const GrClip& clip);
|
||||
|
||||
// Helpers for drawRect, protected so subclasses that override drawRect
|
||||
// can use them.
|
||||
|
|
|
@ -344,16 +344,9 @@ protected:
|
|||
// clipping.
|
||||
};
|
||||
|
||||
/**
|
||||
* Extensions to GrDrawTarget::StateBits to implement stencil clipping
|
||||
*/
|
||||
struct ClipState {
|
||||
bool fClipInStencil;
|
||||
bool fClipIsDirty;
|
||||
} fClipState;
|
||||
|
||||
// GrDrawTarget override
|
||||
virtual void clipWillBeSet(const GrClip& newClip);
|
||||
// keep track of whether we are using stencil clipping (as opposed to
|
||||
// scissor).
|
||||
bool fClipInStencil;
|
||||
|
||||
// prepares clip flushes gpu state before a draw
|
||||
bool setupClipAndFlushState(GrPrimitiveType type);
|
||||
|
|
|
@ -16,17 +16,15 @@
|
|||
* GrDrawTarget class. The GrDrawTarget makes a subset of the stencil buffer
|
||||
* bits available for other uses by external code (clients). Client code can
|
||||
* modify these bits. GrDrawTarget will ignore ref, mask, and writemask bits
|
||||
* provided by clients that overlap the bits used to implement clipping. The
|
||||
* client can use the getUsableStencilBits() function to find out how many
|
||||
* client accessible stencil bits are available.
|
||||
* provided by clients that overlap the bits used to implement clipping.
|
||||
*
|
||||
* When code outside the GrDrawTarget class uses the stencil buffer the contract
|
||||
* is as follows:
|
||||
*
|
||||
* > Normal stencil funcs allow the GrGpu client to modify the client bits of
|
||||
* the stencil buffer outside of the clip.
|
||||
* > Special functions allow a test against the clip. These are more limited
|
||||
* than the general stencil functions.
|
||||
* > Normal stencil funcs allow the client to pass / fail regardless of the
|
||||
* reserved clip bits.
|
||||
* > Additional functions allow a test against the clip along with a limited
|
||||
* set of tests against the client bits.
|
||||
* > Client can assume all client bits are zero initially.
|
||||
* > Client must ensure that after all its passes are finished it has only
|
||||
* written to the color buffer in the region inside the clip. Furthermore, it
|
||||
|
|
|
@ -792,6 +792,10 @@ GrVertexLayout GrDrawTarget::GetRectVertexLayout(StageBitfield stageEnableBitfie
|
|||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
void GrDrawTarget::clipWillBeSet(const GrClip& clip) {
|
||||
}
|
||||
|
||||
void GrDrawTarget::SetRectVertices(const GrRect& rect,
|
||||
const GrMatrix* matrix,
|
||||
const GrRect* srcRects[],
|
||||
|
|
|
@ -257,14 +257,6 @@ const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrGpu::clipWillBeSet(const GrClip& newClip) {
|
||||
if (newClip != fClip) {
|
||||
fClipState.fClipIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// stencil settings to use when clip is in stencil
|
||||
const GrStencilSettings GrGpu::gClipStencilSettings = {
|
||||
kKeep_StencilOp, kKeep_StencilOp,
|
||||
|
@ -402,13 +394,12 @@ bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) {
|
|||
}
|
||||
r = &clipRect;
|
||||
|
||||
fClipState.fClipInStencil = !fClip.isRect() &&
|
||||
!fClip.isEmpty() &&
|
||||
!bounds.isEmpty();
|
||||
// use the stencil clip if we can't represent the clip as a rectangle.
|
||||
fClipInStencil = !fClip.isRect() && !fClip.isEmpty() &&
|
||||
!bounds.isEmpty();
|
||||
|
||||
if (fClipState.fClipInStencil &&
|
||||
(fClipState.fClipIsDirty ||
|
||||
fClip != rt.fLastStencilClip)) {
|
||||
if (fClipInStencil &&
|
||||
fClip != rt.fLastStencilClip) {
|
||||
|
||||
rt.fLastStencilClip = fClip;
|
||||
// we set the current clip to the bounds so that our recursive
|
||||
|
@ -533,12 +524,12 @@ bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// restore clip
|
||||
fClip = clip;
|
||||
// recusive draws would have disabled this.
|
||||
fClipState.fClipInStencil = true;
|
||||
// recusive draws would have disabled this since they drew with
|
||||
// the clip bounds as clip.
|
||||
fClipInStencil = true;
|
||||
}
|
||||
|
||||
fClipState.fClipIsDirty = false;
|
||||
}
|
||||
|
||||
// Must flush the scissor after graphics state
|
||||
|
|
|
@ -578,8 +578,7 @@ void GrGpuGL::resetContext() {
|
|||
|
||||
fHWDrawState.fStencilSettings.invalidate();
|
||||
fHWStencilClip = false;
|
||||
fClipState.fClipIsDirty = true;
|
||||
fClipState.fClipInStencil = false;
|
||||
fClipInStencil = false;
|
||||
|
||||
fHWGeometryState.fIndexBuffer = NULL;
|
||||
fHWGeometryState.fVertexBuffer = NULL;
|
||||
|
@ -1761,7 +1760,7 @@ void GrGpuGL::flushStencil() {
|
|||
|
||||
// use stencil for clipping if clipping is enabled and the clip
|
||||
// has been written into the stencil.
|
||||
bool stencilClip = fClipState.fClipInStencil &&
|
||||
bool stencilClip = fClipInStencil &&
|
||||
(kClip_StateBit & fCurrDrawState.fFlagBits);
|
||||
bool stencilChange = fHWStencilClip != stencilClip ||
|
||||
fHWDrawState.fStencilSettings != *settings ||
|
||||
|
|
|
@ -612,6 +612,7 @@ void GrInOrderDrawBuffer::pushClip() {
|
|||
fClipSet = false;
|
||||
}
|
||||
|
||||
void GrInOrderDrawBuffer::clipWillBeSet(const GrClip& newClip) {
|
||||
void GrInOrderDrawBuffer::clipWillBeSet(const GrClip& newClip) {
|
||||
INHERITED::clipWillBeSet(newClip);
|
||||
fClipSet = true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче