35 ~GLWindowContext_win()
override;
55 this->initializeContext();
58GLWindowContext_win::~GLWindowContext_win() {
59 this->destroyContext();
63 HDC dc = GetDC(fHWND);
67 if (
nullptr == fHGLRC) {
72 if (
extensions.hasExtension(dc,
"WGL_EXT_swap_control")) {
73 extensions.swapInterval(fDisplayParams.fDisableVsync ? 0 : 1);
77 if (wglMakeCurrent(dc, fHGLRC)) {
79 bool renderDocAttached = interface->
hasExtension(
"GL_EXT_debug_tool");
80 interface.reset(
nullptr);
81 if (renderDocAttached) {
82 wglDeleteContext(fHGLRC);
85 if (
nullptr == fHGLRC) {
91 if (wglMakeCurrent(dc, fHGLRC)) {
93 glClearColor(0, 0, 0, 0);
94 glStencilMask(0xffffffff);
95 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
98 int pixelFormat = GetPixelFormat(dc);
99 PIXELFORMATDESCRIPTOR pfd;
100 DescribePixelFormat(dc, pixelFormat,
sizeof(pfd), &pfd);
101 fStencilBits = pfd.cStencilBits;
104 if (
extensions.hasExtension(dc,
"WGL_ARB_multisample")) {
112 fSampleCount =
std::max(fSampleCount, 1);
118 GetClientRect(fHWND, &
rect);
121 glViewport(0, 0, fWidth, fHeight);
127void GLWindowContext_win::onDestroyContext() {
128 wglDeleteContext(fHGLRC);
133void GLWindowContext_win::onSwapBuffers() {
134 HDC dc = GetDC((HWND)fHWND);
136 ReleaseDC((HWND)fHWND, dc);
145 std::unique_ptr<WindowContext> ctx(
new GLWindowContext_win(wnd,
params));
146 if (!ctx->isValid()) {
SK_API sk_sp< const GrGLInterface > GrGLMakeNativeInterface()
HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool deepColor, SkWGLContextRequest context, HGLRC shareContext=nullptr)
@ kGLPreferCompatibilityProfile_SkWGLContextRequest
@ kGLPreferCoreProfile_SkWGLContextRequest
virtual void onSwapBuffers()=0
virtual sk_sp< const GrGLInterface > onInitializeContext()=0
virtual void onDestroyContext()=0
const EmbeddedViewParams * params
static float max(float r, float g, float b)
sk_sp< SkBlender > blender SkRect rect
std::unique_ptr< WindowContext > MakeGLForWin(HWND wnd, const DisplayParams ¶ms)
bool hasExtension(const char ext[]) const