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

Side by Side Diff: components/mus/public/cpp/lib/gles2_context.cc

Issue 2007813003: Remove Mojo GLES2 API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 6 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
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 "components/mus/public/cpp/gles2_context.h" 5 #include "components/mus/public/cpp/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/shared_memory_limits.h"
15 #include "gpu/command_buffer/client/transfer_buffer.h" 15 #include "gpu/command_buffer/client/transfer_buffer.h"
16 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
17 17
18 namespace mus { 18 namespace mus {
19 19
20 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, 20 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs,
21 mojo::ScopedMessagePipeHandle command_buffer_handle, 21 mojo::ScopedMessagePipeHandle command_buffer_handle)
22 MojoGLES2ContextLost lost_callback, 22 : command_buffer_(attribs, std::move(command_buffer_handle)) {}
23 void* closure)
24 : command_buffer_(attribs, std::move(command_buffer_handle)),
25 lost_callback_(lost_callback),
26 closure_(closure) {}
27 23
28 GLES2Context::~GLES2Context() {} 24 GLES2Context::~GLES2Context() {}
29 25
30 bool GLES2Context::Initialize() { 26 bool GLES2Context::Initialize() {
31 if (!command_buffer_.Initialize()) 27 if (!command_buffer_.Initialize())
32 return false; 28 return false;
33 29
34 constexpr gpu::SharedMemoryLimits default_limits; 30 constexpr gpu::SharedMemoryLimits default_limits;
35 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); 31 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
36 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) 32 if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
37 return false; 33 return false;
38 gles2_helper_->SetAutomaticFlushes(false); 34 gles2_helper_->SetAutomaticFlushes(false);
39 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 35 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
40 gpu::Capabilities capabilities = command_buffer_.GetCapabilities(); 36 gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
41 bool bind_generates_resource = 37 bool bind_generates_resource =
42 !!capabilities.bind_generates_resource_chromium; 38 !!capabilities.bind_generates_resource_chromium;
43 // TODO(piman): Some contexts (such as compositor) want this to be true, so 39 // TODO(piman): Some contexts (such as compositor) want this to be true, so
44 // this needs to be a public parameter. 40 // this needs to be a public parameter.
45 bool lose_context_when_out_of_memory = false; 41 bool lose_context_when_out_of_memory = false;
46 bool support_client_side_arrays = false; 42 bool support_client_side_arrays = false;
47 implementation_.reset(new gpu::gles2::GLES2Implementation( 43 implementation_.reset(new gpu::gles2::GLES2Implementation(
48 gles2_helper_.get(), NULL, transfer_buffer_.get(), 44 gles2_helper_.get(), NULL, transfer_buffer_.get(),
49 bind_generates_resource, lose_context_when_out_of_memory, 45 bind_generates_resource, lose_context_when_out_of_memory,
50 support_client_side_arrays, &command_buffer_)); 46 support_client_side_arrays, &command_buffer_));
51 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, 47 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size,
52 default_limits.min_transfer_buffer_size, 48 default_limits.min_transfer_buffer_size,
53 default_limits.max_transfer_buffer_size, 49 default_limits.max_transfer_buffer_size,
54 default_limits.mapped_memory_reclaim_limit)) 50 default_limits.mapped_memory_reclaim_limit))
55 return false; 51 return false;
56 implementation_->SetLostContextCallback(
57 base::Bind(&GLES2Context::OnLostContext, base::Unretained(this)));
58 return true; 52 return true;
59 } 53 }
60 54
61 void GLES2Context::OnLostContext() {
62 lost_callback_(closure_);
63 }
64
65 } // namespace mus 55 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/context_provider.cc ('k') | components/mus/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698