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/android/sys_utils.h"
8 #include "base/debug/trace_event.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;
35 // We only used threaded uploads when we can:
36 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image)
37 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image)
38 // - Use fences (to test for upload completion).
39 // - The heap size is large enough.
40 // TODO(kaanb|epenner): Remove the IsImagination() check pending the
41 // resolution of crbug.com/249147
42 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the
43 // resolution of crbug.com/271929
44 AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
45 gfx::GLContext* context) {
46 TRACE_EVENT0("gpu", "AsyncPixelTransferManager::Create");
47 switch (gfx::GetGLImplementation()) {
48 case gfx::kGLImplementationEGLGLES2:
50 if (context->HasExtension("EGL_KHR_fence_sync") &&
51 context->HasExtension("EGL_KHR_image") &&
52 context->HasExtension("EGL_KHR_image_base") &&
53 context->HasExtension("EGL_KHR_gl_texture_2D_image") &&
54 context->HasExtension("GL_OES_EGL_image") &&
57 !base::android::SysUtils::IsLowEndDevice()) {
58 return new AsyncPixelTransferManagerEGL;
60 return new AsyncPixelTransferManagerIdle;
61 case gfx::kGLImplementationOSMesaGL:
62 return new AsyncPixelTransferManagerIdle;
63 case gfx::kGLImplementationMockGL:
64 return new AsyncPixelTransferManagerStub;