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

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

Issue 384513003: Remove RequestAnimationFrame from mojo, add delayed tasks to RunLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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 "gpu/command_buffer/client/gles2_cmd_helper.h" 7 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "gpu/command_buffer/client/transfer_buffer.h" 9 #include "gpu/command_buffer/client/transfer_buffer.h"
10 #include "mojo/public/c/gles2/gles2.h" 10 #include "mojo/public/c/gles2/gles2.h"
11 #include "mojo/public/cpp/system/core.h" 11 #include "mojo/public/cpp/system/core.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 namespace { 16 namespace {
17 const size_t kDefaultCommandBufferSize = 1024 * 1024; 17 const size_t kDefaultCommandBufferSize = 1024 * 1024;
18 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; 18 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
19 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; 19 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
20 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; 20 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
21 } 21 }
22 22
23 GLES2Context::GLES2Context(const MojoAsyncWaiter* async_waiter, 23 GLES2Context::GLES2Context(const MojoAsyncWaiter* async_waiter,
24 ScopedMessagePipeHandle command_buffer_handle, 24 ScopedMessagePipeHandle command_buffer_handle,
25 MojoGLES2ContextLost lost_callback, 25 MojoGLES2ContextLost lost_callback,
26 MojoGLES2DrawAnimationFrame animation_callback,
27 void* closure) 26 void* closure)
28 : command_buffer_(this, async_waiter, command_buffer_handle.Pass()), 27 : command_buffer_(this, async_waiter, command_buffer_handle.Pass()),
29 lost_callback_(lost_callback), 28 lost_callback_(lost_callback),
30 animation_callback_(animation_callback),
31 closure_(closure) {} 29 closure_(closure) {}
32 30
33 GLES2Context::~GLES2Context() {} 31 GLES2Context::~GLES2Context() {}
34 32
35 bool GLES2Context::Initialize() { 33 bool GLES2Context::Initialize() {
36 if (!command_buffer_.Initialize()) 34 if (!command_buffer_.Initialize())
37 return false; 35 return false;
38 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); 36 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
39 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 37 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize))
40 return false; 38 return false;
41 gles2_helper_->SetAutomaticFlushes(false); 39 gles2_helper_->SetAutomaticFlushes(false);
42 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 40 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
43 bool bind_generates_resource = true; 41 bool bind_generates_resource = true;
44 // TODO(piman): Some contexts (such as compositor) want this to be true, so 42 // TODO(piman): Some contexts (such as compositor) want this to be true, so
45 // this needs to be a public parameter. 43 // this needs to be a public parameter.
46 bool lose_context_when_out_of_memory = false; 44 bool lose_context_when_out_of_memory = false;
47 implementation_.reset( 45 implementation_.reset(
48 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 46 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
49 NULL, 47 NULL,
50 transfer_buffer_.get(), 48 transfer_buffer_.get(),
51 bind_generates_resource, 49 bind_generates_resource,
52 lose_context_when_out_of_memory, 50 lose_context_when_out_of_memory,
53 &command_buffer_)); 51 &command_buffer_));
54 return implementation_->Initialize(kDefaultStartTransferBufferSize, 52 return implementation_->Initialize(kDefaultStartTransferBufferSize,
55 kDefaultMinTransferBufferSize, 53 kDefaultMinTransferBufferSize,
56 kDefaultMaxTransferBufferSize, 54 kDefaultMaxTransferBufferSize,
57 gpu::gles2::GLES2Implementation::kNoLimit); 55 gpu::gles2::GLES2Implementation::kNoLimit);
58 } 56 }
59 57
60 void GLES2Context::RequestAnimationFrames() {
61 command_buffer_.RequestAnimationFrames();
62 }
63
64 void GLES2Context::CancelAnimationFrames() {
65 command_buffer_.CancelAnimationFrames();
66 }
67
68 void GLES2Context::ContextLost() { lost_callback_(closure_); } 58 void GLES2Context::ContextLost() { lost_callback_(closure_); }
69 59
70 void GLES2Context::DrawAnimationFrame() { animation_callback_(closure_); }
71
72 } // namespace gles2 60 } // namespace gles2
73 } // namespace mojo 61 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698