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

Side by Side Diff: gpu/command_buffer/service/x_utils.h

Issue 1540004: Implemented offscreen rendering path for GLES2CmdDecoder on Linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file declares the XWindowWrapper class. 5 // This file declares the XWindowWrapper class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "gpu/command_buffer/common/logging.h" 11 #include "gpu/command_buffer/common/logging.h"
12 #include "gpu/command_buffer/service/gl_utils.h" 12 #include "gpu/command_buffer/service/gl_utils.h"
13 13
14 namespace gpu { 14 namespace gpu {
15 15
16 // Abstracts between on-screen and off-screen GLX contexts.
17 class GLXContextWrapper {
18 public:
19 explicit GLXContextWrapper(Display* display)
20 : display_(display),
21 context_(NULL) {
22 DCHECK(display_);
23 }
24
25 virtual ~GLXContextWrapper();
26
27 // Initializes the GL context. Subclasses should perform their
28 // initialization work and then call the superclass implementation.
29 virtual bool Initialize();
30
31 // Destroys the GL context. Subclasses may call this before or after
32 // doing any necessary cleanup work.
33 virtual void Destroy();
34
35 // Makes the GL context current on the current thread.
36 virtual bool MakeCurrent() = 0;
37
38 // Returns true if this context is offscreen.
39 virtual bool IsOffscreen() = 0;
40
41 // Swaps front and back buffers. This has no effect for off-screen
42 // contexts.
43 virtual void SwapBuffers() = 0;
44
45 // Fetches the GLX context for sharing of server-side objects.
46 GLXContext GetContext() {
47 return context_;
48 }
49
50 protected:
51 Display* GetDisplay() {
52 return display_;
53 }
54
55 void SetContext(GLXContext context) {
56 context_ = context;
57 }
58
59 private:
60 Display* display_;
61 GLXContext context_;
62
63 DISALLOW_COPY_AND_ASSIGN(GLXContextWrapper);
64 };
65
16 // This class is a wrapper around an X Window and associated GL context. It is 66 // This class is a wrapper around an X Window and associated GL context. It is
17 // useful to isolate intrusive X headers, since it can be forward declared 67 // useful to isolate intrusive X headers, since it can be forward declared
18 // (Window and GLXContext can't). 68 // (Window and GLXContext can't).
19 class XWindowWrapper { 69 class XWindowWrapper : public GLXContextWrapper {
20 public: 70 public:
21 XWindowWrapper(Display *display, Window window) 71 XWindowWrapper(Display *display, Window window)
22 : display_(display), 72 : GLXContextWrapper(display),
23 window_(window) { 73 window_(window) {
24 DCHECK(display_);
25 DCHECK(window_); 74 DCHECK(window_);
26 } 75 }
27 // Initializes the GL context.
28 bool Initialize();
29 76
30 // Destroys the GL context. 77 virtual bool Initialize();
31 void Destroy(); 78 virtual bool MakeCurrent();
32 79 virtual bool IsOffscreen();
33 // Makes the GL context current on the current thread. 80 virtual void SwapBuffers();
34 bool MakeCurrent();
35
36 // Swaps front and back buffers.
37 void SwapBuffers();
38 81
39 private: 82 private:
40 Display *display_;
41 Window window_; 83 Window window_;
42 GLXContext context_;
43 DISALLOW_COPY_AND_ASSIGN(XWindowWrapper); 84 DISALLOW_COPY_AND_ASSIGN(XWindowWrapper);
44 }; 85 };
45 86
87 // This class is a wrapper around a GLX pbuffer and associated GL context. It
88 // serves the same purpose as the XWindowWrapper for initializing off-screen
89 // rendering.
90 class GLXPbufferWrapper : public GLXContextWrapper {
91 public:
92 explicit GLXPbufferWrapper(Display* display)
93 : GLXContextWrapper(display) {
94 }
95
96 virtual bool Initialize();
97 virtual void Destroy();
98 virtual bool MakeCurrent();
99 virtual bool IsOffscreen();
100 virtual void SwapBuffers();
101
102 private:
103 GLXPbuffer pbuffer_;
104 DISALLOW_COPY_AND_ASSIGN(GLXPbufferWrapper);
105 };
106
46 } // namespace gpu 107 } // namespace gpu
47 108
48 #endif // GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ 109 #endif // GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_processor_linux.cc ('k') | gpu/command_buffer/service/x_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698