Remove AutoScratchTexture
Remove AST from GrClipMaskCache Remove AST from GrClipMaskManager BUG=skia:2889 R=robertphillips@google.com Review URL: https://codereview.chromium.org/663583002
This commit is contained in:
parent
b227e37eae
commit
427cf28861
@ -19,7 +19,6 @@
|
||||
#include "SkTypes.h"
|
||||
|
||||
class GrAARectRenderer;
|
||||
class GrAutoScratchTexture;
|
||||
class GrDrawState;
|
||||
class GrDrawTarget;
|
||||
class GrFontCache;
|
||||
@ -1049,65 +1048,4 @@ private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is deprecated. Don't use it.
|
||||
*/
|
||||
class SK_API GrAutoScratchTexture : public ::SkNoncopyable {
|
||||
public:
|
||||
GrAutoScratchTexture()
|
||||
: fContext(NULL)
|
||||
, fTexture(NULL) {
|
||||
}
|
||||
|
||||
GrAutoScratchTexture(GrContext* context,
|
||||
const GrTextureDesc& desc,
|
||||
GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch,
|
||||
bool internalFlag = false)
|
||||
: fContext(NULL)
|
||||
, fTexture(NULL) {
|
||||
this->set(context, desc, match, internalFlag);
|
||||
}
|
||||
|
||||
~GrAutoScratchTexture() {
|
||||
this->reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
if (fContext && fTexture) {
|
||||
fTexture->unref();
|
||||
fTexture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GrTexture* detach() {
|
||||
GrTexture* texture = fTexture;
|
||||
fTexture = NULL;
|
||||
return texture;
|
||||
}
|
||||
|
||||
GrTexture* set(GrContext* context,
|
||||
const GrTextureDesc& desc,
|
||||
GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch,
|
||||
bool internalFlag = 0) {
|
||||
this->reset();
|
||||
|
||||
fContext = context;
|
||||
if (fContext) {
|
||||
fTexture = fContext->refScratchTexture(desc, match, internalFlag);
|
||||
if (NULL == fTexture) {
|
||||
fContext = NULL;
|
||||
}
|
||||
return fTexture;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GrTexture* texture() { return fTexture; }
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
GrTexture* fTexture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
|
||||
// We could reuse the mask if bounds is a subset of last bounds. We'd have to communicate
|
||||
// an offset to the caller.
|
||||
if (back->fLastMask.texture() &&
|
||||
!back->fLastMask.texture()->wasDestroyed() &&
|
||||
if (back->fLastMask &&
|
||||
!back->fLastMask->wasDestroyed() &&
|
||||
back->fLastBound == bounds &&
|
||||
back->fLastClipGenID == clipGenID) {
|
||||
return true;
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
|
||||
|
||||
return back->fLastMask.texture();
|
||||
return back->fLastMask;
|
||||
}
|
||||
|
||||
const GrTexture* getLastMask() const {
|
||||
@ -110,7 +110,7 @@ public:
|
||||
|
||||
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
|
||||
|
||||
return back->fLastMask.texture();
|
||||
return back->fLastMask;
|
||||
}
|
||||
|
||||
void acquireMask(int32_t clipGenID,
|
||||
@ -136,11 +136,11 @@ public:
|
||||
|
||||
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
|
||||
|
||||
if (NULL == back->fLastMask.texture()) {
|
||||
if (NULL == back->fLastMask) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return back->fLastMask.texture()->width();
|
||||
return back->fLastMask->width();
|
||||
}
|
||||
|
||||
int getLastMaskHeight() const {
|
||||
@ -152,11 +152,11 @@ public:
|
||||
|
||||
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
|
||||
|
||||
if (NULL == back->fLastMask.texture()) {
|
||||
if (NULL == back->fLastMask) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return back->fLastMask.texture()->height();
|
||||
return back->fLastMask->height();
|
||||
}
|
||||
|
||||
void getLastBound(SkIRect* bound) const {
|
||||
@ -206,7 +206,8 @@ private:
|
||||
|
||||
// HACK: set the last param to true to indicate that this request is at
|
||||
// flush time and therefore we require a scratch texture with no pending IO operations.
|
||||
fLastMask.set(context, desc, GrContext::kApprox_ScratchTexMatch, /*flushing=*/true);
|
||||
fLastMask.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch,
|
||||
/*flushing=*/true));
|
||||
|
||||
fLastBound = bound;
|
||||
}
|
||||
@ -216,7 +217,7 @@ private:
|
||||
|
||||
GrTextureDesc desc;
|
||||
|
||||
fLastMask.set(NULL, desc);
|
||||
fLastMask.reset(NULL);
|
||||
fLastBound.setEmpty();
|
||||
}
|
||||
|
||||
@ -224,7 +225,7 @@ private:
|
||||
// The mask's width & height values are used by GrClipMaskManager to correctly scale the
|
||||
// texture coords for the geometry drawn with this mask. TODO: This should be a cache key
|
||||
// and not a hard ref to a texture.
|
||||
GrAutoScratchTexture fLastMask;
|
||||
SkAutoTUnref<GrTexture> fLastMask;
|
||||
// fLastBound stores the bounding box of the clip mask in clip-stack space. This rect is
|
||||
// used by GrClipMaskManager to position a rect and compute texture coords for the mask.
|
||||
SkIRect fLastBound;
|
||||
|
@ -485,21 +485,14 @@ void GrClipMaskManager::mergeMask(GrTexture* dstMask,
|
||||
fGpu->drawSimpleRect(SkRect::Make(dstBound));
|
||||
}
|
||||
|
||||
// get a texture to act as a temporary buffer for AA clip boolean operations
|
||||
// TODO: given the expense of createTexture we may want to just cache this too
|
||||
void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* temp) {
|
||||
if (temp->texture()) {
|
||||
// we've already allocated the temp texture
|
||||
return;
|
||||
}
|
||||
|
||||
GrTexture* GrClipMaskManager::createTempMask(int width, int height) {
|
||||
GrTextureDesc desc;
|
||||
desc.fFlags = kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit;
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
desc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
|
||||
temp->set(this->getContext(), desc);
|
||||
return fGpu->getContext()->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -593,7 +586,7 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
|
||||
GrDrawTarget::AutoClipRestore acr(fGpu, maskSpaceIBounds);
|
||||
drawState->enableState(GrDrawState::kClip_StateBit);
|
||||
|
||||
GrAutoScratchTexture temp;
|
||||
SkAutoTUnref<GrTexture> temp;
|
||||
// walk through each clip element and perform its set op
|
||||
for (ElementList::Iter iter = elements.headIter(); iter.get(); iter.next()) {
|
||||
const Element* element = iter.get();
|
||||
@ -619,12 +612,15 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
|
||||
elementBounds.roundOut(&maskSpaceElementIBounds);
|
||||
}
|
||||
|
||||
this->getTemp(maskSpaceIBounds.fRight, maskSpaceIBounds.fBottom, &temp);
|
||||
if (NULL == temp.texture()) {
|
||||
if (!temp) {
|
||||
temp.reset(this->createTempMask(maskSpaceIBounds.fRight,
|
||||
maskSpaceIBounds.fBottom));
|
||||
if (!temp) {
|
||||
fAACache.reset();
|
||||
return NULL;
|
||||
}
|
||||
dst = temp.texture();
|
||||
}
|
||||
dst = temp;
|
||||
// clear the temp target and set blend to replace
|
||||
fGpu->clear(&maskSpaceElementIBounds,
|
||||
invert ? 0xffffffff : 0x00000000,
|
||||
@ -658,7 +654,7 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
|
||||
// Now draw into the accumulator using the real operation and the temp buffer as a
|
||||
// texture
|
||||
this->mergeMask(result,
|
||||
temp.texture(),
|
||||
temp,
|
||||
op,
|
||||
maskSpaceIBounds,
|
||||
maskSpaceElementIBounds);
|
||||
|
@ -163,7 +163,7 @@ private:
|
||||
const SkIRect& dstBound,
|
||||
const SkIRect& srcBound);
|
||||
|
||||
void getTemp(int width, int height, GrAutoScratchTexture* temp);
|
||||
GrTexture* createTempMask(int width, int height);
|
||||
|
||||
void setupCache(const SkClipStack& clip,
|
||||
const SkIRect& bounds);
|
||||
|
Loading…
Reference in New Issue
Block a user