OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_GPU_GPU_BACKING_STORE_GLX_CONTEXT_H_ | |
6 #define CHROME_GPU_GPU_BACKING_STORE_GLX_CONTEXT_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "chrome/gpu/x_util.h" | |
11 #include "gfx/size.h" | |
12 | |
13 class GpuThread; | |
14 | |
15 | |
16 class GpuBackingStoreGLXContext { | |
17 public: | |
18 explicit GpuBackingStoreGLXContext(GpuThread* gpu_thread); | |
19 ~GpuBackingStoreGLXContext(); | |
20 | |
21 // Returns the context, creating it if necessary, and binding it to the given | |
22 // display and window identified by the XID. This will avoid duplicate calls | |
23 // to MakeCurrent if the display/XID hasn't changed from the last call. | |
24 // Returns NULL on failure. | |
25 GLXContext BindContext(XID window_id); | |
26 | |
27 bool BindTextureForScrolling(XID window_id, | |
28 const gfx::Size& size); | |
29 | |
30 unsigned int SwapTextureForScrolling(unsigned int old_texture, | |
31 const gfx::Size& old_size); | |
32 | |
33 private: | |
34 GpuThread* gpu_thread_; | |
35 | |
36 // Set to true when we've tried to create the context. This prevents us from | |
37 // trying to initialize the OpenGL context over and over in the failure case. | |
38 bool tried_to_init_; | |
39 | |
40 // The OpenGL context. Non-NULL when initialized. | |
41 GLXContext context_; | |
42 | |
43 // The last window we've bound our context to. This allows us to avoid | |
44 // duplicate "MakeCurrent" calls which are expensive. | |
45 XID previous_window_id_; | |
46 | |
47 // The frame buffer object we use to render scrolled images into. We'll set | |
48 // is_frame_buffer_bound_ when the FBO is bound so we can perform some checks | |
49 // to make sure we're not forgetting to unbind it. | |
50 unsigned int frame_buffer_for_scrolling_; | |
51 bool is_frame_buffer_bound_; | |
52 | |
53 // The temporary texture we use for scrolling. The ID will be 0 if it is | |
54 // uninitialized. Otherwise, this will give the ID and size of an existing | |
55 // texture that can be re-used for a temporary buffer for scrolling. | |
56 unsigned int temp_scroll_texture_id_; | |
57 gfx::Size temp_scroll_texture_size_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(GpuBackingStoreGLXContext); | |
60 }; | |
61 | |
62 #endif // CHROME_GPU_GPU_BACKING_STORE_GLX_CONTEXT_H_ | |
OLD | NEW |