OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/command_buffer/service/async_pixel_transfer_manager.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" | 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) | 70 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) |
71 // - Use fences (to test for upload completion). | 71 // - Use fences (to test for upload completion). |
72 // - The heap size is large enough. | 72 // - The heap size is large enough. |
73 // TODO(kaanb|epenner): Remove the IsImagination() check pending the | 73 // TODO(kaanb|epenner): Remove the IsImagination() check pending the |
74 // resolution of crbug.com/249147 | 74 // resolution of crbug.com/249147 |
75 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the | 75 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the |
76 // resolution of crbug.com/271929 | 76 // resolution of crbug.com/271929 |
77 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( | 77 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( |
78 gfx::GLContext* context) { | 78 gfx::GLContext* context) { |
79 DCHECK(context->IsCurrent(NULL)); | 79 DCHECK(context->IsCurrent(NULL)); |
80 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
81 | |
82 // Threaded mailbox uses EGLImage which conflicts with EGL uploader. | 80 // Threaded mailbox uses EGLImage which conflicts with EGL uploader. |
83 // The spec only allows one EGL image per sibling group, but currently the | 81 // The spec only allows one EGL image per sibling group, but currently the |
84 // image handle cannot be shared between the threaded mailbox code and | 82 // image handle cannot be shared between the threaded mailbox code and |
85 // AsyncPixelTransferManagerEGL. | 83 // AsyncPixelTransferManagerEGL. |
86 bool uses_threaded_mailboxes = | 84 bool uses_threaded_mailboxes = |
87 cl->HasSwitch(switches::kEnableThreadedTextureMailboxes); | 85 base::CommandLine::ForCurrentProcess()->HasSwitch( |
88 // TexImage2D orphans the EGLImage used for threaded mailbox sharing. | 86 switches::kEnableThreadedTextureMailboxes); |
89 bool use_teximage2d_over_texsubimage2d = !uses_threaded_mailboxes; | |
90 switch (gfx::GetGLImplementation()) { | 87 switch (gfx::GetGLImplementation()) { |
91 case gfx::kGLImplementationEGLGLES2: | 88 case gfx::kGLImplementationEGLGLES2: |
92 DCHECK(context); | 89 DCHECK(context); |
93 if (!base::SysInfo::IsLowEndDevice() && | 90 if (!base::SysInfo::IsLowEndDevice() && |
94 context->HasExtension("EGL_KHR_fence_sync") && | 91 context->HasExtension("EGL_KHR_fence_sync") && |
95 context->HasExtension("EGL_KHR_image") && | 92 context->HasExtension("EGL_KHR_image") && |
96 context->HasExtension("EGL_KHR_image_base") && | 93 context->HasExtension("EGL_KHR_image_base") && |
97 context->HasExtension("EGL_KHR_gl_texture_2D_image") && | 94 context->HasExtension("EGL_KHR_gl_texture_2D_image") && |
98 context->HasExtension("GL_OES_EGL_image") && | 95 context->HasExtension("GL_OES_EGL_image") && |
99 !uses_threaded_mailboxes && AllowTransferThreadForGpu()) { | 96 !uses_threaded_mailboxes && |
| 97 AllowTransferThreadForGpu()) { |
100 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); | 98 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); |
101 return new AsyncPixelTransferManagerEGL; | 99 return new AsyncPixelTransferManagerEGL; |
102 } | 100 } |
103 return new AsyncPixelTransferManagerIdle( | 101 return new AsyncPixelTransferManagerIdle; |
104 use_teximage2d_over_texsubimage2d); | |
105 case gfx::kGLImplementationOSMesaGL: { | 102 case gfx::kGLImplementationOSMesaGL: { |
106 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); | 103 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); |
107 return new AsyncPixelTransferManagerIdle( | 104 return new AsyncPixelTransferManagerIdle; |
108 use_teximage2d_over_texsubimage2d); | |
109 } | 105 } |
110 case gfx::kGLImplementationMockGL: | 106 case gfx::kGLImplementationMockGL: |
111 return new AsyncPixelTransferManagerStub; | 107 return new AsyncPixelTransferManagerStub; |
112 default: | 108 default: |
113 NOTREACHED(); | 109 NOTREACHED(); |
114 return NULL; | 110 return NULL; |
115 } | 111 } |
116 } | 112 } |
117 | 113 |
118 } // namespace gpu | 114 } // namespace gpu |
OLD | NEW |