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

Unified Diff: tools/viewer/sk_app/VulkanWindowContext.cpp

Issue 1978573003: Add OpenGL context to Viewer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase to ToT Created 4 years, 7 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 | « tools/viewer/sk_app/VulkanWindowContext.h ('k') | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/VulkanWindowContext.cpp
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 2570e826a387c873afa3529bc95bb968814a4173..bc200de42704a57ece5760bf082b1bbdf5490a02 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -7,6 +7,7 @@
*/
#include "GrContext.h"
+#include "GrRenderTarget.h"
#include "SkSurface.h"
#include "VulkanWindowContext.h"
@@ -25,8 +26,12 @@
namespace sk_app {
VulkanWindowContext::VulkanWindowContext(void* platformData, const DisplayParams& params)
- : fSurface(VK_NULL_HANDLE)
+ : WindowContext()
+ , fSurface(VK_NULL_HANDLE)
, fSwapchain(VK_NULL_HANDLE)
+ , fImages(nullptr)
+ , fImageLayouts(nullptr)
+ , fSurfaces(nullptr)
, fCommandPool(VK_NULL_HANDLE)
, fBackbuffers(nullptr) {
@@ -250,6 +255,7 @@ void VulkanWindowContext::createBuffers(VkFormat format) {
// set up initial image layouts and create surfaces
fImageLayouts = new VkImageLayout[fImageCount];
+ fRenderTargets = new sk_sp<GrRenderTarget>[fImageCount];
fSurfaces = new sk_sp<SkSurface>[fImageCount];
for (uint32_t i = 0; i < fImageCount; ++i) {
fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED;
@@ -269,10 +275,9 @@ void VulkanWindowContext::createBuffers(VkFormat format) {
desc.fSampleCnt = 0;
desc.fStencilBits = 0;
desc.fRenderTargetHandle = (GrBackendObject) &info;
- SkSurfaceProps props(GrPixelConfigIsSRGB(fPixelConfig)
- ? SkSurfaceProps::kGammaCorrect_Flag : 0,
- kUnknown_SkPixelGeometry);
- fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(fContext, desc, &props);
+ fRenderTargets[i].reset(fContext->textureProvider()->wrapBackendRenderTarget(desc));
+
+ fSurfaces[i] = this->createRenderSurface(fRenderTargets[i], 24);
}
// create the command pool for the command buffers
@@ -361,8 +366,11 @@ void VulkanWindowContext::destroyBuffers() {
delete[] fBackbuffers;
fBackbuffers = nullptr;
+ // Does this actually free the surfaces?
delete[] fSurfaces;
fSurfaces = nullptr;
+ delete[] fRenderTargets;
+ fRenderTargets = nullptr;
delete[] fImageLayouts;
fImageLayouts = nullptr;
delete[] fImages;
@@ -398,7 +406,8 @@ void VulkanWindowContext::destroyContext() {
fSurface = VK_NULL_HANDLE;
}
- delete fContext;
+ fContext->abandonContext();
+ fContext->unref();
fBackendContext.reset(nullptr);
}
@@ -419,7 +428,7 @@ VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer
return backbuffer;
}
-SkSurface* VulkanWindowContext::getBackbufferSurface() {
+sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
BackbufferInfo* backbuffer = this->getAvailableBackbuffer();
SkASSERT(backbuffer);
@@ -510,14 +519,16 @@ SkSurface* VulkanWindowContext::getBackbufferSurface() {
QueueSubmit(fBackendContext->fQueue, 1, &submitInfo,
backbuffer->fUsageFences[0]));
- return fSurfaces[backbuffer->fImageIndex].get();
+ return sk_ref_sp(fSurfaces[backbuffer->fImageIndex].get());
}
-
void VulkanWindowContext::swapBuffers() {
BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex;
+ this->presentRenderSurface(fSurfaces[backbuffer->fImageIndex],
+ fRenderTargets[backbuffer->fImageIndex], 24);
+
VkImageLayout layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
« no previous file with comments | « tools/viewer/sk_app/VulkanWindowContext.h ('k') | tools/viewer/sk_app/Window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698