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

Side by Side Diff: gpu/command_buffer/service/gpu_scheduler_linux.cc

Issue 7395020: Create new GLSurface for cross process image transport. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 9 years, 5 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
« no previous file with comments | « gpu/command_buffer/service/gpu_scheduler.cc ('k') | ui/gfx/gl/generate_bindings.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "gpu/command_buffer/service/gpu_scheduler.h" 5 #include "gpu/command_buffer/service/gpu_scheduler.h"
6 #include "ui/gfx/gl/gl_context.h" 6 #include "ui/gfx/gl/gl_context.h"
7 #include "ui/gfx/gl/gl_share_group.h" 7 #include "ui/gfx/gl/gl_share_group.h"
8 #include "ui/gfx/gl/gl_surface.h" 8 #include "ui/gfx/gl/gl_surface.h"
9 9
10 #if defined(TOUCH_UI)
11 #include "third_party/angle/include/EGL/egl.h"
12 #include "third_party/angle/include/EGL/eglext.h"
13 #include "ui/gfx/gl/gl_surface_egl.h"
14 #include "ui/gfx/gl/gl_bindings.h"
15 #endif
16
17 using ::base::SharedMemory; 10 using ::base::SharedMemory;
18 11
19 namespace gpu { 12 namespace gpu {
20 13
21 bool GpuScheduler::Initialize( 14 bool GpuScheduler::Initialize(
22 gfx::PluginWindowHandle window, 15 gfx::PluginWindowHandle window,
23 const gfx::Size& size, 16 const gfx::Size& size,
24 bool software, 17 bool software,
25 const gles2::DisallowedExtensions& disallowed_extensions, 18 const gles2::DisallowedExtensions& disallowed_extensions,
26 const char* allowed_extensions, 19 const char* allowed_extensions,
27 const std::vector<int32>& attribs, 20 const std::vector<int32>& attribs,
28 gfx::GLShareGroup* share_group) { 21 gfx::GLShareGroup* share_group) {
22 #if defined(TOUCH_UI)
23 NOTIMPLEMENTED();
24 return false;
25 #endif
26
29 // Create either a view or pbuffer based GLSurface. 27 // Create either a view or pbuffer based GLSurface.
30 scoped_refptr<gfx::GLSurface> surface; 28 scoped_refptr<gfx::GLSurface> surface;
31 #if defined(TOUCH_UI)
32 surface = gfx::GLSurface::CreateOffscreenGLSurface(software, gfx::Size(1, 1));
33 #else
34 if (window) 29 if (window)
35 surface = gfx::GLSurface::CreateViewGLSurface(software, window); 30 surface = gfx::GLSurface::CreateViewGLSurface(software, window);
36 else 31 else
37 surface = gfx::GLSurface::CreateOffscreenGLSurface(software, 32 surface = gfx::GLSurface::CreateOffscreenGLSurface(software,
38 gfx::Size(1, 1)); 33 gfx::Size(1, 1));
39 #endif
40
41 if (!surface.get()) { 34 if (!surface.get()) {
42 LOG(ERROR) << "GpuScheduler::Initialize failed.\n"; 35 LOG(ERROR) << "GpuScheduler::Initialize failed.\n";
43 Destroy(); 36 Destroy();
44 return false; 37 return false;
45 } 38 }
46 39
47 // Create a GLContext and attach the surface. 40 // Create a GLContext and attach the surface.
48 scoped_refptr<gfx::GLContext> context( 41 scoped_refptr<gfx::GLContext> context(
49 gfx::GLContext::CreateGLContext(share_group, surface.get())); 42 gfx::GLContext::CreateGLContext(share_group, surface.get()));
50 if (!context.get()) { 43 if (!context.get()) {
51 LOG(ERROR) << "CreateGLContext failed.\n"; 44 LOG(ERROR) << "CreateGLContext failed.\n";
52 Destroy(); 45 Destroy();
53 return false; 46 return false;
54 } 47 }
55 48
56 return InitializeCommon(surface, 49 return InitializeCommon(surface,
57 context, 50 context,
58 size, 51 size,
59 disallowed_extensions, 52 disallowed_extensions,
60 allowed_extensions, 53 allowed_extensions,
61 attribs); 54 attribs);
62 } 55 }
63 56
64 void GpuScheduler::Destroy() { 57 void GpuScheduler::Destroy() {
65 DestroyCommon(); 58 DestroyCommon();
66 } 59 }
67 60
68 void GpuScheduler::WillSwapBuffers() { 61 void GpuScheduler::WillSwapBuffers() {
69 #if defined(TOUCH_UI)
70 front_surface_.swap(back_surface_);
71 DCHECK_NE(front_surface_.get(), static_cast<AcceleratedSurface*>(NULL));
72
73 gfx::Size expected_size = front_surface_->size();
74 if (!back_surface_.get() || back_surface_->size() != expected_size) {
75 wrapped_resize_callback_->Run(expected_size);
76 } else {
77 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
78 GL_COLOR_ATTACHMENT0,
79 GL_TEXTURE_2D,
80 back_surface_->texture(),
81 0);
82 }
83 ++swap_buffers_count_;
84 glFlush();
85 #endif
86 if (wrapped_swap_buffers_callback_.get()) { 62 if (wrapped_swap_buffers_callback_.get()) {
87 wrapped_swap_buffers_callback_->Run(); 63 wrapped_swap_buffers_callback_->Run();
88 } 64 }
89 } 65 }
90 66
91 #if defined(TOUCH_UI)
92 uint64 GpuScheduler::GetBackSurfaceId() {
93 if (!back_surface_.get())
94 return 0;
95 return back_surface_->pixmap();
96 }
97
98 uint64 GpuScheduler::GetFrontSurfaceId() {
99 if (!front_surface_.get())
100 return 0;
101 return front_surface_->pixmap();
102 }
103
104 uint64 GpuScheduler::swap_buffers_count() const {
105 return swap_buffers_count_;
106 }
107
108 uint64 GpuScheduler::acknowledged_swap_buffers_count() const {
109 return acknowledged_swap_buffers_count_;
110 }
111
112 void GpuScheduler::set_acknowledged_swap_buffers_count(
113 uint64 acknowledged_swap_buffers_count) {
114 acknowledged_swap_buffers_count_ = acknowledged_swap_buffers_count;
115 }
116
117 void GpuScheduler::CreateBackSurface(const gfx::Size& size) {
118 decoder()->ResizeOffscreenFrameBuffer(size);
119 decoder()->UpdateOffscreenFrameBufferSize();
120
121 back_surface_ = new AcceleratedSurface(size);
122 surfaces_[back_surface_->pixmap()] = back_surface_;
123
124 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
125 GL_COLOR_ATTACHMENT0,
126 GL_TEXTURE_2D,
127 back_surface_->texture(),
128 0);
129 glFlush();
130 }
131
132 void GpuScheduler::ReleaseSurface(uint64 surface_id) {
133 DCHECK_NE(surfaces_[surface_id].get(), back_surface_.get());
134 DCHECK_NE(surfaces_[surface_id].get(), front_surface_.get());
135 surfaces_.erase(surface_id);
136 }
137
138 #endif
139
140 } // namespace gpu 67 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_scheduler.cc ('k') | ui/gfx/gl/generate_bindings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698