Skip to content

Commit

Permalink
Reintroduce support for the CGImage destruction listener.
Browse files Browse the repository at this point in the history
  • Loading branch information
DHowett committed Feb 25, 2017
1 parent e7edfdf commit 7359e71
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Frameworks/CoreGraphics/CGImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@

static const wchar_t* TAG = L"CGImage";

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

#pragma endregion OLD_CODE

#pragma region CGImageImplementation

struct __CGImageImpl {
Expand Down Expand Up @@ -225,6 +223,12 @@ inline WICPixelFormatGUID PixelFormat() const {
_impl.renderingIntent = intent;
return *this;
}

~__CGImage() {
for (auto listener: _imageDestructionListeners) {
listener(this);
}
}
};

#pragma endregion CGImageImplementation
Expand Down

0 comments on commit 7359e71

Please sign in to comment.