Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: src/views/win/SkOSWindow_win.cpp

Issue 2061233002: Remove command buffer sample app support. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 #include "SkGraphics.h" 22 #include "SkGraphics.h"
23 23
24 #if SK_ANGLE 24 #if SK_ANGLE
25 #include "gl/GrGLAssembleInterface.h" 25 #include "gl/GrGLAssembleInterface.h"
26 #include "gl/GrGLInterface.h" 26 #include "gl/GrGLInterface.h"
27 #include "GLES2/gl2.h" 27 #include "GLES2/gl2.h"
28 #include <EGL/egl.h> 28 #include <EGL/egl.h>
29 #include <EGL/eglext.h> 29 #include <EGL/eglext.h>
30 #endif // SK_ANGLE 30 #endif // SK_ANGLE
31 31
32 #if SK_COMMAND_BUFFER
33 #include "gl/command_buffer/SkCommandBufferGLContext.h"
34 #endif // SK_COMMAND_BUFFER
35
36 const int kDefaultWindowWidth = 500; 32 const int kDefaultWindowWidth = 500;
37 const int kDefaultWindowHeight = 500; 33 const int kDefaultWindowHeight = 500;
38 34
39 #define GL_CALL(IFACE, X) \ 35 #define GL_CALL(IFACE, X) \
40 SkASSERT(IFACE); \ 36 SkASSERT(IFACE); \
41 do { \ 37 do { \
42 (IFACE)->fFunctions.f##X; \ 38 (IFACE)->fFunctions.f##X; \
43 } while (false) 39 } while (false)
44 40
45 #define WM_EVENT_CALLBACK (WM_USER+0) 41 #define WM_EVENT_CALLBACK (WM_USER+0)
(...skipping 11 matching lines...) Expand all
57 fHWND = CreateWindow(fWinInit.fClass, NULL, WS_OVERLAPPEDWINDOW, 53 fHWND = CreateWindow(fWinInit.fClass, NULL, WS_OVERLAPPEDWINDOW,
58 CW_USEDEFAULT, 0, kDefaultWindowWidth, kDefaultWindowHe ight, NULL, NULL, 54 CW_USEDEFAULT, 0, kDefaultWindowWidth, kDefaultWindowHe ight, NULL, NULL,
59 fWinInit.fInstance, NULL); 55 fWinInit.fInstance, NULL);
60 gHwndToOSWindowMap.set(fHWND, this); 56 gHwndToOSWindowMap.set(fHWND, this);
61 #if SK_SUPPORT_GPU 57 #if SK_SUPPORT_GPU
62 #if SK_ANGLE 58 #if SK_ANGLE
63 fDisplay = EGL_NO_DISPLAY; 59 fDisplay = EGL_NO_DISPLAY;
64 fContext = EGL_NO_CONTEXT; 60 fContext = EGL_NO_CONTEXT;
65 fSurface = EGL_NO_SURFACE; 61 fSurface = EGL_NO_SURFACE;
66 #endif 62 #endif
67 #if SK_COMMAND_BUFFER
68 fCommandBuffer = nullptr;
69 #endif // SK_COMMAND_BUFFER
70 63
71 fHGLRC = NULL; 64 fHGLRC = NULL;
72 #endif 65 #endif
73 fAttached = kNone_BackEndType; 66 fAttached = kNone_BackEndType;
74 fFullscreen = false; 67 fFullscreen = false;
75 } 68 }
76 69
77 SkOSWindow::~SkOSWindow() { 70 SkOSWindow::~SkOSWindow() {
78 #if SK_SUPPORT_GPU 71 #if SK_SUPPORT_GPU
79 if (fHGLRC) { 72 if (fHGLRC) {
80 wglDeleteContext((HGLRC)fHGLRC); 73 wglDeleteContext((HGLRC)fHGLRC);
81 } 74 }
82 #if SK_ANGLE 75 #if SK_ANGLE
83 if (EGL_NO_CONTEXT != fContext) { 76 if (EGL_NO_CONTEXT != fContext) {
84 eglDestroyContext(fDisplay, fContext); 77 eglDestroyContext(fDisplay, fContext);
85 fContext = EGL_NO_CONTEXT; 78 fContext = EGL_NO_CONTEXT;
86 } 79 }
87 80
88 if (EGL_NO_SURFACE != fSurface) { 81 if (EGL_NO_SURFACE != fSurface) {
89 eglDestroySurface(fDisplay, fSurface); 82 eglDestroySurface(fDisplay, fSurface);
90 fSurface = EGL_NO_SURFACE; 83 fSurface = EGL_NO_SURFACE;
91 } 84 }
92 85
93 if (EGL_NO_DISPLAY != fDisplay) { 86 if (EGL_NO_DISPLAY != fDisplay) {
94 eglTerminate(fDisplay); 87 eglTerminate(fDisplay);
95 fDisplay = EGL_NO_DISPLAY; 88 fDisplay = EGL_NO_DISPLAY;
96 } 89 }
97 #endif // SK_ANGLE 90 #endif // SK_ANGLE
98 #if SK_COMMAND_BUFFER
99 delete fCommandBuffer;
100 #endif // SK_COMMAND_BUFFER
101
102 #endif // SK_SUPPORT_GPU 91 #endif // SK_SUPPORT_GPU
103 this->closeWindow(); 92 this->closeWindow();
104 } 93 }
105 94
106 static SkKey winToskKey(WPARAM vk) { 95 static SkKey winToskKey(WPARAM vk) {
107 static const struct { 96 static const struct {
108 WPARAM fVK; 97 WPARAM fVK;
109 SkKey fKey; 98 SkKey fKey;
110 } gPair[] = { 99 } gPair[] = {
111 { VK_BACK, kBack_SkKey }, 100 { VK_BACK, kBack_SkKey },
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 fDisplay = EGL_NO_DISPLAY; 592 fDisplay = EGL_NO_DISPLAY;
604 } 593 }
605 594
606 void SkOSWindow::presentANGLE() { 595 void SkOSWindow::presentANGLE() {
607 GL_CALL(fANGLEInterface, Flush()); 596 GL_CALL(fANGLEInterface, Flush());
608 597
609 eglSwapBuffers(fDisplay, fSurface); 598 eglSwapBuffers(fDisplay, fSurface);
610 } 599 }
611 #endif // SK_ANGLE 600 #endif // SK_ANGLE
612 601
613 #if SK_COMMAND_BUFFER
614
615 bool SkOSWindow::attachCommandBuffer(int msaaSampleCount, AttachmentInfo* info) {
616 if (!fCommandBuffer) {
617 fCommandBuffer = SkCommandBufferGLContext::Create((HWND)fHWND, msaaSampl eCount);
618 if (!fCommandBuffer)
619 return false;
620
621 SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface( ));
622 if (intf) {
623 GL_CALL(intf, ClearStencil(0));
624 GL_CALL(intf, ClearColor(0, 0, 0, 0));
625 GL_CALL(intf, StencilMask(0xffffffff));
626 GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT));
627 }
628 }
629
630 if (fCommandBuffer->makeCurrent()) {
631 info->fStencilBits = fCommandBuffer->getStencilBits();
632 info->fSampleCount = fCommandBuffer->getSampleCount();
633
634 SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface( ));
635
636 if (intf ) {
637 GL_CALL(intf, Viewport(0, 0, SkScalarRoundToInt(this->width()),
638 SkScalarRoundToInt(this->height())));
639 }
640 return true;
641 }
642 return false;
643 }
644
645 void SkOSWindow::detachCommandBuffer() {
646 delete fCommandBuffer;
647 fCommandBuffer = nullptr;
648 }
649
650 void SkOSWindow::presentCommandBuffer() {
651 fCommandBuffer->presentCommandBuffer();
652 }
653 #endif // SK_COMMAND_BUFFER
654
655 #endif // SK_SUPPORT_GPU 602 #endif // SK_SUPPORT_GPU
656 603
657 // return true on success 604 // return true on success
658 bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, bool dee pColor, 605 bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, bool dee pColor,
659 AttachmentInfo* info) { 606 AttachmentInfo* info) {
660 607
661 // attach doubles as "windowResize" so we need to allo 608 // attach doubles as "windowResize" so we need to allo
662 // already bound states to pass through again 609 // already bound states to pass through again
663 // TODO: split out the resize functionality 610 // TODO: split out the resize functionality
664 // SkASSERT(kNone_BackEndType == fAttached); 611 // SkASSERT(kNone_BackEndType == fAttached);
665 bool result = true; 612 bool result = true;
666 613
667 switch (attachType) { 614 switch (attachType) {
668 case kNone_BackEndType: 615 case kNone_BackEndType:
669 // nothing to do 616 // nothing to do
670 break; 617 break;
671 #if SK_SUPPORT_GPU 618 #if SK_SUPPORT_GPU
672 case kNativeGL_BackEndType: 619 case kNativeGL_BackEndType:
673 result = attachGL(msaaSampleCount, deepColor, info); 620 result = attachGL(msaaSampleCount, deepColor, info);
674 break; 621 break;
675 #if SK_ANGLE 622 #if SK_ANGLE
676 case kANGLE_BackEndType: 623 case kANGLE_BackEndType:
677 result = attachANGLE(msaaSampleCount, info); 624 result = attachANGLE(msaaSampleCount, info);
678 break; 625 break;
679 #endif // SK_ANGLE 626 #endif // SK_ANGLE
680 #if SK_COMMAND_BUFFER
681 case kCommandBuffer_BackEndType:
682 result = attachCommandBuffer(msaaSampleCount, info);
683 break;
684 #endif // SK_COMMAND_BUFFER
685 #endif // SK_SUPPORT_GPU 627 #endif // SK_SUPPORT_GPU
686 default: 628 default:
687 SkASSERT(false); 629 SkASSERT(false);
688 result = false; 630 result = false;
689 break; 631 break;
690 } 632 }
691 633
692 if (result) { 634 if (result) {
693 fAttached = attachType; 635 fAttached = attachType;
694 } 636 }
695 637
696 return result; 638 return result;
697 } 639 }
698 640
699 void SkOSWindow::release() { 641 void SkOSWindow::release() {
700 switch (fAttached) { 642 switch (fAttached) {
701 case kNone_BackEndType: 643 case kNone_BackEndType:
702 // nothing to do 644 // nothing to do
703 break; 645 break;
704 #if SK_SUPPORT_GPU 646 #if SK_SUPPORT_GPU
705 case kNativeGL_BackEndType: 647 case kNativeGL_BackEndType:
706 detachGL(); 648 detachGL();
707 break; 649 break;
708 #if SK_ANGLE 650 #if SK_ANGLE
709 case kANGLE_BackEndType: 651 case kANGLE_BackEndType:
710 detachANGLE(); 652 detachANGLE();
711 break; 653 break;
712 #endif // SK_ANGLE 654 #endif // SK_ANGLE
713 #if SK_COMMAND_BUFFER
714 case kCommandBuffer_BackEndType:
715 detachCommandBuffer();
716 break;
717 #endif // SK_COMMAND_BUFFER
718 #endif // SK_SUPPORT_GPU 655 #endif // SK_SUPPORT_GPU
719 default: 656 default:
720 SkASSERT(false); 657 SkASSERT(false);
721 break; 658 break;
722 } 659 }
723 fAttached = kNone_BackEndType; 660 fAttached = kNone_BackEndType;
724 } 661 }
725 662
726 void SkOSWindow::present() { 663 void SkOSWindow::present() {
727 switch (fAttached) { 664 switch (fAttached) {
728 case kNone_BackEndType: 665 case kNone_BackEndType:
729 // nothing to do 666 // nothing to do
730 return; 667 return;
731 #if SK_SUPPORT_GPU 668 #if SK_SUPPORT_GPU
732 case kNativeGL_BackEndType: 669 case kNativeGL_BackEndType:
733 presentGL(); 670 presentGL();
734 break; 671 break;
735 #if SK_ANGLE 672 #if SK_ANGLE
736 case kANGLE_BackEndType: 673 case kANGLE_BackEndType:
737 presentANGLE(); 674 presentANGLE();
738 break; 675 break;
739 #endif // SK_ANGLE 676 #endif // SK_ANGLE
740 #if SK_COMMAND_BUFFER
741 case kCommandBuffer_BackEndType:
742 presentCommandBuffer();
743 break;
744 #endif // SK_COMMAND_BUFFER
745 #endif // SK_SUPPORT_GPU 677 #endif // SK_SUPPORT_GPU
746 default: 678 default:
747 SkASSERT(false); 679 SkASSERT(false);
748 break; 680 break;
749 } 681 }
750 } 682 }
751 683
752 bool SkOSWindow::makeFullscreen() { 684 bool SkOSWindow::makeFullscreen() {
753 if (fFullscreen) { 685 if (fFullscreen) {
754 return true; 686 return true;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 763 }
832 764
833 void SkOSWindow::closeWindow() { 765 void SkOSWindow::closeWindow() {
834 DestroyWindow((HWND)fHWND); 766 DestroyWindow((HWND)fHWND);
835 if (fFullscreen) { 767 if (fFullscreen) {
836 DestroyWindow((HWND)fSavedWindowState.fHWND); 768 DestroyWindow((HWND)fSavedWindowState.fHWND);
837 } 769 }
838 gHwndToOSWindowMap.remove(fHWND); 770 gHwndToOSWindowMap.remove(fHWND);
839 } 771 }
840 #endif 772 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698