Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit cbff90d

Browse files
committed
Don't convert back and forth between weak ptr
1 parent b90ef01 commit cbff90d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

impeller/renderer/backend/metal/surface_mtl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class SurfaceMTL final : public Surface {
4343
id<MTLDrawable> drawable() const { return drawable_; }
4444

4545
private:
46-
std::weak_ptr<Context> context_;
46+
std::shared_ptr<Context> context_;
4747
id<MTLDrawable> drawable_ = nil;
4848

49-
SurfaceMTL(const std::weak_ptr<Context>& context,
49+
SurfaceMTL(const std::shared_ptr<Context>& context,
5050
const RenderTarget& target,
5151
id<MTLDrawable> drawable);
5252

impeller/renderer/backend/metal/surface_mtl.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@
112112
render_target_desc.SetStencilAttachment(stencil0);
113113

114114
// The constructor is private. So make_unique may not be used.
115-
return std::unique_ptr<SurfaceMTL>(new SurfaceMTL(
116-
context->weak_from_this(), render_target_desc, current_drawable));
115+
return std::unique_ptr<SurfaceMTL>(
116+
new SurfaceMTL(context, render_target_desc, current_drawable));
117117
}
118118

119-
SurfaceMTL::SurfaceMTL(const std::weak_ptr<Context>& context,
119+
SurfaceMTL::SurfaceMTL(const std::shared_ptr<Context>& context,
120120
const RenderTarget& target,
121121
id<MTLDrawable> drawable)
122122
: Surface(target), context_(context), drawable_(drawable) {}
@@ -131,7 +131,7 @@
131131
}
132132

133133
id<MTLCommandBuffer> command_buffer =
134-
ContextMTL::Cast(context_.lock().get())->CreateMTLCommandBuffer();
134+
ContextMTL::Cast(context_.get())->CreateMTLCommandBuffer();
135135
[command_buffer presentDrawable:drawable_];
136136
[command_buffer commit];
137137

0 commit comments

Comments
 (0)