Make GrVkStencilAttachment derive form GrVkImage

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1735283004

Review URL: https://codereview.chromium.org/1735283004
This commit is contained in:
egdaniel 2016-02-26 13:12:00 -08:00 committed by Commit bot
parent d524f16b98
commit e015c2646f
2 changed files with 9 additions and 15 deletions

View File

@ -19,12 +19,12 @@ GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu,
const GrVkImage::ImageDesc& desc,
const GrVkImage::Resource* imageResource,
const GrVkImageView* stencilView)
: INHERITED(gpu, lifeCycle, desc.fWidth, desc.fHeight, format.fStencilBits, desc.fSamples)
: GrStencilAttachment(gpu, lifeCycle, desc.fWidth, desc.fHeight,
format.fStencilBits, desc.fSamples)
, GrVkImage(imageResource)
, fFormat(format)
, fImageResource(imageResource)
, fStencilView(stencilView) {
this->registerWithCache();
imageResource->ref();
stencilView->ref();
}
@ -68,7 +68,6 @@ GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu,
GrVkStencilAttachment::~GrVkStencilAttachment() {
// should have been released or abandoned first
SkASSERT(!fImageResource);
SkASSERT(!fStencilView);
}
@ -83,20 +82,18 @@ size_t GrVkStencilAttachment::onGpuMemorySize() const {
void GrVkStencilAttachment::onRelease() {
GrVkGpu* gpu = this->getVkGpu();
fImageResource->unref(gpu);
fImageResource = nullptr;
this->releaseImage(gpu);
fStencilView->unref(gpu);
fStencilView = nullptr;
INHERITED::onRelease();
GrStencilAttachment::onRelease();
}
void GrVkStencilAttachment::onAbandon() {
fImageResource->unrefAndAbandon();
fImageResource = nullptr;
this->abandonImage();
fStencilView->unrefAndAbandon();
fStencilView = nullptr;
INHERITED::onAbandon();
GrStencilAttachment::onAbandon();
}
GrVkGpu* GrVkStencilAttachment::getVkGpu() const {

View File

@ -15,7 +15,7 @@
class GrVkImageView;
class GrVkGpu;
class GrVkStencilAttachment : public GrStencilAttachment {
class GrVkStencilAttachment : public GrStencilAttachment, public GrVkImage {
public:
struct Format {
VkFormat fInternalFormat;
@ -30,7 +30,7 @@ public:
~GrVkStencilAttachment() override;
const GrVkImage::Resource* imageResource() const { return fImageResource; }
const GrVkImage::Resource* imageResource() const { return this->resource(); }
const GrVkImageView* stencilView() const { return fStencilView; }
VkFormat vkFormat() const { return fFormat.fInternalFormat; }
@ -53,10 +53,7 @@ private:
Format fFormat;
const GrVkImage::Resource* fImageResource;
const GrVkImageView* fStencilView;
typedef GrStencilAttachment INHERITED;
};
#endif