LocalCurrentGraphicsContext.h [plain text]
#pragma once
#include "GraphicsContext.h"
#include <wtf/Noncopyable.h>
#if PLATFORM(COCOA)
#if USE(APPKIT)
OBJC_CLASS NSGraphicsContext;
#endif
namespace WebCore {
class LocalCurrentGraphicsContext {
WTF_MAKE_NONCOPYABLE(LocalCurrentGraphicsContext);
public:
WEBCORE_EXPORT LocalCurrentGraphicsContext(GraphicsContext&);
WEBCORE_EXPORT ~LocalCurrentGraphicsContext();
CGContextRef cgContext() { return m_savedGraphicsContext.platformContext(); }
private:
GraphicsContext& m_savedGraphicsContext;
#if USE(APPKIT)
RetainPtr<NSGraphicsContext> m_savedNSGraphicsContext;
#endif
bool m_didSetGraphicsContext { false };
};
class ContextContainer {
WTF_MAKE_NONCOPYABLE(ContextContainer);
public:
ContextContainer(GraphicsContext& graphicsContext)
: m_graphicsContext(graphicsContext.platformContext())
{
}
CGContextRef context() { return m_graphicsContext; }
private:
CGContextRef m_graphicsContext;
};
}
#endif // PLATFORM(COCOA)