| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ipc/service/image_transport_surface.h" | 5 #include "gpu/ipc/service/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" | 8 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" |
| 9 #include "gpu/ipc/service/pass_through_image_transport_surface.h" | 9 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/gl/gl_surface_osmesa.h" | 11 #include "ui/gl/gl_surface_osmesa.h" |
| 12 #include "ui/gl/gl_surface_stub.h" | 12 #include "ui/gl/gl_surface_stub.h" |
| 13 | 13 |
| 14 namespace gpu { | 14 namespace gpu { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // A subclass of GLSurfaceOSMesa that doesn't print an error message when | 18 // A subclass of GLSurfaceOSMesa that doesn't print an error message when |
| 19 // SwapBuffers() is called. | 19 // SwapBuffers() is called. |
| 20 class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { | 20 class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { |
| 21 public: | 21 public: |
| 22 // Size doesn't matter, the surface is resized to the right size later. | 22 // Size doesn't matter, the surface is resized to the right size later. |
| 23 DRTSurfaceOSMesa() | 23 DRTSurfaceOSMesa() |
| 24 : GLSurfaceOSMesa(gl::GLSurface::SURFACE_OSMESA_RGBA, gfx::Size(1, 1)) {} | 24 : GLSurfaceOSMesa( |
| 25 gl::GLSurfaceFormat(gl::GLSurfaceFormat::PIXEL_LAYOUT_RGBA), |
| 26 gfx::Size(1, 1)) {} |
| 25 | 27 |
| 26 // Implement a subset of GLSurface. | 28 // Implement a subset of GLSurface. |
| 27 gfx::SwapResult SwapBuffers() override; | 29 gfx::SwapResult SwapBuffers() override; |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 ~DRTSurfaceOSMesa() override {} | 32 ~DRTSurfaceOSMesa() override {} |
| 31 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa); | 33 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa); |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers() { | 36 gfx::SwapResult DRTSurfaceOSMesa::SwapBuffers() { |
| 35 return gfx::SwapResult::SWAP_ACK; | 37 return gfx::SwapResult::SWAP_ACK; |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool g_allow_os_mesa = false; | 40 bool g_allow_os_mesa = false; |
| 39 | 41 |
| 40 } // namespace | 42 } // namespace |
| 41 | 43 |
| 42 // static | 44 // static |
| 43 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( | 45 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( |
| 44 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 46 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
| 45 SurfaceHandle surface_handle, | 47 SurfaceHandle surface_handle, |
| 46 gl::GLSurface::Format format) { | 48 gl::GLSurfaceFormat format) { |
| 47 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 49 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
| 48 | 50 |
| 49 switch (gl::GetGLImplementation()) { | 51 switch (gl::GetGLImplementation()) { |
| 50 case gl::kGLImplementationDesktopGL: | 52 case gl::kGLImplementationDesktopGL: |
| 51 case gl::kGLImplementationDesktopGLCoreProfile: | 53 case gl::kGLImplementationDesktopGLCoreProfile: |
| 52 case gl::kGLImplementationAppleGL: | 54 case gl::kGLImplementationAppleGL: |
| 53 return make_scoped_refptr<gl::GLSurface>( | 55 return make_scoped_refptr<gl::GLSurface>( |
| 54 new ImageTransportSurfaceOverlayMac(delegate)); | 56 new ImageTransportSurfaceOverlayMac(delegate)); |
| 55 case gl::kGLImplementationMockGL: | 57 case gl::kGLImplementationMockGL: |
| 56 return make_scoped_refptr<gl::GLSurface>(new gl::GLSurfaceStub); | 58 return make_scoped_refptr<gl::GLSurface>(new gl::GLSurfaceStub); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 new PassThroughImageTransportSurface(delegate, surface.get())); | 71 new PassThroughImageTransportSurface(delegate, surface.get())); |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 | 74 |
| 73 // static | 75 // static |
| 74 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 76 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
| 75 g_allow_os_mesa = allow; | 77 g_allow_os_mesa = allow; |
| 76 } | 78 } |
| 77 | 79 |
| 78 } // namespace gpu | 80 } // namespace gpu |
| OLD | NEW |