-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
14cb066
commit eb6eabc
Showing
18 changed files
with
498 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" | ||
|
||
namespace flutter { | ||
|
||
GPUSurfaceMetalDelegate::GPUSurfaceMetalDelegate( | ||
MTLRenderTargetType render_target_type) | ||
: render_target_type_(render_target_type) {} | ||
|
||
GPUSurfaceMetalDelegate::~GPUSurfaceMetalDelegate() = default; | ||
|
||
MTLRenderTargetType GPUSurfaceMetalDelegate::GetRenderTargetType() { | ||
return render_target_type_; | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ | ||
#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#include "flutter/fml/macros.h" | ||
#include "third_party/skia/include/core/SkSize.h" | ||
#include "third_party/skia/include/core/SkSurface.h" | ||
#include "third_party/skia/include/gpu/mtl/GrMtlTypes.h" | ||
|
||
namespace flutter { | ||
|
||
// expected to be id<MTLDevice> | ||
typedef void* GPUMTLDeviceHandle; | ||
|
||
// expected to be id<MTLCommandQueues> | ||
typedef void* GPUMTLCommandQueueHandle; | ||
|
||
// expected to be CAMetalLayer* | ||
typedef void* GPUCAMetalLayerHandle; | ||
|
||
// expected to be id<MTLTexture> | ||
typedef void* GPUMTLTextureHandle; | ||
|
||
struct GPUMTLTextureInfo { | ||
intptr_t texture_id; | ||
GPUMTLTextureHandle texture; | ||
}; | ||
|
||
enum class MTLRenderTargetType { kMTLTexture, kCAMetalLayer }; | ||
|
||
//------------------------------------------------------------------------------ | ||
/// @brief Interface implemented by all platform surfaces that can present | ||
/// a metal backing store to the "screen". The GPU surface | ||
/// abstraction (which abstracts the client rendering API) uses this | ||
/// delegation pattern to tell the platform surface (which abstracts | ||
/// how backing stores fulfilled by the selected client rendering | ||
/// API end up on the "screen" on a particular platform) when the | ||
/// rasterizer needs to allocate and present the software backing | ||
/// store. | ||
/// | ||
/// @see |IOSurfaceMetal| and |EmbedderSurfaceMetal|. | ||
/// | ||
class GPUSurfaceMetalDelegate { | ||
public: | ||
//------------------------------------------------------------------------------ | ||
/// @brief Construct a new GPUSurfaceMetalDelegate object with the specified | ||
/// render_target type. | ||
/// | ||
/// @see |MTLRenderTargetType| | ||
/// | ||
explicit GPUSurfaceMetalDelegate(MTLRenderTargetType render_target); | ||
|
||
virtual ~GPUSurfaceMetalDelegate(); | ||
|
||
//------------------------------------------------------------------------------ | ||
/// @brief Returns the handle to the CAMetalLayer to render to. This is only | ||
/// called when the specifed render target type is `kCAMetalLayer`. | ||
/// | ||
virtual GPUCAMetalLayerHandle GetCAMetalLayer( | ||
const SkISize& frame_info) const = 0; | ||
|
||
//------------------------------------------------------------------------------ | ||
/// @brief Presents the drawable to the "screen". The drawable is obtained | ||
/// from the CAMetalLayer that given by `GetCAMetalLayer` call. This is only | ||
/// called when the specified render target type in `kCAMetalLayer`. | ||
/// | ||
/// @see |GPUSurfaceMetalDelegate::GetCAMetalLayer| | ||
/// | ||
virtual bool PresentDrawable(GrMTLHandle drawable) const = 0; | ||
|
||
//------------------------------------------------------------------------------ | ||
/// @brief Returns the handle to the MTLTexture to render to. This is only | ||
/// called when the specefied render target type is `kMTLTexture`. | ||
/// | ||
virtual GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const = 0; | ||
|
||
//------------------------------------------------------------------------------ | ||
/// @brief Presents the texture with `texture_id` to the "screen". | ||
/// `texture_id` corresponds to a texture that has been obtained by an earlier | ||
/// call to `GetMTLTexture`. This is only called when the specefied render | ||
/// target type is `kMTLTexture`. | ||
/// | ||
/// @see |GPUSurfaceMetalDelegate::GetMTLTexture| | ||
/// | ||
virtual bool PresentTexture(intptr_t texture_id) const = 0; | ||
|
||
MTLRenderTargetType GetRenderTargetType(); | ||
|
||
private: | ||
const MTLRenderTargetType render_target_type_; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ |
Oops, something went wrong.