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

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

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: .get 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
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>
(...skipping 10 matching lines...) Expand all
21 const size_t kDefaultCommandBufferSize = 1024 * 1024; 21 const size_t kDefaultCommandBufferSize = 1024 * 1024;
22 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; 22 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
23 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; 23 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
24 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; 24 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
25 } 25 }
26 26
27 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, 27 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs,
28 mojo::ScopedMessagePipeHandle command_buffer_handle, 28 mojo::ScopedMessagePipeHandle command_buffer_handle,
29 MojoGLES2ContextLost lost_callback, 29 MojoGLES2ContextLost lost_callback,
30 void* closure) 30 void* closure)
31 : command_buffer_(this, attribs, std::move(command_buffer_handle)), 31 : command_buffer_(attribs, std::move(command_buffer_handle)),
32 lost_callback_(lost_callback), 32 lost_callback_(lost_callback),
33 closure_(closure) {} 33 closure_(closure) {}
34 34
35 GLES2Context::~GLES2Context() {} 35 GLES2Context::~GLES2Context() {}
36 36
37 bool GLES2Context::Initialize() { 37 bool GLES2Context::Initialize() {
38 if (!command_buffer_.Initialize()) 38 if (!command_buffer_.Initialize())
39 return false; 39 return false;
40 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); 40 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
41 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 41 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize))
42 return false; 42 return false;
43 gles2_helper_->SetAutomaticFlushes(false); 43 gles2_helper_->SetAutomaticFlushes(false);
44 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 44 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
45 gpu::Capabilities capabilities = command_buffer_.GetCapabilities(); 45 gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
46 bool bind_generates_resource = 46 bool bind_generates_resource =
47 !!capabilities.bind_generates_resource_chromium; 47 !!capabilities.bind_generates_resource_chromium;
48 // TODO(piman): Some contexts (such as compositor) want this to be true, so 48 // TODO(piman): Some contexts (such as compositor) want this to be true, so
49 // this needs to be a public parameter. 49 // this needs to be a public parameter.
50 bool lose_context_when_out_of_memory = false; 50 bool lose_context_when_out_of_memory = false;
51 bool support_client_side_arrays = false; 51 bool support_client_side_arrays = false;
52 implementation_.reset( 52 implementation_.reset(
53 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 53 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
54 NULL, 54 NULL,
55 transfer_buffer_.get(), 55 transfer_buffer_.get(),
56 bind_generates_resource, 56 bind_generates_resource,
57 lose_context_when_out_of_memory, 57 lose_context_when_out_of_memory,
58 support_client_side_arrays, 58 support_client_side_arrays,
59 &command_buffer_)); 59 &command_buffer_));
60 return implementation_->Initialize(kDefaultStartTransferBufferSize, 60 if (!implementation_->Initialize(kDefaultStartTransferBufferSize,
61 kDefaultMinTransferBufferSize, 61 kDefaultMinTransferBufferSize,
62 kDefaultMaxTransferBufferSize, 62 kDefaultMaxTransferBufferSize,
63 gpu::gles2::GLES2Implementation::kNoLimit); 63 gpu::gles2::GLES2Implementation::kNoLimit))
64 return false;
65 implementation_->SetLostContextCallback(
66 base::Bind(&GLES2Context::OnLostContext, base::Unretained(this)));
67 return true;
64 } 68 }
65 69
66 void GLES2Context::ContextLost() { lost_callback_(closure_); } 70 void GLES2Context::OnLostContext() {
71 lost_callback_(closure_);
72 }
67 73
68 } // namespace gles2 74 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698