2017-04-18 19:52:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GrBackendSurface.h"
|
|
|
|
|
|
|
|
#ifdef SK_VULKAN
|
|
|
|
#include "vk/GrVkTypes.h"
|
|
|
|
#include "vk/GrVkUtil.h"
|
|
|
|
GrBackendTexture::GrBackendTexture(int width,
|
|
|
|
int height,
|
2017-04-19 00:23:39 +00:00
|
|
|
GrVkImageInfo* vkInfo)
|
2017-04-18 19:52:36 +00:00
|
|
|
: fWidth(width)
|
|
|
|
, fHeight(height)
|
2017-04-19 00:23:39 +00:00
|
|
|
, fConfig(GrVkFormatToPixelConfig(vkInfo->fFormat))
|
2017-04-18 19:52:36 +00:00
|
|
|
, fBackend(kVulkan_GrBackend)
|
|
|
|
, fVkInfo(vkInfo) {}
|
2017-04-19 00:23:39 +00:00
|
|
|
#endif // SK_VULKAN
|
2017-04-18 19:52:36 +00:00
|
|
|
|
|
|
|
GrBackendTexture::GrBackendTexture(int width,
|
|
|
|
int height,
|
|
|
|
GrPixelConfig config,
|
2017-04-19 00:23:39 +00:00
|
|
|
GrGLTextureInfo* glInfo)
|
2017-04-18 19:52:36 +00:00
|
|
|
: fWidth(width)
|
|
|
|
, fHeight(height)
|
|
|
|
, fConfig(config)
|
|
|
|
, fBackend(kOpenGL_GrBackend)
|
|
|
|
, fGLInfo(glInfo) {}
|
|
|
|
|
|
|
|
GrBackendTexture::GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend)
|
|
|
|
: fWidth(desc.fWidth)
|
|
|
|
, fHeight(desc.fHeight)
|
|
|
|
, fConfig(kVulkan_GrBackend == backend
|
|
|
|
#ifdef SK_VULKAN
|
|
|
|
? GrVkFormatToPixelConfig(((GrVkImageInfo*)desc.fTextureHandle)->fFormat)
|
|
|
|
#else
|
|
|
|
? kUnknown_GrPixelConfig
|
|
|
|
#endif
|
|
|
|
: desc.fConfig)
|
|
|
|
, fBackend(backend)
|
|
|
|
, fHandle(desc.fTextureHandle) {}
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
GrVkImageInfo* GrBackendTexture::getVkImageInfo() {
|
2017-04-18 19:52:36 +00:00
|
|
|
if (kVulkan_GrBackend == fBackend) {
|
|
|
|
return fVkInfo;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
GrGLTextureInfo* GrBackendTexture::getGLTextureInfo() {
|
2017-04-18 19:52:36 +00:00
|
|
|
if (kOpenGL_GrBackend == fBackend) {
|
|
|
|
return fGLInfo;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
#ifdef SK_VULKAN
|
2017-04-18 19:52:36 +00:00
|
|
|
GrBackendRenderTarget::GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
2017-04-19 00:23:39 +00:00
|
|
|
GrVkImageInfo* vkInfo)
|
2017-04-18 19:52:36 +00:00
|
|
|
: fWidth(width)
|
|
|
|
, fHeight(height)
|
|
|
|
, fSampleCnt(sampleCnt)
|
|
|
|
, fStencilBits(stencilBits)
|
2017-04-19 00:23:39 +00:00
|
|
|
, fConfig(GrVkFormatToPixelConfig(vkInfo->fFormat))
|
2017-04-18 19:52:36 +00:00
|
|
|
, fBackend(kVulkan_GrBackend)
|
|
|
|
, fVkInfo(vkInfo) {}
|
2017-04-19 00:23:39 +00:00
|
|
|
#endif // SK_VULKAN
|
2017-04-18 19:52:36 +00:00
|
|
|
|
|
|
|
GrBackendRenderTarget::GrBackendRenderTarget(int width,
|
|
|
|
int height,
|
|
|
|
int sampleCnt,
|
|
|
|
int stencilBits,
|
|
|
|
GrPixelConfig config,
|
2017-04-19 00:23:39 +00:00
|
|
|
GrGLTextureInfo* glInfo)
|
2017-04-18 19:52:36 +00:00
|
|
|
: fWidth(width)
|
|
|
|
, fHeight(height)
|
|
|
|
, fSampleCnt(sampleCnt)
|
|
|
|
, fStencilBits(stencilBits)
|
|
|
|
, fConfig(config)
|
|
|
|
, fBackend(kOpenGL_GrBackend)
|
|
|
|
, fGLInfo(glInfo) {}
|
|
|
|
|
|
|
|
GrBackendRenderTarget::GrBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
|
|
|
|
GrBackend backend)
|
|
|
|
: fWidth(desc.fWidth)
|
|
|
|
, fHeight(desc.fHeight)
|
|
|
|
, fSampleCnt(desc.fSampleCnt)
|
|
|
|
, fStencilBits(desc.fStencilBits)
|
|
|
|
, fConfig(kVulkan_GrBackend == backend
|
|
|
|
#ifdef SK_VULKAN
|
|
|
|
? GrVkFormatToPixelConfig(((GrVkImageInfo*)desc.fRenderTargetHandle)->fFormat)
|
|
|
|
#else
|
|
|
|
? kUnknown_GrPixelConfig
|
|
|
|
#endif
|
|
|
|
: desc.fConfig)
|
|
|
|
, fBackend(backend)
|
|
|
|
, fHandle(desc.fRenderTargetHandle) {}
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
GrVkImageInfo* GrBackendRenderTarget::getVkImageInfo() {
|
2017-04-18 19:52:36 +00:00
|
|
|
if (kVulkan_GrBackend == fBackend) {
|
|
|
|
return fVkInfo;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
GrGLTextureInfo* GrBackendRenderTarget::getGLTextureInfo() {
|
2017-04-18 19:52:36 +00:00
|
|
|
if (kOpenGL_GrBackend == fBackend) {
|
|
|
|
return fGLInfo;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|