Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 2443023002: gpu: Add CHROMIUM_copy_image extension.
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/ozone/platform/drm/gpu/gbm_surfaceless.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/sys_info.h" 20 #include "base/sys_info.h"
21 #include "base/threading/thread.h"
21 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
24 #include "ui/gl/egl_util.h" 25 #include "ui/gl/egl_util.h"
25 #include "ui/gl/gl_context.h" 26 #include "ui/gl/gl_context.h"
26 #include "ui/gl/gl_context_egl.h" 27 #include "ui/gl/gl_context_egl.h"
27 #include "ui/gl/gl_image.h" 28 #include "ui/gl/gl_image.h"
28 #include "ui/gl/gl_implementation.h" 29 #include "ui/gl/gl_implementation.h"
29 #include "ui/gl/gl_surface_stub.h" 30 #include "ui/gl/gl_surface_stub.h"
30 #include "ui/gl/gl_switches.h" 31 #include "ui/gl/gl_switches.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 347 }
347 } 348 }
348 } 349 }
349 return config; 350 return config;
350 } 351 }
351 352
352 LOG(ERROR) << "No suitable EGL configs found."; 353 LOG(ERROR) << "No suitable EGL configs found.";
353 return nullptr; 354 return nullptr;
354 } 355 }
355 356
357 void WaitForSyncFence(EGLDisplay display, EGLSyncKHR fence) {
358 eglClientWaitSyncKHR(display, fence, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
359 EGL_FOREVER_KHR);
360 }
361
356 } // namespace 362 } // namespace
357 363
358 void GetEGLInitDisplays(bool supports_angle_d3d, 364 void GetEGLInitDisplays(bool supports_angle_d3d,
359 bool supports_angle_opengl, 365 bool supports_angle_opengl,
360 bool supports_angle_null, 366 bool supports_angle_null,
361 const base::CommandLine* command_line, 367 const base::CommandLine* command_line,
362 std::vector<DisplayType>* init_displays) { 368 std::vector<DisplayType>* init_displays) {
363 // SwiftShader does not use the platform extensions 369 // SwiftShader does not use the platform extensions
364 if (command_line->GetSwitchValueASCII(switches::kUseGL) == 370 if (command_line->GetSwitchValueASCII(switches::kUseGL) ==
365 kGLImplementationSwiftShaderName) { 371 kGLImplementationSwiftShaderName) {
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 } 1153 }
1148 1154
1149 return handle; 1155 return handle;
1150 #endif 1156 #endif
1151 } 1157 }
1152 1158
1153 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 1159 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
1154 Destroy(); 1160 Destroy();
1155 } 1161 }
1156 1162
1163 class SurfacelessEGL::EGLWaitSyncFenceThread
1164 : public base::Thread,
1165 public base::NonThreadSafe,
1166 public base::RefCounted<EGLWaitSyncFenceThread> {
1167 public:
1168 static scoped_refptr<EGLWaitSyncFenceThread> Create() {
1169 if (!g_wait_sync_fence_thread) {
1170 g_wait_sync_fence_thread = new EGLWaitSyncFenceThread;
1171 g_wait_sync_fence_thread->Start();
1172 }
1173 return g_wait_sync_fence_thread;
1174 }
1175
1176 private:
1177 friend class base::RefCounted<EGLWaitSyncFenceThread>;
1178
1179 EGLWaitSyncFenceThread() : base::Thread("EGLWaitSyncFence") {
1180 DCHECK(CalledOnValidThread());
1181 }
1182 ~EGLWaitSyncFenceThread() override {
1183 DCHECK(CalledOnValidThread());
1184 g_wait_sync_fence_thread = nullptr;
1185 Stop();
1186 }
1187
1188 static EGLWaitSyncFenceThread* g_wait_sync_fence_thread;
1189
1190 DISALLOW_COPY_AND_ASSIGN(EGLWaitSyncFenceThread);
1191 };
1192
1193 SurfacelessEGL::EGLWaitSyncFenceThread*
1194 SurfacelessEGL::EGLWaitSyncFenceThread::g_wait_sync_fence_thread = nullptr;
1195
1157 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size) 1196 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size)
1158 : size_(size) { 1197 : size_(size), weak_ptr_factory_(this) {
1159 format_ = GLSurface::SURFACE_SURFACELESS; 1198 format_ = GLSurface::SURFACE_SURFACELESS;
1160 } 1199 }
1161 1200
1162 bool SurfacelessEGL::Initialize() { 1201 bool SurfacelessEGL::Initialize() {
1202 wait_sync_fence_thread_ = EGLWaitSyncFenceThread::Create();
1203 if (!wait_sync_fence_thread_)
1204 return false;
1163 return Initialize(SURFACE_SURFACELESS); 1205 return Initialize(SURFACE_SURFACELESS);
1164 } 1206 }
1165 1207
1166 bool SurfacelessEGL::Initialize(GLSurface::Format format) { 1208 bool SurfacelessEGL::Initialize(GLSurface::Format format) {
1167 format_ = format; 1209 format_ = format;
1168 return true; 1210 return true;
1169 } 1211 }
1170 1212
1171 void SurfacelessEGL::Destroy() { 1213 void SurfacelessEGL::Destroy() {
1172 } 1214 }
(...skipping 23 matching lines...) Expand all
1196 } 1238 }
1197 1239
1198 EGLSurface SurfacelessEGL::GetHandle() { 1240 EGLSurface SurfacelessEGL::GetHandle() {
1199 return EGL_NO_SURFACE; 1241 return EGL_NO_SURFACE;
1200 } 1242 }
1201 1243
1202 void* SurfacelessEGL::GetShareHandle() { 1244 void* SurfacelessEGL::GetShareHandle() {
1203 return NULL; 1245 return NULL;
1204 } 1246 }
1205 1247
1248 bool SurfacelessEGL::SupportsInsertFence() {
1249 return true;
1250 }
1251
1252 void SurfacelessEGL::InsertFence(const base::Closure& callback) {
1253 bool rv = InsertSyncFence(nullptr, callback);
1254 LOG_IF(ERROR, !rv) << "InsertFence failed";
1255 }
1256
1257 bool SurfacelessEGL::InsertSyncFence(const EGLint* attribs,
1258 const base::Closure& callback) {
1259 EGLSyncKHR fence =
1260 eglCreateSyncKHR(GetDisplay(), EGL_SYNC_FENCE_KHR, attribs);
1261 if (!fence)
1262 return false;
1263
1264 wait_sync_fence_thread_->task_runner()->PostTaskAndReply(
1265 FROM_HERE, base::Bind(&WaitForSyncFence, GetDisplay(), fence),
1266 base::Bind(&SurfacelessEGL::FenceRetired, weak_ptr_factory_.GetWeakPtr(),
1267 fence, callback));
1268 return true;
1269 }
1270
1271 void SurfacelessEGL::FenceRetired(EGLSyncKHR fence,
1272 const base::Closure& callback) {
1273 eglDestroySyncKHR(GetDisplay(), fence);
1274 callback.Run();
1275 }
1276
1206 SurfacelessEGL::~SurfacelessEGL() { 1277 SurfacelessEGL::~SurfacelessEGL() {
1207 } 1278 }
1208 1279
1209 } // namespace gl 1280 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/ozone/platform/drm/gpu/gbm_surfaceless.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698