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

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
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 const gles2::DisallowedExtensions& disallowed_extensions, 17 const gles2::DisallowedExtensions& disallowed_extensions,
25 const char* allowed_extensions, 18 const char* allowed_extensions,
26 const std::vector<int32>& attribs, 19 const std::vector<int32>& attribs,
27 gfx::GLShareGroup* share_group) { 20 gfx::GLShareGroup* share_group) {
21 #if defined(TOUCH_UI)
22 NOTIMPLEMENTED();
23 return false;
24 #endif
25
28 // Create either a view or pbuffer based GLSurface. 26 // Create either a view or pbuffer based GLSurface.
29 scoped_refptr<gfx::GLSurface> surface; 27 scoped_refptr<gfx::GLSurface> surface;
30 #if defined(TOUCH_UI)
31 surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
32 #else
33 if (window) 28 if (window)
34 surface = gfx::GLSurface::CreateViewGLSurface(window); 29 surface = gfx::GLSurface::CreateViewGLSurface(window);
35 else 30 else
36 surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); 31 surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
37 #endif
38 32
39 if (!surface.get()) { 33 if (!surface.get()) {
40 LOG(ERROR) << "GpuScheduler::Initialize failed.\n"; 34 LOG(ERROR) << "GpuScheduler::Initialize failed.\n";
41 Destroy(); 35 Destroy();
42 return false; 36 return false;
43 } 37 }
44 38
45 // Create a GLContext and attach the surface. 39 // Create a GLContext and attach the surface.
46 scoped_refptr<gfx::GLContext> context( 40 scoped_refptr<gfx::GLContext> context(
47 gfx::GLContext::CreateGLContext(share_group, surface.get())); 41 gfx::GLContext::CreateGLContext(share_group, surface.get()));
48 if (!context.get()) { 42 if (!context.get()) {
49 LOG(ERROR) << "CreateGLContext failed.\n"; 43 LOG(ERROR) << "CreateGLContext failed.\n";
50 Destroy(); 44 Destroy();
51 return false; 45 return false;
52 } 46 }
53 47
54 return InitializeCommon(surface, 48 return InitializeCommon(surface,
55 context, 49 context,
56 size, 50 size,
57 disallowed_extensions, 51 disallowed_extensions,
58 allowed_extensions, 52 allowed_extensions,
59 attribs); 53 attribs);
60 } 54 }
61 55
62 void GpuScheduler::Destroy() { 56 void GpuScheduler::Destroy() {
63 DestroyCommon(); 57 DestroyCommon();
64 } 58 }
65 59
66 void GpuScheduler::WillSwapBuffers() { 60 void GpuScheduler::WillSwapBuffers() {
67 #if defined(TOUCH_UI)
68 front_surface_.swap(back_surface_);
69 DCHECK_NE(front_surface_.get(), static_cast<AcceleratedSurface*>(NULL));
70
71 gfx::Size expected_size = front_surface_->size();
72 if (!back_surface_.get() || back_surface_->size() != expected_size) {
73 wrapped_resize_callback_->Run(expected_size);
74 } else {
75 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
76 GL_COLOR_ATTACHMENT0,
77 GL_TEXTURE_2D,
78 back_surface_->texture(),
79 0);
80 }
81 ++swap_buffers_count_;
82 glFlush();
83 #endif
84 if (wrapped_swap_buffers_callback_.get()) { 61 if (wrapped_swap_buffers_callback_.get()) {
85 wrapped_swap_buffers_callback_->Run(); 62 wrapped_swap_buffers_callback_->Run();
86 } 63 }
87 } 64 }
88 65
89 #if defined(TOUCH_UI)
90 uint64 GpuScheduler::GetBackSurfaceId() {
91 if (!back_surface_.get())
92 return 0;
93 return back_surface_->pixmap();
94 }
95
96 uint64 GpuScheduler::GetFrontSurfaceId() {
97 if (!front_surface_.get())
98 return 0;
99 return front_surface_->pixmap();
100 }
101
102 uint64 GpuScheduler::swap_buffers_count() const {
103 return swap_buffers_count_;
104 }
105
106 uint64 GpuScheduler::acknowledged_swap_buffers_count() const {
107 return acknowledged_swap_buffers_count_;
108 }
109
110 void GpuScheduler::set_acknowledged_swap_buffers_count(
111 uint64 acknowledged_swap_buffers_count) {
112 acknowledged_swap_buffers_count_ = acknowledged_swap_buffers_count;
113 }
114
115 void GpuScheduler::CreateBackSurface(const gfx::Size& size) {
116 decoder()->ResizeOffscreenFrameBuffer(size);
117 decoder()->UpdateOffscreenFrameBufferSize();
118
119 back_surface_ = new AcceleratedSurface(size);
120 surfaces_[back_surface_->pixmap()] = back_surface_;
121
122 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
123 GL_COLOR_ATTACHMENT0,
124 GL_TEXTURE_2D,
125 back_surface_->texture(),
126 0);
127 glFlush();
128 }
129
130 void GpuScheduler::ReleaseSurface(uint64 surface_id) {
131 DCHECK_NE(surfaces_[surface_id].get(), back_surface_.get());
132 DCHECK_NE(surfaces_[surface_id].get(), front_surface_.get());
133 surfaces_.erase(surface_id);
134 }
135
136 #endif
137
138 } // namespace gpu 66 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698