1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if defined(ENABLE_GPU)
#include "content/common/gpu/image_transport_surface.h"
// This conflicts with the defines in Xlib.h and must come first.
#include "content/common/gpu/gpu_messages.h"
#include <map>
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
#include "base/callback.h"
#include "base/debug/trace_event.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "third_party/angle/include/EGL/egl.h"
#include "third_party/angle/include/EGL/eglext.h"
#include "third_party/mesa/MesaLib/include/GL/osmesa.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface_egl.h"
#include "ui/gfx/gl/gl_surface_glx.h"
#include "ui/gfx/gl/gl_surface_osmesa.h"
namespace {
// The GL context associated with the surface must be current when
// an instance is created or destroyed.
class EGLAcceleratedSurface : public base::RefCounted<EGLAcceleratedSurface> {
public:
EGLAcceleratedSurface(const gfx::Size& size);
const gfx::Size& size() const { return size_; }
uint32 pixmap() const { return pixmap_; }
uint32 texture() const { return texture_; }
private:
~EGLAcceleratedSurface();
gfx::Size size_;
void* image_;
uint32 pixmap_;
uint32 texture_;
friend class base::RefCounted<EGLAcceleratedSurface>;
DISALLOW_COPY_AND_ASSIGN(EGLAcceleratedSurface);
};
// We are backed by an Pbuffer offscreen surface for the purposes of creating a
// context, but use FBOs to render to X Pixmap backed EGLImages.
class EGLImageTransportSurface : public ImageTransportSurface,
public gfx::PbufferGLSurfaceEGL {
public:
EGLImageTransportSurface(GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id);
// GLSurface implementation
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool IsOffscreen() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE;
protected:
// ImageTransportSurface implementation
virtual void OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
virtual void OnBuffersSwappedACK() OVERRIDE;
virtual void OnResize(gfx::Size size) OVERRIDE;
private:
virtual ~EGLImageTransportSurface() OVERRIDE;
void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface);
uint32 fbo_id_;
scoped_refptr<EGLAcceleratedSurface> back_surface_;
scoped_refptr<EGLAcceleratedSurface> front_surface_;
// Whether or not we've successfully made the surface current once.
bool made_current_;
scoped_ptr<ImageTransportHelper> helper_;
DISALLOW_COPY_AND_ASSIGN(EGLImageTransportSurface);
};
// We render to an off-screen (but mapped) window that the browser process will
// read from via XComposite
class GLXImageTransportSurface : public ImageTransportSurface,
public gfx::NativeViewGLSurfaceGLX {
public:
GLXImageTransportSurface(GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id);
// gfx::GLSurface implementation:
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE;
protected:
// ImageTransportSurface implementation:
virtual void OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
virtual void OnBuffersSwappedACK() OVERRIDE;
virtual void OnResize(gfx::Size size) OVERRIDE;
private:
virtual ~GLXImageTransportSurface();
// Tell the browser to release the surface.
void ReleaseSurface();
XID dummy_parent_;
gfx::Size size_;
// Whether or not the image has been bound on the browser side.
bool bound_;
// Whether or not we need to send a resize on the next swap.
bool needs_resize_;
// Whether or not we've successfully made the surface current once.
bool made_current_;
scoped_ptr<ImageTransportHelper> helper_;
DISALLOW_COPY_AND_ASSIGN(GLXImageTransportSurface);
};
// We render to a hunk of shared memory that we get from the browser.
// Swapping buffers simply means telling the browser to read the contents
// of the memory.
class OSMesaImageTransportSurface : public ImageTransportSurface,
public gfx::GLSurfaceOSMesa {
public:
OSMesaImageTransportSurface(GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id);
// gfx::GLSurface implementation:
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool IsOffscreen() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
protected:
// ImageTransportSurface implementation:
virtual void OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
virtual void OnBuffersSwappedACK() OVERRIDE;
virtual void OnResize(gfx::Size size) OVERRIDE;
private:
virtual ~OSMesaImageTransportSurface();
// Tell the browser to release the surface.
void ReleaseSurface();
scoped_ptr<TransportDIB> shared_mem_;
uint32 shared_id_;
gfx::Size size_;
scoped_ptr<ImageTransportHelper> helper_;
DISALLOW_COPY_AND_ASSIGN(OSMesaImageTransportSurface);
};
EGLAcceleratedSurface::EGLAcceleratedSurface(const gfx::Size& size)
: size_(size), texture_(0) {
Display* dpy = gfx::GLSurfaceEGL::GetNativeDisplay();
EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay();
XID window = XDefaultRootWindow(dpy);
XWindowAttributes gwa;
XGetWindowAttributes(dpy, window, &gwa);
pixmap_ = XCreatePixmap(
dpy, window, size_.width(), size_.height(), gwa.depth);
image_ = eglCreateImageKHR(
edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
reinterpret_cast<void*>(pixmap_), NULL);
glGenTextures(1, &texture_);
GLint current_texture = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
glBindTexture(GL_TEXTURE_2D, texture_);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_);
glBindTexture(GL_TEXTURE_2D, current_texture);
}
EGLAcceleratedSurface::~EGLAcceleratedSurface() {
glDeleteTextures(1, &texture_);
eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_);
XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_);
}
EGLImageTransportSurface::EGLImageTransportSurface(
GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id)
: gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)),
fbo_id_(0),
made_current_(false) {
helper_.reset(new ImageTransportHelper(this,
manager,
render_view_id,
renderer_id,
command_buffer_id,
gfx::kNullPluginWindow));
}
EGLImageTransportSurface::~EGLImageTransportSurface() {
Destroy();
}
bool EGLImageTransportSurface::Initialize() {
if (!helper_->Initialize())
return false;
return PbufferGLSurfaceEGL::Initialize();
}
void EGLImageTransportSurface::Destroy() {
if (back_surface_.get())
ReleaseSurface(&back_surface_);
if (front_surface_.get())
ReleaseSurface(&front_surface_);
helper_->Destroy();
PbufferGLSurfaceEGL::Destroy();
}
// Make sure that buffer swaps occur for the surface, so we can send the data
// to the actual onscreen surface in the browser
bool EGLImageTransportSurface::IsOffscreen() {
return false;
}
bool EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
if (made_current_)
return true;
if (!context->HasExtension("EGL_KHR_image") &&
!context->HasExtension("EGL_KHR_image_pixmap")) {
DLOG(ERROR) << "EGLImage from X11 pixmap not supported";
return false;
}
glGenFramebuffersEXT(1, &fbo_id_);
glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_id_);
OnResize(gfx::Size(1, 1));
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
DLOG(ERROR) << "Framebuffer incomplete.";
return false;
}
made_current_ = true;
return true;
}
unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() {
return fbo_id_;
}
void EGLImageTransportSurface::SetVisible(bool visible) {
if (!visible && back_surface_.get() && front_surface_.get()) {
ReleaseSurface(&back_surface_);
} else if (visible && !back_surface_.get() && front_surface_.get()) {
// Leverage the OnResize hook because it does exactly what we want
OnResize(front_surface_->size());
}
}
void EGLImageTransportSurface::ReleaseSurface(
scoped_refptr<EGLAcceleratedSurface>* surface) {
if (surface->get()) {
GpuHostMsg_AcceleratedSurfaceRelease_Params params;
params.identifier = (*surface)->pixmap();
helper_->SendAcceleratedSurfaceRelease(params);
*surface = NULL;
}
}
void EGLImageTransportSurface::OnResize(gfx::Size size) {
if (back_surface_.get())
ReleaseSurface(&back_surface_);
back_surface_ = new EGLAcceleratedSurface(size);
GLint previous_fbo_id = 0;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previous_fbo_id);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
back_surface_->texture(),
0);
glFlush();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id);
GpuHostMsg_AcceleratedSurfaceNew_Params params;
params.width = size.width();
params.height = size.height();
params.surface_id = back_surface_->pixmap();
helper_->SendAcceleratedSurfaceNew(params);
helper_->SetScheduled(false);
}
bool EGLImageTransportSurface::SwapBuffers() {
front_surface_.swap(back_surface_);
DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL));
glFlush();
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_id = front_surface_->pixmap();
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
gfx::Size expected_size = front_surface_->size();
if (!back_surface_.get() || back_surface_->size() != expected_size) {
OnResize(expected_size);
} else {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
back_surface_->texture(),
0);
}
helper_->SetScheduled(false);
return true;
}
gfx::Size EGLImageTransportSurface::GetSize() {
return back_surface_->size();
}
void EGLImageTransportSurface::OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
DCHECK_EQ(back_surface_->pixmap(), surface_id);
helper_->SetScheduled(true);
}
void EGLImageTransportSurface::OnBuffersSwappedACK() {
helper_->SetScheduled(true);
}
GLXImageTransportSurface::GLXImageTransportSurface(
GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id)
: gfx::NativeViewGLSurfaceGLX(),
dummy_parent_(0),
size_(1, 1),
bound_(false),
needs_resize_(false),
made_current_(false) {
helper_.reset(new ImageTransportHelper(this,
manager,
render_view_id,
renderer_id,
command_buffer_id,
gfx::kNullPluginWindow));
}
GLXImageTransportSurface::~GLXImageTransportSurface() {
Destroy();
}
bool GLXImageTransportSurface::Initialize() {
// Create a dummy window to host the real window.
Display* dpy = static_cast<Display*>(GetDisplay());
XSetWindowAttributes swa;
swa.event_mask = StructureNotifyMask;
swa.override_redirect = True;
dummy_parent_ = XCreateWindow(
dpy,
RootWindow(dpy, DefaultScreen(dpy)), // parent
-100, -100, 1, 1,
0, // border width
CopyFromParent, // depth
InputOutput,
CopyFromParent, // visual
CWEventMask | CWOverrideRedirect, &swa);
XMapWindow(dpy, dummy_parent_);
swa.event_mask = StructureNotifyMask;
swa.override_redirect = false;
window_ = XCreateWindow(dpy,
dummy_parent_,
0, 0, size_.width(), size_.height(),
0, // border width
CopyFromParent, // depth
InputOutput,
CopyFromParent, // visual
CWEventMask, &swa);
XMapWindow(dpy, window_);
while (1) {
XEvent event;
XNextEvent(dpy, &event);
if (event.type == MapNotify && event.xmap.window == window_)
break;
}
// Manual setting must be used to avoid unnecessary rendering by server.
XCompositeRedirectWindow(dpy, window_, CompositeRedirectManual);
OnResize(size_);
if (!helper_->Initialize())
return false;
return gfx::NativeViewGLSurfaceGLX::Initialize();
}
void GLXImageTransportSurface::Destroy() {
if (bound_)
ReleaseSurface();
if (window_) {
Display* dpy = static_cast<Display*>(GetDisplay());
XDestroyWindow(dpy, window_);
XDestroyWindow(dpy, dummy_parent_);
}
helper_->Destroy();
gfx::NativeViewGLSurfaceGLX::Destroy();
}
void GLXImageTransportSurface::ReleaseSurface() {
DCHECK(bound_);
GpuHostMsg_AcceleratedSurfaceRelease_Params params;
params.identifier = window_;
helper_->SendAcceleratedSurfaceRelease(params);
bound_ = false;
}
void GLXImageTransportSurface::SetVisible(bool visible) {
Display* dpy = static_cast<Display*>(GetDisplay());
if (!visible) {
XResizeWindow(dpy, window_, 1, 1);
} else {
XResizeWindow(dpy, window_, size_.width(), size_.height());
needs_resize_ = true;
}
glXWaitX();
}
void GLXImageTransportSurface::OnResize(gfx::Size size) {
TRACE_EVENT0("gpu", "GLXImageTransportSurface::OnResize");
size_ = size;
Display* dpy = static_cast<Display*>(GetDisplay());
XResizeWindow(dpy, window_, size_.width(), size_.height());
glXWaitX();
needs_resize_ = true;
}
bool GLXImageTransportSurface::SwapBuffers() {
gfx::NativeViewGLSurfaceGLX::SwapBuffers();
glFlush();
if (needs_resize_) {
GpuHostMsg_AcceleratedSurfaceNew_Params params;
params.width = size_.width();
params.height = size_.height();
params.surface_id = window_;
helper_->SendAcceleratedSurfaceNew(params);
bound_ = true;
needs_resize_ = false;
}
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_id = window_;
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
helper_->SetScheduled(false);
return true;
}
gfx::Size GLXImageTransportSurface::GetSize() {
return size_;
}
bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
if (made_current_)
return true;
// Check for driver support.
Display* dpy = static_cast<Display*>(GetDisplay());
int event_base, error_base;
if (XCompositeQueryExtension(dpy, &event_base, &error_base)) {
int major = 0, minor = 2;
XCompositeQueryVersion(dpy, &major, &minor);
if (major == 0 && minor < 2) {
DLOG(ERROR) << "Pixmap from window not supported.";
return false;
}
}
context->SetSwapInterval(0);
made_current_ = true;
return true;
}
void GLXImageTransportSurface::OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
}
void GLXImageTransportSurface::OnBuffersSwappedACK() {
helper_->SetScheduled(true);
}
OSMesaImageTransportSurface::OSMesaImageTransportSurface(
GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id)
: gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)),
size_(gfx::Size(1, 1)) {
helper_.reset(new ImageTransportHelper(this,
manager,
render_view_id,
renderer_id,
command_buffer_id,
gfx::kNullPluginWindow));
}
OSMesaImageTransportSurface::~OSMesaImageTransportSurface() {
Destroy();
}
bool OSMesaImageTransportSurface::Initialize() {
if (!helper_->Initialize())
return false;
return gfx::GLSurfaceOSMesa::Initialize();
}
void OSMesaImageTransportSurface::Destroy() {
if (shared_mem_.get())
ReleaseSurface();
helper_->Destroy();
gfx::GLSurfaceOSMesa::Destroy();
}
// Make sure that buffer swaps occur for the surface, so we can send the data
// to the actual onscreen surface in the browser
bool OSMesaImageTransportSurface::IsOffscreen() {
return false;
}
void OSMesaImageTransportSurface::ReleaseSurface() {
GpuHostMsg_AcceleratedSurfaceRelease_Params params;
params.identifier = shared_id_;
helper_->SendAcceleratedSurfaceRelease(params);
shared_mem_.reset();
shared_id_ = 0;
}
void OSMesaImageTransportSurface::OnResize(gfx::Size size) {
if (shared_mem_.get())
ReleaseSurface();
GLSurfaceOSMesa::Resize(size);
// Now that we resized/reallocated the memory buffer, we need to change
// what OSMesa is pointing at to the new buffer.
helper_->MakeCurrent();
size_ = size;
GpuHostMsg_AcceleratedSurfaceNew_Params params;
params.width = size_.width();
params.height = size_.height();
params.surface_id = 0; // id comes from the browser with the shared mem
helper_->SendAcceleratedSurfaceNew(params);
helper_->SetScheduled(false);
}
void OSMesaImageTransportSurface::OnNewSurfaceACK(
uint64 surface_id, TransportDIB::Handle surface_handle) {
shared_id_ = surface_id;
shared_mem_.reset(TransportDIB::Map(surface_handle));
DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
helper_->SetScheduled(true);
}
bool OSMesaImageTransportSurface::SwapBuffers() {
DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
// Copy the OSMesa buffer to the shared memory
glFinish();
memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4);
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_id = shared_id_;
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
helper_->SetScheduled(false);
return true;
}
void OSMesaImageTransportSurface::OnBuffersSwappedACK() {
helper_->SetScheduled(true);
}
gfx::Size OSMesaImageTransportSurface::GetSize() {
return size_;
}
} // namespace
// static
scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
GpuChannelManager* manager,
int32 render_view_id,
int32 renderer_id,
int32 command_buffer_id,
gfx::PluginWindowHandle /* handle */) {
scoped_refptr<gfx::GLSurface> surface;
switch (gfx::GetGLImplementation()) {
case gfx::kGLImplementationDesktopGL:
surface = new GLXImageTransportSurface(manager,
render_view_id,
renderer_id,
command_buffer_id);
break;
case gfx::kGLImplementationEGLGLES2:
surface = new EGLImageTransportSurface(manager,
render_view_id,
renderer_id,
command_buffer_id);
break;
case gfx::kGLImplementationOSMesaGL:
surface = new OSMesaImageTransportSurface(manager,
render_view_id,
renderer_id,
command_buffer_id);
break;
default:
NOTREACHED();
return NULL;
}
if (surface->Initialize())
return surface;
else
return NULL;
}
#endif // defined(USE_GPU)
|