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 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: blimp2 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 command_buffer_.SetGpuControlClient(this);
no sievers 2016/04/07 21:07:58 Won't GLES2Impl below clobber this and set itself
danakj 2016/04/07 21:45:19 Yes I was doing this wrong like the GLInProcessCon
38 if (!command_buffer_.Initialize()) 39 if (!command_buffer_.Initialize())
39 return false; 40 return false;
40 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); 41 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
41 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 42 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize))
42 return false; 43 return false;
43 gles2_helper_->SetAutomaticFlushes(false); 44 gles2_helper_->SetAutomaticFlushes(false);
44 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 45 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
45 gpu::Capabilities capabilities = command_buffer_.GetCapabilities(); 46 gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
46 bool bind_generates_resource = 47 bool bind_generates_resource =
47 !!capabilities.bind_generates_resource_chromium; 48 !!capabilities.bind_generates_resource_chromium;
48 // TODO(piman): Some contexts (such as compositor) want this to be true, so 49 // TODO(piman): Some contexts (such as compositor) want this to be true, so
49 // this needs to be a public parameter. 50 // this needs to be a public parameter.
50 bool lose_context_when_out_of_memory = false; 51 bool lose_context_when_out_of_memory = false;
51 bool support_client_side_arrays = false; 52 bool support_client_side_arrays = false;
52 implementation_.reset( 53 implementation_.reset(
53 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 54 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
54 NULL, 55 NULL,
55 transfer_buffer_.get(), 56 transfer_buffer_.get(),
56 bind_generates_resource, 57 bind_generates_resource,
57 lose_context_when_out_of_memory, 58 lose_context_when_out_of_memory,
58 support_client_side_arrays, 59 support_client_side_arrays,
59 &command_buffer_)); 60 &command_buffer_));
60 return implementation_->Initialize(kDefaultStartTransferBufferSize, 61 return implementation_->Initialize(kDefaultStartTransferBufferSize,
61 kDefaultMinTransferBufferSize, 62 kDefaultMinTransferBufferSize,
62 kDefaultMaxTransferBufferSize, 63 kDefaultMaxTransferBufferSize,
63 gpu::gles2::GLES2Implementation::kNoLimit); 64 gpu::gles2::GLES2Implementation::kNoLimit);
64 } 65 }
65 66
66 void GLES2Context::ContextLost() { lost_callback_(closure_); } 67 void GLES2Context::OnGpuControlLostContext() {
68 lost_callback_(closure_);
69 }
67 70
68 } // namespace gles2 71 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698