Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: src/gpu/vk/GrVkStencilAttachment.cpp

Issue 1735283004: Make GrVkStencilAttachment derive form GrVkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkStencilAttachment.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkStencilAttachment.h" 8 #include "GrVkStencilAttachment.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 #include "GrVkImage.h" 10 #include "GrVkImage.h"
11 #include "GrVkImageView.h" 11 #include "GrVkImageView.h"
12 #include "GrVkUtil.h" 12 #include "GrVkUtil.h"
13 13
14 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 14 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
15 15
16 GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu, 16 GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu,
17 GrGpuResource::LifeCycle lifeCycle, 17 GrGpuResource::LifeCycle lifeCycle,
18 const Format& format, 18 const Format& format,
19 const GrVkImage::ImageDesc& desc, 19 const GrVkImage::ImageDesc& desc,
20 const GrVkImage::Resource* imageRes ource, 20 const GrVkImage::Resource* imageRes ource,
21 const GrVkImageView* stencilView) 21 const GrVkImageView* stencilView)
22 : INHERITED(gpu, lifeCycle, desc.fWidth, desc.fHeight, format.fStencilBits, desc.fSamples) 22 : GrStencilAttachment(gpu, lifeCycle, desc.fWidth, desc.fHeight,
23 format.fStencilBits, desc.fSamples)
24 , GrVkImage(imageResource)
23 , fFormat(format) 25 , fFormat(format)
24 , fImageResource(imageResource)
25 , fStencilView(stencilView) { 26 , fStencilView(stencilView) {
26 this->registerWithCache(); 27 this->registerWithCache();
27 imageResource->ref();
28 stencilView->ref(); 28 stencilView->ref();
29 } 29 }
30 30
31 GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu, 31 GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu,
32 GrGpuResource::LifeCycle li feCycle, 32 GrGpuResource::LifeCycle li feCycle,
33 int width, 33 int width,
34 int height, 34 int height,
35 int sampleCnt, 35 int sampleCnt,
36 const Format& format) { 36 const Format& format) {
37 GrVkImage::ImageDesc imageDesc; 37 GrVkImage::ImageDesc imageDesc;
(...skipping 23 matching lines...) Expand all
61 GrVkStencilAttachment* stencil = new GrVkStencilAttachment(gpu, lifeCycle, f ormat, imageDesc, 61 GrVkStencilAttachment* stencil = new GrVkStencilAttachment(gpu, lifeCycle, f ormat, imageDesc,
62 imageResource, im ageView); 62 imageResource, im ageView);
63 imageResource->unref(gpu); 63 imageResource->unref(gpu);
64 imageView->unref(gpu); 64 imageView->unref(gpu);
65 65
66 return stencil; 66 return stencil;
67 } 67 }
68 68
69 GrVkStencilAttachment::~GrVkStencilAttachment() { 69 GrVkStencilAttachment::~GrVkStencilAttachment() {
70 // should have been released or abandoned first 70 // should have been released or abandoned first
71 SkASSERT(!fImageResource);
72 SkASSERT(!fStencilView); 71 SkASSERT(!fStencilView);
73 } 72 }
74 73
75 size_t GrVkStencilAttachment::onGpuMemorySize() const { 74 size_t GrVkStencilAttachment::onGpuMemorySize() const {
76 uint64_t size = this->width(); 75 uint64_t size = this->width();
77 size *= this->height(); 76 size *= this->height();
78 size *= fFormat.fTotalBits; 77 size *= fFormat.fTotalBits;
79 size *= SkTMax(1,this->numSamples()); 78 size *= SkTMax(1,this->numSamples());
80 return static_cast<size_t>(size / 8); 79 return static_cast<size_t>(size / 8);
81 } 80 }
82 81
83 void GrVkStencilAttachment::onRelease() { 82 void GrVkStencilAttachment::onRelease() {
84 GrVkGpu* gpu = this->getVkGpu(); 83 GrVkGpu* gpu = this->getVkGpu();
85 84
86 fImageResource->unref(gpu); 85 this->releaseImage(gpu);
87 fImageResource = nullptr;
88 86
89 fStencilView->unref(gpu); 87 fStencilView->unref(gpu);
90 fStencilView = nullptr; 88 fStencilView = nullptr;
91 INHERITED::onRelease(); 89 GrStencilAttachment::onRelease();
92 } 90 }
93 91
94 void GrVkStencilAttachment::onAbandon() { 92 void GrVkStencilAttachment::onAbandon() {
95 fImageResource->unrefAndAbandon(); 93 this->abandonImage();
96 fImageResource = nullptr;
97 fStencilView->unrefAndAbandon(); 94 fStencilView->unrefAndAbandon();
98 fStencilView = nullptr; 95 fStencilView = nullptr;
99 INHERITED::onAbandon(); 96 GrStencilAttachment::onAbandon();
100 } 97 }
101 98
102 GrVkGpu* GrVkStencilAttachment::getVkGpu() const { 99 GrVkGpu* GrVkStencilAttachment::getVkGpu() const {
103 SkASSERT(!this->wasDestroyed()); 100 SkASSERT(!this->wasDestroyed());
104 return static_cast<GrVkGpu*>(this->getGpu()); 101 return static_cast<GrVkGpu*>(this->getGpu());
105 } 102 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkStencilAttachment.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698