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

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

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 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 | « mojo/gles2/gles2_context.h ('k') | mojo/gles2/gles2_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/gles2/gles2_context.h"
6
7 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "gpu/command_buffer/client/transfer_buffer.h"
10 #include "mojo/public/c/gles2/gles2.h"
11 #include "mojo/public/cpp/system/core.h"
12
13 namespace gles2 {
14
15 namespace {
16 const size_t kDefaultCommandBufferSize = 1024 * 1024;
17 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
18 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
19 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
20 }
21
22 GLES2Context::GLES2Context(const MojoAsyncWaiter* async_waiter,
23 mojo::ScopedMessagePipeHandle command_buffer_handle,
24 MojoGLES2ContextLost lost_callback,
25 void* closure)
26 : command_buffer_(this, async_waiter, command_buffer_handle.Pass()),
27 lost_callback_(lost_callback),
28 closure_(closure) {
29 }
30
31 GLES2Context::~GLES2Context() {}
32
33 bool GLES2Context::Initialize() {
34 if (!command_buffer_.Initialize())
35 return false;
36 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
37 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize))
38 return false;
39 gles2_helper_->SetAutomaticFlushes(false);
40 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
41 gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
42 bool bind_generates_resource =
43 !!capabilities.bind_generates_resource_chromium;
44 // TODO(piman): Some contexts (such as compositor) want this to be true, so
45 // this needs to be a public parameter.
46 bool lose_context_when_out_of_memory = false;
47 bool support_client_side_arrays = false;
48 implementation_.reset(
49 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
50 NULL,
51 transfer_buffer_.get(),
52 bind_generates_resource,
53 lose_context_when_out_of_memory,
54 support_client_side_arrays,
55 &command_buffer_));
56 return implementation_->Initialize(kDefaultStartTransferBufferSize,
57 kDefaultMinTransferBufferSize,
58 kDefaultMaxTransferBufferSize,
59 gpu::gles2::GLES2Implementation::kNoLimit);
60 }
61
62 void GLES2Context::ContextLost() { lost_callback_(closure_); }
63
64 } // namespace gles2
OLDNEW
« no previous file with comments | « mojo/gles2/gles2_context.h ('k') | mojo/gles2/gles2_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698