Commit 5e7b1c41 by Le Hoang Quyen Committed by Commit Bot

Metal: Create a dedicated class for Window Surface.

To distinguish it from PBuffer class in future. Bug: angleproject:2634 Change-Id: I1e256a74584fb001158465cd3068925847231984 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2281795 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 249db6da
...@@ -161,7 +161,7 @@ SurfaceImpl *DisplayMtl::createWindowSurface(const egl::SurfaceState &state, ...@@ -161,7 +161,7 @@ SurfaceImpl *DisplayMtl::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
return new SurfaceMtl(this, state, window, attribs); return new WindowSurfaceMtl(this, state, window, attribs);
} }
SurfaceImpl *DisplayMtl::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayMtl::createPbufferSurface(const egl::SurfaceState &state,
......
...@@ -29,7 +29,6 @@ class SurfaceMtl : public SurfaceImpl ...@@ -29,7 +29,6 @@ class SurfaceMtl : public SurfaceImpl
public: public:
SurfaceMtl(DisplayMtl *display, SurfaceMtl(DisplayMtl *display,
const egl::SurfaceState &state, const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs); const egl::AttributeMap &attribs);
~SurfaceMtl() override; ~SurfaceMtl() override;
...@@ -59,7 +58,6 @@ class SurfaceMtl : public SurfaceImpl ...@@ -59,7 +58,6 @@ class SurfaceMtl : public SurfaceImpl
void setFixedWidth(EGLint width) override; void setFixedWidth(EGLint width) override;
void setFixedHeight(EGLint height) override; void setFixedHeight(EGLint height) override;
// width and height can change with client window resizing
EGLint getWidth() const override; EGLint getWidth() const override;
EGLint getHeight() const override; EGLint getHeight() const override;
...@@ -72,21 +70,15 @@ class SurfaceMtl : public SurfaceImpl ...@@ -72,21 +70,15 @@ class SurfaceMtl : public SurfaceImpl
GLsizei samples, GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut) override; FramebufferAttachmentRenderTarget **rtOut) override;
private: protected:
angle::Result swapImpl(const gl::Context *context); // Ensure companion (depth, stencil) textures' size is correct w.r.t color texture.
angle::Result ensureRenderTargetsCreated(const gl::Context *context);
angle::Result obtainNextDrawable(const gl::Context *context);
angle::Result ensureDepthStencilSizeCorrect(const gl::Context *context, angle::Result ensureDepthStencilSizeCorrect(const gl::Context *context,
gl::Framebuffer::DirtyBits *fboDirtyBits); gl::Framebuffer::DirtyBits *fboDirtyBits);
// Check if metal layer has been resized.
void checkIfLayerResized();
mtl::AutoObjCObj<CAMetalLayer> mMetalLayer = nil; mtl::TextureRef mColorTexture;
CALayer *mLayer;
mtl::AutoObjCPtr<id<CAMetalDrawable>> mCurrentDrawable = nil;
mtl::TextureRef mDrawableTexture;
mtl::TextureRef mDepthTexture; mtl::TextureRef mDepthTexture;
mtl::TextureRef mStencilTexture; mtl::TextureRef mStencilTexture;
bool mUsePackedDepthStencil = false; bool mUsePackedDepthStencil = false;
mtl::Format mColorFormat; mtl::Format mColorFormat;
...@@ -98,6 +90,49 @@ class SurfaceMtl : public SurfaceImpl ...@@ -98,6 +90,49 @@ class SurfaceMtl : public SurfaceImpl
RenderTargetMtl mStencilRenderTarget; RenderTargetMtl mStencilRenderTarget;
}; };
class WindowSurfaceMtl : public SurfaceMtl
{
public:
WindowSurfaceMtl(DisplayMtl *display,
const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs);
~WindowSurfaceMtl() override;
void destroy(const egl::Display *display) override;
egl::Error initialize(const egl::Display *display) override;
FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
EGLint getSwapBehavior() const override;
// width and height can change with client window resizing
EGLint getWidth() const override;
EGLint getHeight() const override;
angle::Result getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut) override;
private:
angle::Result swapImpl(const gl::Context *context);
angle::Result ensureRenderTargetsCreated(const gl::Context *context);
angle::Result obtainNextDrawable(const gl::Context *context);
// Check if metal layer has been resized.
void checkIfLayerResized();
mtl::AutoObjCObj<CAMetalLayer> mMetalLayer = nil;
CALayer *mLayer;
mtl::AutoObjCPtr<id<CAMetalDrawable>> mCurrentDrawable = nil;
};
} // namespace rx } // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_SURFACEMTL_H_ */ #endif /* LIBANGLE_RENDERER_METAL_SURFACEMTL_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment