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

Side by Side Diff: tools/viewer/sk_app/unix/Window_unix.h

Issue 2011473003: Add OpenGL support to Linux viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Repatched the patch 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 7
8 #ifndef Window_unix_DEFINED 8 #ifndef Window_unix_DEFINED
9 #define Window_unix_DEFINED 9 #define Window_unix_DEFINED
10 10
11 #include <X11/Xlib.h> 11 #include <X11/Xlib.h>
12 #include <GL/glx.h>
12 #include "../Window.h" 13 #include "../Window.h"
13 #include "SkChecksum.h" 14 #include "SkChecksum.h"
14 #include "SkTDynamicHash.h" 15 #include "SkTDynamicHash.h"
15 16
16 typedef Window XWindow; 17 typedef Window XWindow;
17 18
18 namespace sk_app { 19 namespace sk_app {
19 20
20 struct ContextPlatformData_unix { 21 struct ContextPlatformData_unix {
21 Display* fDisplay; 22 Display* fDisplay;
22 XWindow fHWnd; 23 XWindow fWindow;
23 VisualID fVisualID; 24 XVisualInfo* fVisualInfo;
24 }; 25 };
25 26
26 class Window_unix : public Window { 27 class Window_unix : public Window {
27 public: 28 public:
28 Window_unix() : Window() {} 29 Window_unix() : Window()
29 ~Window_unix() override {} 30 , fDisplay(nullptr)
31 , fWindow(0)
32 , fGC(nullptr)
33 , fVisualInfo(nullptr)
34 , fMSAASampleCount(0) {}
35 ~Window_unix() override { this->closeWindow(); }
30 36
31 bool init(Display* display); 37 bool initWindow(Display* display, const DisplayParams* params);
32 38
33 void setTitle(const char*) override; 39 void setTitle(const char*) override;
34 void show() override; 40 void show() override;
35 41
36 bool attach(BackendType attachType, const DisplayParams& params) override; 42 bool attach(BackendType attachType, const DisplayParams& params) override;
37 43
38 void onInval() override; 44 void onInval() override;
39 45
40 bool handleEvent(const XEvent& event); 46 bool handleEvent(const XEvent& event);
41 47
42 static const XWindow& GetKey(const Window_unix& w) { 48 static const XWindow& GetKey(const Window_unix& w) {
43 return w.fHWnd; 49 return w.fWindow;
44 } 50 }
45 51
46 static uint32_t Hash(const XWindow& w) { 52 static uint32_t Hash(const XWindow& w) {
47 return SkChecksum::Mix(w); 53 return SkChecksum::Mix(w);
48 } 54 }
49 55
50 static SkTDynamicHash<Window_unix, XWindow> gWindowMap; 56 static SkTDynamicHash<Window_unix, XWindow> gWindowMap;
51 57
52 void markPendingPaint() { fPendingPaint = true; } 58 void markPendingPaint() { fPendingPaint = true; }
53 void finishPaint() { 59 void finishPaint() {
54 if (fPendingPaint) { 60 if (fPendingPaint) {
55 this->onPaint(); 61 this->onPaint();
56 fPendingPaint = false; 62 fPendingPaint = false;
57 } 63 }
58 } 64 }
59 65
60 void markPendingResize(int width, int height) { 66 void markPendingResize(int width, int height) {
61 fPendingWidth = width; 67 fPendingWidth = width;
62 fPendingHeight = height; 68 fPendingHeight = height;
63 fPendingResize = true; 69 fPendingResize = true;
64 } 70 }
65 void finishResize() { 71 void finishResize() {
66 if (fPendingResize) { 72 if (fPendingResize) {
67 this->onResize(fPendingWidth, fPendingHeight); 73 this->onResize(fPendingWidth, fPendingHeight);
68 fPendingResize = false; 74 fPendingResize = false;
69 } 75 }
70 } 76 }
71 77
72 private: 78 private:
73 Display* fDisplay; 79 void closeWindow();
74 XWindow fHWnd; 80
81 Display* fDisplay;
82 XWindow fWindow;
83 GC fGC;
84 XVisualInfo* fVisualInfo;
85 int fMSAASampleCount;
75 86
76 Atom fWmDeleteMessage; 87 Atom fWmDeleteMessage;
77 88
78 bool fPendingPaint; 89 bool fPendingPaint;
79 int fPendingWidth; 90 int fPendingWidth;
80 int fPendingHeight; 91 int fPendingHeight;
81 bool fPendingResize; 92 bool fPendingResize;
82 }; 93 };
83 94
84 } // namespace sk_app 95 } // namespace sk_app
85 96
86 #endif 97 #endif
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp ('k') | tools/viewer/sk_app/unix/Window_unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698