OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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 "gpu/command_buffer/service/async_pixel_transfer_delegate.h" | |
6 | |
7 #include "base/debug/trace_event.h" | |
8 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_egl.h" | |
9 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_stub.h" | |
10 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_sync.h" | |
11 #include "ui/gl/gl_context.h" | |
12 #include "ui/gl/gl_implementation.h" | |
13 | |
14 namespace gpu { | |
15 namespace { | |
16 | |
17 bool IsBroadcom() { | |
18 const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | |
19 if (vendor) | |
20 return std::string(vendor).find("Broadcom") != std::string::npos; | |
21 return false; | |
22 } | |
23 | |
24 } | |
25 | |
26 // We only used threaded uploads when we can: | |
27 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) | |
28 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) | |
29 // - Use fences (to test for upload completion). | |
30 AsyncPixelTransferDelegate* AsyncPixelTransferDelegate::Create( | |
31 gfx::GLContext* context) { | |
32 TRACE_EVENT0("gpu", "AsyncPixelTransferDelegate::Create"); | |
33 switch (gfx::GetGLImplementation()) { | |
34 case gfx::kGLImplementationEGLGLES2: | |
35 DCHECK(context); | |
36 if (context->HasExtension("EGL_KHR_fence_sync") && | |
37 context->HasExtension("EGL_KHR_image") && | |
38 context->HasExtension("EGL_KHR_image_base") && | |
39 context->HasExtension("EGL_KHR_gl_texture_2D_image") && | |
40 context->HasExtension("GL_OES_EGL_image") && | |
41 !IsBroadcom()) { | |
42 return new AsyncPixelTransferDelegateEGL; | |
43 } | |
44 LOG(INFO) << "Async pixel transfers not supported"; | |
45 return new AsyncPixelTransferDelegateSync; | |
46 case gfx::kGLImplementationMockGL: | |
47 return new AsyncPixelTransferDelegateStub; | |
48 default: | |
49 NOTREACHED(); | |
50 return NULL; | |
51 } | |
52 } | |
53 | |
54 } // namespace gpu | |
OLD | NEW |