1 // Copyright 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.
5 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
7 #include "base/debug/trace_event.h"
8 #include "base/sys_info.h"
9 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h"
10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h"
11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h"
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h"
13 #include "ui/gl/gl_context.h"
14 #include "ui/gl/gl_implementation.h"
20 const char* vendor
= reinterpret_cast<const char*>(glGetString(GL_VENDOR
));
22 return std::string(vendor
).find("Broadcom") != std::string::npos
;
26 bool IsImagination() {
27 const char* vendor
= reinterpret_cast<const char*>(glGetString(GL_VENDOR
));
29 return std::string(vendor
).find("Imagination") != std::string::npos
;
34 const char* vendor
= reinterpret_cast<const char*>(glGetString(GL_VENDOR
));
35 const char* version
= reinterpret_cast<const char*>(glGetString(GL_VERSION
));
36 return vendor
&& version
&&
37 std::string(vendor
).find("NVIDIA") != std::string::npos
&&
38 std::string(version
).find("OpenGL ES 3.1") != std::string::npos
;
43 // We only used threaded uploads when we can:
44 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image)
45 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image)
46 // - Use fences (to test for upload completion).
47 // - The heap size is large enough.
48 // TODO(kaanb|epenner): Remove the IsImagination() check pending the
49 // resolution of crbug.com/249147
50 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the
51 // resolution of crbug.com/271929
52 AsyncPixelTransferManager
* AsyncPixelTransferManager::Create(
53 gfx::GLContext
* context
) {
54 TRACE_EVENT0("gpu", "AsyncPixelTransferManager::Create");
55 switch (gfx::GetGLImplementation()) {
56 case gfx::kGLImplementationEGLGLES2
:
58 if (context
->HasExtension("EGL_KHR_fence_sync") &&
59 context
->HasExtension("EGL_KHR_image") &&
60 context
->HasExtension("EGL_KHR_image_base") &&
61 context
->HasExtension("EGL_KHR_gl_texture_2D_image") &&
62 context
->HasExtension("GL_OES_EGL_image") &&
66 !base::SysInfo::IsLowEndDevice()) {
67 return new AsyncPixelTransferManagerEGL
;
69 return new AsyncPixelTransferManagerIdle
;
70 case gfx::kGLImplementationOSMesaGL
:
71 return new AsyncPixelTransferManagerIdle
;
72 case gfx::kGLImplementationMockGL
:
73 return new AsyncPixelTransferManagerStub
;