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,
EGLNativeWindowType window,
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,
......
......@@ -29,7 +29,6 @@ class SurfaceMtl : public SurfaceImpl
public:
SurfaceMtl(DisplayMtl *display,
const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs);
~SurfaceMtl() override;
......@@ -59,7 +58,6 @@ class SurfaceMtl : public SurfaceImpl
void setFixedWidth(EGLint width) override;
void setFixedHeight(EGLint height) override;
// width and height can change with client window resizing
EGLint getWidth() const override;
EGLint getHeight() const override;
......@@ -72,21 +70,15 @@ class SurfaceMtl : public SurfaceImpl
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);
protected:
// Ensure companion (depth, stencil) textures' size is correct w.r.t color texture.
angle::Result ensureDepthStencilSizeCorrect(const gl::Context *context,
gl::Framebuffer::DirtyBits *fboDirtyBits);
// Check if metal layer has been resized.
void checkIfLayerResized();
mtl::AutoObjCObj<CAMetalLayer> mMetalLayer = nil;
CALayer *mLayer;
mtl::AutoObjCPtr<id<CAMetalDrawable>> mCurrentDrawable = nil;
mtl::TextureRef mDrawableTexture;
mtl::TextureRef mColorTexture;
mtl::TextureRef mDepthTexture;
mtl::TextureRef mStencilTexture;
bool mUsePackedDepthStencil = false;
mtl::Format mColorFormat;
......@@ -98,6 +90,49 @@ class SurfaceMtl : public SurfaceImpl
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
#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