Skip to content

Commit

Permalink
Migrate VK calls of GrBackend* (flutter#45325)
Browse files Browse the repository at this point in the history
In https://skia-review.googlesource.com/c/skia/+/742797 Skia refactored
GrBackend* to not require #ifdefs. This changes
callsites in Flutter to use static functions instead of methods that
were conditionally compiled on those classes.

There should be no functional change.
  • Loading branch information
brianosman authored Aug 31, 2023
1 parent cfc8823 commit 77444a7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
7 changes: 3 additions & 4 deletions shell/gpu/gpu_surface_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#include "vulkan/vulkan_core.h"

namespace flutter {
Expand Down Expand Up @@ -115,10 +116,8 @@ sk_sp<SkSurface> GPUSurfaceVulkan::CreateSurfaceFromVulkanImage(
.fSampleCount = 1,
.fLevelCount = 1,
};
GrBackendTexture backend_texture(size.width(), //
size.height(), //
image_info //
);
auto backend_texture =
GrBackendTextures::MakeVk(size.width(), size.height(), image_info);

SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);

Expand Down
10 changes: 6 additions & 4 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ extern const intptr_t kPlatformStrongDillSize;
#endif // IMPELLER_SUPPORTS_RENDERING
#endif // SHELL_ENABLE_METAL

#ifdef SHELL_ENABLE_VULKAN
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#endif // SHELL_ENABLE_VULKAN

const int32_t kFlutterSemanticsNodeIdBatchEnd = -1;
const int32_t kFlutterSemanticsCustomActionIdBatchEnd = -1;

Expand Down Expand Up @@ -1105,10 +1109,8 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
.fSampleCount = 1,
.fLevelCount = 1,
};
GrBackendTexture backend_texture(config.size.width, //
config.size.height, //
image_info //
);
auto backend_texture = GrBackendTextures::MakeVk(
config.size.width, config.size.height, image_info);

SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <memory>
#include <utility>

#ifdef SHELL_ENABLE_VULKAN
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#endif // SHELL_ENABLE_VULKAN

// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
// NOLINTBEGIN(bugprone-unchecked-optional-access)

Expand Down Expand Up @@ -329,8 +333,8 @@ bool EmbedderTestBackingStoreProducer::CreateVulkanImage(
.fSampleCount = 1,
.fLevelCount = 1,
};
GrBackendTexture backend_texture(surface_size.width(), surface_size.height(),
image_info);
auto backend_texture = GrBackendTextures::MakeVk(
surface_size.width(), surface_size.height(), image_info);

SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);

Expand Down
7 changes: 3 additions & 4 deletions testing/test_vulkan_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#include "third_party/skia/include/gpu/vk/GrVkTypes.h"

namespace flutter {
Expand Down Expand Up @@ -43,10 +44,8 @@ std::unique_ptr<TestVulkanSurface> TestVulkanSurface::Create(
.fSampleCount = 1,
.fLevelCount = 1,
};
GrBackendTexture backend_texture(surface_size.width(), //
surface_size.height(), //
image_info //
);
auto backend_texture = GrBackendTextures::MakeVk(
surface_size.width(), surface_size.height(), image_info);

SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);

Expand Down
8 changes: 5 additions & 3 deletions vulkan/vulkan_swapchain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#include "third_party/skia/include/gpu/vk/GrVkTypes.h"

#include "vulkan_backbuffer.h"
Expand Down Expand Up @@ -242,8 +243,8 @@ sk_sp<SkSurface> VulkanSwapchain::CreateSkiaSurface(
image_info.fLevelCount = 1;

// TODO(chinmaygarde): Setup the stencil buffer and the sampleCnt.
GrBackendRenderTarget backend_render_target(size.fWidth, size.fHeight,
image_info);
auto backend_render_target =
GrBackendRenderTargets::MakeVk(size.fWidth, size.fHeight, image_info);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);

return SkSurfaces::WrapBackendRenderTarget(
Expand Down Expand Up @@ -483,7 +484,8 @@ VulkanSwapchain::AcquireResult VulkanSwapchain::AcquireSurface() {
FML_DLOG(INFO) << "Could not get backend render target.";
return error;
}
backendRT.setVkImageLayout(destination_image_layout);
GrBackendRenderTargets::SetVkImageLayout(&backendRT,
destination_image_layout);

current_image_index_ = next_image_index;

Expand Down

0 comments on commit 77444a7

Please sign in to comment.