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

Side by Side Diff: content/common/gpu/image_transport_surface_mac.mm

Issue 334173006: Clean up GLSurfaceCGL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 6 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
« no previous file with comments | « content/common/gpu/image_transport_surface_mac.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #include "content/common/gpu/image_transport_surface_fbo_mac.h"
6
7 #include "content/common/gpu/gpu_messages.h"
8 #include "content/common/gpu/image_transport_surface_iosurface_mac.h"
9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gl/gl_context.h"
11 #include "ui/gl/gl_implementation.h"
12 #include "ui/gl/gl_surface_osmesa.h"
13
14 namespace content {
15 namespace {
16
17 // A subclass of GLSurfaceOSMesa that doesn't print an error message when
18 // SwapBuffers() is called.
19 class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa {
20 public:
21 // Size doesn't matter, the surface is resized to the right size later.
22 DRTSurfaceOSMesa() : GLSurfaceOSMesa(GL_RGBA, gfx::Size(1, 1)) {}
23
24 // Implement a subset of GLSurface.
25 virtual bool SwapBuffers() OVERRIDE;
26
27 private:
28 virtual ~DRTSurfaceOSMesa() {}
29 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa);
30 };
31
32 bool DRTSurfaceOSMesa::SwapBuffers() {
33 return true;
34 }
35
36 bool g_allow_os_mesa = false;
37
38 } // namespace
39
40 // static
41 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
42 GpuChannelManager* manager,
43 GpuCommandBufferStub* stub,
44 const gfx::GLSurfaceHandle& surface_handle) {
45 DCHECK(surface_handle.transport_type == gfx::NATIVE_DIRECT ||
46 surface_handle.transport_type == gfx::NATIVE_TRANSPORT);
47
48 switch (gfx::GetGLImplementation()) {
49 case gfx::kGLImplementationDesktopGL:
50 case gfx::kGLImplementationAppleGL:
51 return scoped_refptr<gfx::GLSurface>(new ImageTransportSurfaceFBO(
52 new IOSurfaceStorageProvider, manager, stub, surface_handle.handle));
53 default:
54 // Content shell in DRT mode spins up a gpu process which needs an
55 // image transport surface, but that surface isn't used to read pixel
56 // baselines. So this is mostly a dummy surface.
57 if (!g_allow_os_mesa) {
58 NOTREACHED();
59 return scoped_refptr<gfx::GLSurface>();
60 }
61 scoped_refptr<gfx::GLSurface> surface(new DRTSurfaceOSMesa());
62 if (!surface.get() || !surface->Initialize())
63 return surface;
64 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface(
65 manager, stub, surface.get()));
66 }
67 }
68
69 // static
70 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) {
71 g_allow_os_mesa = allow;
72 }
73
74 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_mac.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698