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

Side by Side Diff: mojo/gles2/gles2_context.cc

Issue 1900993002: Move SharedMemoryLimits out of WebGraphicsContext3DCommandBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@limits
Patch Set: move-limits: types Created 4 years, 8 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/display.cc ('k') | ppapi/shared_impl/ppb_graphics_3d_shared.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/gles2/gles2_context.h" 5 #include "mojo/gles2/gles2_context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
11 11
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
13 #include "gpu/command_buffer/client/gles2_implementation.h" 13 #include "gpu/command_buffer/client/gles2_implementation.h"
14 #include "gpu/command_buffer/client/shared_memory_limits.h"
14 #include "gpu/command_buffer/client/transfer_buffer.h" 15 #include "gpu/command_buffer/client/transfer_buffer.h"
15 #include "mojo/public/c/gles2/gles2.h" 16 #include "mojo/public/c/gles2/gles2.h"
16 #include "mojo/public/cpp/system/core.h" 17 #include "mojo/public/cpp/system/core.h"
17 18
18 namespace gles2 { 19 namespace gles2 {
19 20
20 namespace {
21 const size_t kDefaultCommandBufferSize = 1024 * 1024;
22 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
23 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
24 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
25 }
26
27 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, 21 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs,
28 mojo::ScopedMessagePipeHandle command_buffer_handle, 22 mojo::ScopedMessagePipeHandle command_buffer_handle,
29 MojoGLES2ContextLost lost_callback, 23 MojoGLES2ContextLost lost_callback,
30 void* closure) 24 void* closure)
31 : command_buffer_(attribs, std::move(command_buffer_handle)), 25 : command_buffer_(attribs, std::move(command_buffer_handle)),
32 lost_callback_(lost_callback), 26 lost_callback_(lost_callback),
33 closure_(closure) {} 27 closure_(closure) {}
34 28
35 GLES2Context::~GLES2Context() {} 29 GLES2Context::~GLES2Context() {}
36 30
37 bool GLES2Context::Initialize() { 31 bool GLES2Context::Initialize() {
38 if (!command_buffer_.Initialize()) 32 if (!command_buffer_.Initialize())
39 return false; 33 return false;
34
35 constexpr gpu::SharedMemoryLimits default_limits;
40 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); 36 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
41 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 37 if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
42 return false; 38 return false;
43 gles2_helper_->SetAutomaticFlushes(false); 39 gles2_helper_->SetAutomaticFlushes(false);
44 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 40 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
45 gpu::Capabilities capabilities = command_buffer_.GetCapabilities(); 41 gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
46 bool bind_generates_resource = 42 bool bind_generates_resource =
47 !!capabilities.bind_generates_resource_chromium; 43 !!capabilities.bind_generates_resource_chromium;
48 // TODO(piman): Some contexts (such as compositor) want this to be true, so 44 // TODO(piman): Some contexts (such as compositor) want this to be true, so
49 // this needs to be a public parameter. 45 // this needs to be a public parameter.
50 bool lose_context_when_out_of_memory = false; 46 bool lose_context_when_out_of_memory = false;
51 bool support_client_side_arrays = false; 47 bool support_client_side_arrays = false;
52 implementation_.reset( 48 implementation_.reset(
53 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 49 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
54 NULL, 50 NULL,
55 transfer_buffer_.get(), 51 transfer_buffer_.get(),
56 bind_generates_resource, 52 bind_generates_resource,
57 lose_context_when_out_of_memory, 53 lose_context_when_out_of_memory,
58 support_client_side_arrays, 54 support_client_side_arrays,
59 &command_buffer_)); 55 &command_buffer_));
60 if (!implementation_->Initialize(kDefaultStartTransferBufferSize, 56 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size,
61 kDefaultMinTransferBufferSize, 57 default_limits.min_transfer_buffer_size,
62 kDefaultMaxTransferBufferSize, 58 default_limits.max_transfer_buffer_size,
63 gpu::gles2::GLES2Implementation::kNoLimit)) 59 default_limits.mapped_memory_reclaim_limit))
64 return false; 60 return false;
65 implementation_->SetLostContextCallback( 61 implementation_->SetLostContextCallback(
66 base::Bind(&GLES2Context::OnLostContext, base::Unretained(this))); 62 base::Bind(&GLES2Context::OnLostContext, base::Unretained(this)));
67 return true; 63 return true;
68 } 64 }
69 65
70 void GLES2Context::OnLostContext() { 66 void GLES2Context::OnLostContext() {
71 lost_callback_(closure_); 67 lost_callback_(closure_);
72 } 68 }
73 69
74 } // namespace gles2 70 } // namespace gles2
OLDNEW
« no previous file with comments | « gpu/gles2_conform_support/egl/display.cc ('k') | ppapi/shared_impl/ppb_graphics_3d_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698