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

Commit a01904f

Browse files
DHowettRaj Seshasankaran
authored andcommitted
Reintroduce support for the CGImage destruction listener. (#2099)
Fixes #1928. Fixes #2096. Refs #2098.
1 parent e56b771 commit a01904f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Frameworks/CoreGraphics/CGImage.mm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@
3939

4040
static const wchar_t* TAG = L"CGImage";
4141

42-
// TODO #1124: remove old code
43-
#pragma region OLD_CODE
42+
// This is used by XamlCompositor to flush the DisplayTexture cache.
43+
// TODO GH#2098 look at where we're using the image cache and what we can do to avoid it.
4444
static std::vector<CGImageDestructionListener> _imageDestructionListeners;
4545
COREGRAPHICS_EXPORT void CGImageAddDestructionListener(CGImageDestructionListener listener) {
4646
_imageDestructionListeners.push_back(listener);
4747
}
4848

49-
#pragma endregion OLD_CODE
50-
5149
#pragma region CGImageImplementation
5250

5351
struct __CGImageImpl {
@@ -225,6 +223,12 @@ inline WICPixelFormatGUID PixelFormat() const {
225223
_impl.renderingIntent = intent;
226224
return *this;
227225
}
226+
227+
~__CGImage() {
228+
for (auto listener: _imageDestructionListeners) {
229+
listener(this);
230+
}
231+
}
228232
};
229233

230234
#pragma endregion CGImageImplementation

0 commit comments

Comments
 (0)