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

Side by Side Diff: gpu/gles2_conform_support/egl/context.cc

Issue 2814583002: Service/ClientDiscardableManager (Closed)
Patch Set: rebase Created 3 years, 7 months 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 | « gpu/gles2_conform_support/egl/context.h ('k') | gpu/ipc/in_process_command_buffer.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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/gles2_conform_support/egl/context.h" 5 #include "gpu/gles2_conform_support/egl/context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h" 11 #include "gpu/command_buffer/client/gles2_implementation.h"
12 #include "gpu/command_buffer/client/gles2_lib.h" 12 #include "gpu/command_buffer/client/gles2_lib.h"
13 #include "gpu/command_buffer/client/shared_memory_limits.h" 13 #include "gpu/command_buffer/client/shared_memory_limits.h"
14 #include "gpu/command_buffer/client/transfer_buffer.h" 14 #include "gpu/command_buffer/client/transfer_buffer.h"
15 #include "gpu/command_buffer/service/context_group.h" 15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/mailbox_manager.h" 16 #include "gpu/command_buffer/service/mailbox_manager.h"
17 #include "gpu/command_buffer/service/memory_tracking.h" 17 #include "gpu/command_buffer/service/memory_tracking.h"
18 #include "gpu/command_buffer/service/service_discardable_manager.h"
18 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 19 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
19 #include "gpu/gles2_conform_support/egl/config.h" 20 #include "gpu/gles2_conform_support/egl/config.h"
20 #include "gpu/gles2_conform_support/egl/display.h" 21 #include "gpu/gles2_conform_support/egl/display.h"
21 #include "gpu/gles2_conform_support/egl/surface.h" 22 #include "gpu/gles2_conform_support/egl/surface.h"
22 #include "gpu/gles2_conform_support/egl/thread_state.h" 23 #include "gpu/gles2_conform_support/egl/thread_state.h"
23 #include "ui/gl/init/gl_factory.h" 24 #include "ui/gl/init/gl_factory.h"
24 25
25 // The slight complexification in this file comes from following properties: 26 // The slight complexification in this file comes from following properties:
26 // 1) Command buffer connection (context) can not be established without a 27 // 1) Command buffer connection (context) can not be established without a
27 // GLSurface. EGL Context can be created independent of a surface. This is why 28 // GLSurface. EGL Context can be created independent of a surface. This is why
(...skipping 17 matching lines...) Expand all
45 const bool kLoseContextWhenOutOfMemory = false; 46 const bool kLoseContextWhenOutOfMemory = false;
46 const bool kSupportClientSideArrays = true; 47 const bool kSupportClientSideArrays = true;
47 } 48 }
48 49
49 namespace egl { 50 namespace egl {
50 Context::Context(Display* display, const Config* config) 51 Context::Context(Display* display, const Config* config)
51 : display_(display), 52 : display_(display),
52 config_(config), 53 config_(config),
53 is_current_in_some_thread_(false), 54 is_current_in_some_thread_(false),
54 is_destroyed_(false), 55 is_destroyed_(false),
55 gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()) { 56 discardable_manager_(new gpu::ServiceDiscardableManager()),
56 } 57 gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()) {}
57 58
58 Context::~Context() { 59 Context::~Context() {
59 // We might not have a surface, so we must lose the context. Cleanup will 60 // We might not have a surface, so we must lose the context. Cleanup will
60 // execute GL commands otherwise. TODO: if shared contexts are ever 61 // execute GL commands otherwise. TODO: if shared contexts are ever
61 // implemented, this will leak the GL resources. For pbuffer contexts, one 62 // implemented, this will leak the GL resources. For pbuffer contexts, one
62 // could track the last current surface or create a surface for destroying 63 // could track the last current surface or create a surface for destroying
63 // purposes only. Other option would be to make the service usable without 64 // purposes only. Other option would be to make the service usable without
64 // surface. 65 // surface.
65 if (HasService()) { 66 if (HasService()) {
66 if (!WasServiceContextLost()) 67 if (!WasServiceContextLost())
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 std::unique_ptr<gpu::CommandBufferService> command_buffer( 261 std::unique_ptr<gpu::CommandBufferService> command_buffer(
261 new gpu::CommandBufferService(transfer_buffer_manager_.get())); 262 new gpu::CommandBufferService(transfer_buffer_manager_.get()));
262 263
263 scoped_refptr<gpu::gles2::FeatureInfo> feature_info( 264 scoped_refptr<gpu::gles2::FeatureInfo> feature_info(
264 new gpu::gles2::FeatureInfo(gpu_driver_bug_workarounds_)); 265 new gpu::gles2::FeatureInfo(gpu_driver_bug_workarounds_));
265 scoped_refptr<gpu::gles2::ContextGroup> group(new gpu::gles2::ContextGroup( 266 scoped_refptr<gpu::gles2::ContextGroup> group(new gpu::gles2::ContextGroup(
266 gpu_preferences_, nullptr, nullptr, 267 gpu_preferences_, nullptr, nullptr,
267 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_), 268 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_),
268 new gpu::gles2::FramebufferCompletenessCache, feature_info, true, nullptr, 269 new gpu::gles2::FramebufferCompletenessCache, feature_info, true, nullptr,
269 nullptr, gpu::GpuFeatureInfo())); 270 nullptr, gpu::GpuFeatureInfo(), discardable_manager_.get()));
270 271
271 std::unique_ptr<gpu::gles2::GLES2Decoder> decoder( 272 std::unique_ptr<gpu::gles2::GLES2Decoder> decoder(
272 gpu::gles2::GLES2Decoder::Create(group.get())); 273 gpu::gles2::GLES2Decoder::Create(group.get()));
273 if (!decoder.get()) 274 if (!decoder.get())
274 return false; 275 return false;
275 276
276 std::unique_ptr<gpu::CommandExecutor> command_executor( 277 std::unique_ptr<gpu::CommandExecutor> command_executor(
277 new gpu::CommandExecutor(command_buffer.get(), decoder.get(), 278 new gpu::CommandExecutor(command_buffer.get(), decoder.get(),
278 decoder.get())); 279 decoder.get()));
279 280
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return false; 397 return false;
397 if (!gl_context_->MakeCurrent(gl_surface)) { 398 if (!gl_context_->MakeCurrent(gl_surface)) {
398 MarkServiceContextLost(); 399 MarkServiceContextLost();
399 return false; 400 return false;
400 } 401 }
401 client_gl_context_->Flush(); 402 client_gl_context_->Flush();
402 return true; 403 return true;
403 } 404 }
404 405
405 } // namespace egl 406 } // namespace egl
OLDNEW
« no previous file with comments | « gpu/gles2_conform_support/egl/context.h ('k') | gpu/ipc/in_process_command_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698