aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBackendSurface.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-04-10 13:46:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-11 11:14:58 +0000
commit323fbcf6d18f1a82b76cc3e471015dc9717e7fb5 (patch)
tree6542aa1caf6b2f7e0a473cbf0b42ed397b2722d4 /src/gpu/GrBackendSurface.cpp
parent3b6afd51b22c14fdfd5e741b809c5e02c6ec2095 (diff)
Move GrBackendRenderTarget over to new system of getting backed infos
Bug: skia: Change-Id: I3927390894715e8424b3d0240dad3ee6cd03dc38 Reviewed-on: https://skia-review.googlesource.com/120181 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrBackendSurface.cpp')
-rw-r--r--src/gpu/GrBackendSurface.cpp100
1 files changed, 88 insertions, 12 deletions
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 36c26e9cdb..eb7aea2020 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -301,6 +301,14 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
int sampleCnt,
const GrVkImageInfo& vkInfo)
+ : GrBackendRenderTarget(width, height, sampleCnt, vkInfo,
+ sk_sp<GrVkImageLayout>(new GrVkImageLayout(vkInfo.fImageLayout))) {}
+
+GrBackendRenderTarget::GrBackendRenderTarget(int width,
+ int height,
+ int sampleCnt,
+ const GrVkImageInfo& vkInfo,
+ sk_sp<GrVkImageLayout> layout)
: fIsValid(true)
, fWidth(width)
, fHeight(height)
@@ -308,7 +316,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
, fStencilBits(0) // We always create stencil buffers internally for vulkan
, fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fBackend(kVulkan_GrBackend)
- , fVkInfo(vkInfo) {}
+ , fVkInfo(vkInfo, layout.release()) {}
#endif
#if GR_TEST_UTILS
@@ -356,28 +364,96 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
, fConfig(mockInfo.fConfig)
, fMockInfo(mockInfo) {}
+GrBackendRenderTarget::~GrBackendRenderTarget() {
+ this->cleanup();
+}
+
+void GrBackendRenderTarget::cleanup() {
#ifdef SK_VULKAN
-const GrVkImageInfo* GrBackendRenderTarget::getVkImageInfo() const {
- if (kVulkan_GrBackend == fBackend) {
- return &fVkInfo;
+ if (this->isValid() && kVulkan_GrBackend == fBackend) {
+ fVkInfo.cleanup();
}
- return nullptr;
+#endif
}
+
+GrBackendRenderTarget::GrBackendRenderTarget(const GrBackendRenderTarget& that) : fIsValid(false) {
+ *this = that;
+}
+
+GrBackendRenderTarget& GrBackendRenderTarget::operator=(const GrBackendRenderTarget& that) {
+ if (!that.isValid()) {
+ this->cleanup();
+ fIsValid = false;
+ return *this;
+ }
+ fWidth = that.fWidth;
+ fHeight = that.fHeight;
+ fSampleCnt = that.fSampleCnt;
+ fStencilBits = that.fStencilBits;
+ fConfig = that.fConfig;
+ fBackend = that.fBackend;
+
+ switch (that.fBackend) {
+ case kOpenGL_GrBackend:
+ fGLInfo = that.fGLInfo;
+ break;
+#ifdef SK_VULKAN
+ case kVulkan_GrBackend:
+ fVkInfo.assign(that.fVkInfo, this->isValid());
+ break;
+#endif
+#ifdef SK_METAL
+ case kMetal_GrBackend:
+ break;
#endif
+ case kMock_GrBackend:
+ fMockInfo = that.fMockInfo;
+ break;
+ default:
+ SK_ABORT("Unknown GrBackend");
+ }
+ fIsValid = that.fIsValid;
+ return *this;
+}
-const GrGLFramebufferInfo* GrBackendRenderTarget::getGLFramebufferInfo() const {
- if (kOpenGL_GrBackend == fBackend) {
- return &fGLInfo;
+#ifdef SK_VULKAN
+bool GrBackendRenderTarget::getVkImageInfo(GrVkImageInfo* outInfo) const {
+ if (this->isValid() && kVulkan_GrBackend == fBackend) {
+ *outInfo = fVkInfo.snapImageInfo();
+ return true;
}
- return nullptr;
+ return false;
}
-const GrMockRenderTargetInfo* GrBackendRenderTarget::getMockRenderTargetInfo() const {
- if (kMock_GrBackend == fBackend) {
- return &fMockInfo;
+void GrBackendRenderTarget::setVkImageLayout(VkImageLayout layout) {
+ if (this->isValid() && kVulkan_GrBackend == fBackend) {
+ fVkInfo.setImageLayout(layout);
+ }
+}
+
+sk_sp<GrVkImageLayout> GrBackendRenderTarget::getGrVkImageLayout() const {
+ if (this->isValid() && kVulkan_GrBackend == fBackend) {
+ return fVkInfo.getGrVkImageLayout();
}
return nullptr;
}
+#endif
+
+bool GrBackendRenderTarget::getGLFramebufferInfo(GrGLFramebufferInfo* outInfo) const {
+ if (this->isValid() && kOpenGL_GrBackend == fBackend) {
+ *outInfo = fGLInfo;
+ return true;
+ }
+ return false;
+}
+
+bool GrBackendRenderTarget::getMockRenderTargetInfo(GrMockRenderTargetInfo* outInfo) const {
+ if (this->isValid() && kMock_GrBackend == fBackend) {
+ *outInfo = fMockInfo;
+ return true;
+ }
+ return false;
+}
#if GR_TEST_UTILS
bool GrBackendRenderTarget::TestingOnly_Equals(const GrBackendRenderTarget& r0,