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

Unified Diff: src/gpu/vk/GrVkTexture.cpp

Issue 1808263002: Implement Vulkan GrBackendObject for textures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tweaks 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkTexture.h ('k') | src/gpu/vk/GrVkTextureRenderTarget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkTexture.cpp
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 5c4c3bd6c757b72a272eb54d70659251ae57c921..a6a89df37a3340d86248bb149ee8fbb4f2971653 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -10,6 +10,8 @@
#include "GrVkImageView.h"
#include "GrVkUtil.h"
+#include "vk/GrVkTypes.h"
+
#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
@@ -75,12 +77,29 @@ GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, const GrSurfaceDesc& de
GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu, const GrSurfaceDesc& desc,
GrGpuResource::LifeCycle lifeCycle,
VkFormat format,
- const GrVkImage::Resource* imageResource) {
- SkASSERT(imageResource);
+ const GrVkTextureInfo* info) {
+ SkASSERT(info);
+ // Wrapped textures require both image and allocation (because they can be mapped)
+ SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc);
+
+ GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
+ ? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
+
+ const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage,
+ info->fAlloc,
+ flags);
+ if (!imageResource) {
+ return nullptr;
+ }
- // Note: we assume the caller will unref the imageResource
- // Create() will increment the refCount, and we'll unref when we're done with it
- return Create(gpu, desc, lifeCycle, format, imageResource);
+ GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource);
+ if (texture) {
+ texture->fCurrentLayout = info->fImageLayout;
+ }
+ // Create() will increment the refCount of the image resource if it succeeds
+ imageResource->unref(gpu);
+
+ return texture;
}
GrVkTexture::~GrVkTexture() {
« no previous file with comments | « src/gpu/vk/GrVkTexture.h ('k') | src/gpu/vk/GrVkTextureRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698