OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gl/async_pixel_transfer_delegate_stub.h" | 5 #include "ui/gl/async_pixel_transfer_delegate_stub.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 | 10 |
11 using base::SharedMemory; | 11 using base::SharedMemory; |
12 using base::SharedMemoryHandle; | 12 using base::SharedMemoryHandle; |
13 | 13 |
14 namespace { | 14 namespace { |
15 // Gets the address of the data from shared memory. | 15 // Gets the address of the data from shared memory. |
16 void* GetAddress(SharedMemory* shared_memory, | 16 void* GetAddress(SharedMemory* shared_memory, |
17 uint32 shm_size, | 17 uint32 shm_size, |
18 uint32 shm_data_offset, | 18 uint32 shm_data_offset, |
19 uint32 shm_data_size) { | 19 uint32 shm_data_size) { |
20 // Memory bounds have already been validated, so there | 20 // Memory bounds have already been validated, so there |
21 // is just DCHECKS here. | 21 // are just DCHECKS here. |
22 DCHECK(shared_memory); | 22 DCHECK(shared_memory); |
23 DCHECK(shared_memory->memory()); | 23 DCHECK(shared_memory->memory()); |
24 DCHECK_LE(shm_data_offset + shm_data_size, shm_size); | 24 DCHECK_LE(shm_data_offset + shm_data_size, shm_size); |
25 return static_cast<int8*>(shared_memory->memory()) + shm_data_offset; | 25 return static_cast<int8*>(shared_memory->memory()) + shm_data_offset; |
26 } | 26 } |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 namespace gfx { | 29 namespace gfx { |
30 | 30 |
31 #if !defined(OS_ANDROID) | |
32 scoped_ptr<AsyncPixelTransferDelegate> | |
33 AsyncPixelTransferDelegate::Create(gfx::GLContext* context) { | |
34 return AsyncPixelTransferDelegateStub::Create(context); | |
35 } | |
36 #endif | |
37 | |
38 scoped_ptr<AsyncPixelTransferDelegate> | 31 scoped_ptr<AsyncPixelTransferDelegate> |
39 AsyncPixelTransferDelegateStub::Create(gfx::GLContext* context) { | 32 AsyncPixelTransferDelegateStub::Create(gfx::GLContext* context) { |
40 return make_scoped_ptr( | 33 return make_scoped_ptr( |
41 static_cast<AsyncPixelTransferDelegate*>( | 34 static_cast<AsyncPixelTransferDelegate*>( |
42 new AsyncPixelTransferDelegateStub())); | 35 new AsyncPixelTransferDelegateStub())); |
43 } | 36 } |
44 | 37 |
45 AsyncTransferStateStub::AsyncTransferStateStub(GLuint texture_id) { | 38 AsyncTransferStateStub::AsyncTransferStateStub(GLuint texture_id) { |
46 } | 39 } |
47 | 40 |
48 AsyncTransferStateStub::~AsyncTransferStateStub() { | 41 AsyncTransferStateStub::~AsyncTransferStateStub() { |
49 } | 42 } |
50 | 43 |
51 bool AsyncTransferStateStub::TransferIsInProgress() { | 44 bool AsyncTransferStateStub::TransferIsInProgress() { |
52 return false; | 45 return false; |
53 } | 46 } |
54 | 47 |
55 AsyncPixelTransferDelegateStub::AsyncPixelTransferDelegateStub() | 48 AsyncPixelTransferDelegateStub::AsyncPixelTransferDelegateStub() |
56 : texture_upload_count_(0) { | 49 : texture_upload_count_(0) { |
57 } | 50 } |
58 | 51 |
59 AsyncPixelTransferDelegateStub::~AsyncPixelTransferDelegateStub() { | 52 AsyncPixelTransferDelegateStub::~AsyncPixelTransferDelegateStub() { |
60 } | 53 } |
61 | 54 |
62 AsyncPixelTransferState* | 55 AsyncPixelTransferState* |
63 AsyncPixelTransferDelegateStub::CreateRawPixelTransferState( | 56 AsyncPixelTransferDelegateStub::CreateRawPixelTransferState( |
64 GLuint texture_id, | 57 GLuint texture_id, |
65 const AsyncTexImage2DParams& define_params) { | 58 const AsyncTexImage2DParams& define_params) { |
66 return static_cast<AsyncPixelTransferState*>( | 59 return new AsyncTransferStateStub(texture_id); |
67 new AsyncTransferStateStub(texture_id)); | |
68 } | 60 } |
69 | 61 |
70 bool AsyncPixelTransferDelegateStub::BindCompletedAsyncTransfers() { | 62 bool AsyncPixelTransferDelegateStub::BindCompletedAsyncTransfers() { |
71 // Everything is already bound. | 63 // Everything is already bound. |
72 return false; | 64 return false; |
73 } | 65 } |
74 | 66 |
75 void AsyncPixelTransferDelegateStub::AsyncNotifyCompletion( | 67 void AsyncPixelTransferDelegateStub::AsyncNotifyCompletion( |
76 const AsyncMemoryParams& mem_params, | 68 const AsyncMemoryParams& mem_params, |
77 const CompletionCallback& callback) { | 69 const CompletionCallback& callback) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 126 } |
135 | 127 |
136 uint32 AsyncPixelTransferDelegateStub::GetTextureUploadCount() { | 128 uint32 AsyncPixelTransferDelegateStub::GetTextureUploadCount() { |
137 return texture_upload_count_; | 129 return texture_upload_count_; |
138 } | 130 } |
139 | 131 |
140 base::TimeDelta AsyncPixelTransferDelegateStub::GetTotalTextureUploadTime() { | 132 base::TimeDelta AsyncPixelTransferDelegateStub::GetTotalTextureUploadTime() { |
141 return total_texture_upload_time_; | 133 return total_texture_upload_time_; |
142 } | 134 } |
143 | 135 |
| 136 bool AsyncPixelTransferDelegateStub::ProcessMorePendingTransfers() { |
| 137 return false; |
| 138 } |
| 139 |
| 140 bool AsyncPixelTransferDelegateStub::NeedsProcessMorePendingTransfers() { |
| 141 return false; |
| 142 } |
| 143 |
144 } // namespace gfx | 144 } // namespace gfx |
145 | 145 |
OLD | NEW |