| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "SkTypes.h" | 7 #include "SkTypes.h" |
| 8 | 8 |
| 9 #if defined(SK_BUILD_FOR_WIN) | 9 #if defined(SK_BUILD_FOR_WIN) |
| 10 | 10 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 332 } |
| 333 if (delay) | 333 if (delay) |
| 334 { | 334 { |
| 335 gTimer = SetTimer(NULL, 0, delay, sk_timer_proc); | 335 gTimer = SetTimer(NULL, 0, delay, sk_timer_proc); |
| 336 //SkDebugf("SetTimer of %d returned %d\n", delay, gTimer); | 336 //SkDebugf("SetTimer of %d returned %d\n", delay, gTimer); |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 #if SK_SUPPORT_GPU | 340 #if SK_SUPPORT_GPU |
| 341 | 341 |
| 342 bool SkOSWindow::attachGL(int msaaSampleCount, AttachmentInfo* info) { | 342 bool SkOSWindow::attachGL(int msaaSampleCount, bool deepColor, AttachmentInfo* i
nfo) { |
| 343 HDC dc = GetDC((HWND)fHWND); | 343 HDC dc = GetDC((HWND)fHWND); |
| 344 if (NULL == fHGLRC) { | 344 if (NULL == fHGLRC) { |
| 345 fHGLRC = SkCreateWGLContext(dc, msaaSampleCount, | 345 fHGLRC = SkCreateWGLContext(dc, msaaSampleCount, deepColor, |
| 346 kGLPreferCompatibilityProfile_SkWGLContextRequest); | 346 kGLPreferCompatibilityProfile_SkWGLContextRequest); |
| 347 if (NULL == fHGLRC) { | 347 if (NULL == fHGLRC) { |
| 348 return false; | 348 return false; |
| 349 } | 349 } |
| 350 glClearStencil(0); | 350 glClearStencil(0); |
| 351 glClearColor(0, 0, 0, 0); | 351 glClearColor(0, 0, 0, 0); |
| 352 glStencilMask(0xffffffff); | 352 glStencilMask(0xffffffff); |
| 353 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); | 353 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
| 354 } | 354 } |
| 355 if (wglMakeCurrent(dc, (HGLRC)fHGLRC)) { | 355 if (wglMakeCurrent(dc, (HGLRC)fHGLRC)) { |
| 356 // use DescribePixelFormat to get the stencil bit depth. | 356 // use DescribePixelFormat to get the stencil and color bit depth. |
| 357 int pixelFormat = GetPixelFormat(dc); | 357 int pixelFormat = GetPixelFormat(dc); |
| 358 PIXELFORMATDESCRIPTOR pfd; | 358 PIXELFORMATDESCRIPTOR pfd; |
| 359 DescribePixelFormat(dc, pixelFormat, sizeof(pfd), &pfd); | 359 DescribePixelFormat(dc, pixelFormat, sizeof(pfd), &pfd); |
| 360 info->fStencilBits = pfd.cStencilBits; | 360 info->fStencilBits = pfd.cStencilBits; |
| 361 // pfd.cColorBits includes alpha, so it will be 32 in 8/8/8/8 and 10/10/
10/2 |
| 362 info->fColorBits = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits; |
| 361 | 363 |
| 362 // Get sample count if the MSAA WGL extension is present | 364 // Get sample count if the MSAA WGL extension is present |
| 363 SkWGLExtensions extensions; | 365 SkWGLExtensions extensions; |
| 364 if (extensions.hasExtension(dc, "WGL_ARB_multisample")) { | 366 if (extensions.hasExtension(dc, "WGL_ARB_multisample")) { |
| 365 static const int kSampleCountAttr = SK_WGL_SAMPLES; | 367 static const int kSampleCountAttr = SK_WGL_SAMPLES; |
| 366 extensions.getPixelFormatAttribiv(dc, | 368 extensions.getPixelFormatAttribiv(dc, |
| 367 pixelFormat, | 369 pixelFormat, |
| 368 0, | 370 0, |
| 369 1, | 371 1, |
| 370 &kSampleCountAttr, | 372 &kSampleCountAttr, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 646 } |
| 645 | 647 |
| 646 void SkOSWindow::presentCommandBuffer() { | 648 void SkOSWindow::presentCommandBuffer() { |
| 647 fCommandBuffer->presentCommandBuffer(); | 649 fCommandBuffer->presentCommandBuffer(); |
| 648 } | 650 } |
| 649 #endif // SK_COMMAND_BUFFER | 651 #endif // SK_COMMAND_BUFFER |
| 650 | 652 |
| 651 #endif // SK_SUPPORT_GPU | 653 #endif // SK_SUPPORT_GPU |
| 652 | 654 |
| 653 // return true on success | 655 // return true on success |
| 654 bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, Attachme
ntInfo* info) { | 656 bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, bool dee
pColor, |
| 657 AttachmentInfo* info) { |
| 655 | 658 |
| 656 // attach doubles as "windowResize" so we need to allo | 659 // attach doubles as "windowResize" so we need to allo |
| 657 // already bound states to pass through again | 660 // already bound states to pass through again |
| 658 // TODO: split out the resize functionality | 661 // TODO: split out the resize functionality |
| 659 // SkASSERT(kNone_BackEndType == fAttached); | 662 // SkASSERT(kNone_BackEndType == fAttached); |
| 660 bool result = true; | 663 bool result = true; |
| 661 | 664 |
| 662 switch (attachType) { | 665 switch (attachType) { |
| 663 case kNone_BackEndType: | 666 case kNone_BackEndType: |
| 664 // nothing to do | 667 // nothing to do |
| 665 break; | 668 break; |
| 666 #if SK_SUPPORT_GPU | 669 #if SK_SUPPORT_GPU |
| 667 case kNativeGL_BackEndType: | 670 case kNativeGL_BackEndType: |
| 668 result = attachGL(msaaSampleCount, info); | 671 result = attachGL(msaaSampleCount, deepColor, info); |
| 669 break; | 672 break; |
| 670 #if SK_ANGLE | 673 #if SK_ANGLE |
| 671 case kANGLE_BackEndType: | 674 case kANGLE_BackEndType: |
| 672 result = attachANGLE(msaaSampleCount, info); | 675 result = attachANGLE(msaaSampleCount, info); |
| 673 break; | 676 break; |
| 674 #endif // SK_ANGLE | 677 #endif // SK_ANGLE |
| 675 #if SK_COMMAND_BUFFER | 678 #if SK_COMMAND_BUFFER |
| 676 case kCommandBuffer_BackEndType: | 679 case kCommandBuffer_BackEndType: |
| 677 result = attachCommandBuffer(msaaSampleCount, info); | 680 result = attachCommandBuffer(msaaSampleCount, info); |
| 678 break; | 681 break; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 829 } |
| 827 | 830 |
| 828 void SkOSWindow::closeWindow() { | 831 void SkOSWindow::closeWindow() { |
| 829 DestroyWindow((HWND)fHWND); | 832 DestroyWindow((HWND)fHWND); |
| 830 if (fFullscreen) { | 833 if (fFullscreen) { |
| 831 DestroyWindow((HWND)fSavedWindowState.fHWND); | 834 DestroyWindow((HWND)fSavedWindowState.fHWND); |
| 832 } | 835 } |
| 833 gHwndToOSWindowMap.remove(fHWND); | 836 gHwndToOSWindowMap.remove(fHWND); |
| 834 } | 837 } |
| 835 #endif | 838 #endif |
| OLD | NEW |