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

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

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2014 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.h"
6
7 #include "base/macros.h"
8 #include "content/common/gpu/pass_through_image_transport_surface.h"
9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gl/gl_surface_osmesa.h"
11
12 namespace content {
13
14 scoped_refptr<gfx::GLSurface> ImageTransportSurfaceCreateNativeSurface(
15 GpuChannelManager* manager,
16 GpuCommandBufferStub* stub,
17 gpu::SurfaceHandle handle);
18
19 namespace {
20
21 // A subclass of GLSurfaceOSMesa that doesn't print an error message when
22 // SwapBuffers() is called.
23 class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa {
24 public:
25 // Size doesn't matter, the surface is resized to the right size later.
26 DRTSurfaceOSMesa()
27 : GLSurfaceOSMesa(gfx::GLSurface::SURFACE_OSMESA_RGBA, gfx::Size(1, 1)) {}
28
29 // Implement a subset of GLSurface.
30 gfx::SwapResult SwapBuffers() override;
31
32 private:
33 ~DRTSurfaceOSMesa() override {}
34 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa);
35 };
36
37 gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers() {
38 return gfx::SwapResult::SWAP_ACK;
39 }
40
41 bool g_allow_os_mesa = false;
42
43 } // namespace
44
45 // static
46 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
47 GpuChannelManager* manager,
48 GpuCommandBufferStub* stub,
49 gpu::SurfaceHandle surface_handle,
50 gfx::GLSurface::Format format) {
51 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle);
52
53 switch (gfx::GetGLImplementation()) {
54 case gfx::kGLImplementationDesktopGL:
55 case gfx::kGLImplementationDesktopGLCoreProfile:
56 case gfx::kGLImplementationAppleGL:
57 return ImageTransportSurfaceCreateNativeSurface(manager, stub,
58 surface_handle);
59 default:
60 // Content shell in DRT mode spins up a gpu process which needs an
61 // image transport surface, but that surface isn't used to read pixel
62 // baselines. So this is mostly a dummy surface.
63 if (!g_allow_os_mesa) {
64 NOTREACHED();
65 return nullptr;
66 }
67 scoped_refptr<gfx::GLSurface> surface(new DRTSurfaceOSMesa());
68 if (!surface.get() || !surface->Initialize(format))
69 return surface;
70 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface(
71 manager, stub, surface.get()));
72 }
73 }
74
75 // static
76 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) {
77 g_allow_os_mesa = allow;
78 }
79
80 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_linux.cc ('k') | content/common/gpu/image_transport_surface_overlay_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698