Skip to content

Commit

Permalink
Workaround for surface size on Fuchsia/Magma (flutter#3458)
Browse files Browse the repository at this point in the history
Allow surface size to be passed by caller
temporarily until we get a proper Display API
  • Loading branch information
mikejurka authored Mar 2, 2017
1 parent 342a311 commit 90dd98f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vulkan/vulkan_native_surface_magma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace vulkan {

VulkanNativeSurfaceMagma::VulkanNativeSurfaceMagma() = default;

VulkanNativeSurfaceMagma::VulkanNativeSurfaceMagma(int32_t width,
int32_t height) {
size_ = SkISize::Make(width, height);
}

VulkanNativeSurfaceMagma::~VulkanNativeSurfaceMagma() = default;

const char* VulkanNativeSurfaceMagma::GetExtensionName() const {
Expand Down Expand Up @@ -50,7 +55,12 @@ bool VulkanNativeSurfaceMagma::IsValid() const {
}

SkISize VulkanNativeSurfaceMagma::GetSize() const {
return SkISize::Make(2160, 1440);
if (size_.width() != 0 && size_.height() != 0) {
return size_;
} else {
// TODO: Don't hardcode this after we get a proper Fuchsia Display API.
return SkISize::Make(2160, 1440);
}
}

} // namespace vulkan
6 changes: 6 additions & 0 deletions vulkan/vulkan_native_surface_magma.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class VulkanNativeSurfaceMagma : public vulkan::VulkanNativeSurface {
public:
VulkanNativeSurfaceMagma();

// Alternate constructor which allows the caller to specify the surface's
// width and height.
// TODO: Remove this once we have a Fuchsia Display API.
VulkanNativeSurfaceMagma(int32_t surface_width, int32_t surface_height);

~VulkanNativeSurfaceMagma();

const char* GetExtensionName() const override;
Expand All @@ -29,6 +34,7 @@ class VulkanNativeSurfaceMagma : public vulkan::VulkanNativeSurface {
SkISize GetSize() const override;

private:
SkISize size_;
FTL_DISALLOW_COPY_AND_ASSIGN(VulkanNativeSurfaceMagma);
};

Expand Down

0 comments on commit 90dd98f

Please sign in to comment.