blob: 5aaabf4ea8ae89733d07c214fe872839115c986a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
#include "base/android/sys_utils.h"
#include "base/debug/trace_event.h"
#include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h"
#include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h"
#include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h"
#include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
namespace gpu {
namespace {
bool IsBroadcom() {
const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
if (vendor)
return std::string(vendor).find("Broadcom") != std::string::npos;
return false;
}
bool IsImagination() {
const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
if (vendor)
return std::string(vendor).find("Imagination") != std::string::npos;
return false;
}
}
// We only used threaded uploads when we can:
// - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image)
// - Bind EGLImages to OpenGL textures (GL_OES_EGL_image)
// - Use fences (to test for upload completion).
// - The heap size is large enough.
// TODO(kaanb|epenner): Remove the IsImagination() check pending the
// resolution of crbug.com/249147
// TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the
// resolution of crbug.com/271929
AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
gfx::GLContext* context) {
TRACE_EVENT0("gpu", "AsyncPixelTransferManager::Create");
switch (gfx::GetGLImplementation()) {
case gfx::kGLImplementationEGLGLES2:
DCHECK(context);
if (context->HasExtension("EGL_KHR_fence_sync") &&
context->HasExtension("EGL_KHR_image") &&
context->HasExtension("EGL_KHR_image_base") &&
context->HasExtension("EGL_KHR_gl_texture_2D_image") &&
context->HasExtension("GL_OES_EGL_image") &&
!IsBroadcom() &&
!IsImagination() &&
!base::android::SysUtils::IsLowEndDevice()) {
return new AsyncPixelTransferManagerEGL;
}
LOG(INFO) << "Async pixel transfers not supported";
return new AsyncPixelTransferManagerIdle;
case gfx::kGLImplementationMockGL:
return new AsyncPixelTransferManagerStub;
default:
NOTREACHED();
return NULL;
}
}
} // namespace gpu
|