Chromium Code Reviews| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <limits> | 13 #include <limits> |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 #include <string.h> | 15 #include <string.h> |
| 16 #include <GLES2/gl2ext.h> | 16 #include <GLES2/gl2ext.h> |
| 17 #include <GLES2/gl2extchromium.h> | 17 #include <GLES2/gl2extchromium.h> |
| 18 #include "gpu/command_buffer/client/buffer_tracker.h" | 18 #include "gpu/command_buffer/client/buffer_tracker.h" |
| 19 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" | 19 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" |
| 20 #include "gpu/command_buffer/client/mapped_memory.h" | 20 #include "gpu/command_buffer/client/mapped_memory.h" |
| 21 #include "gpu/command_buffer/client/program_info_manager.h" | 21 #include "gpu/command_buffer/client/program_info_manager.h" |
| 22 #include "gpu/command_buffer/client/query_tracker.h" | 22 #include "gpu/command_buffer/client/query_tracker.h" |
| 23 #include "gpu/command_buffer/client/transfer_buffer.h" | 23 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 24 #include "gpu/command_buffer/client/vertex_array_object_manager.h" | 24 #include "gpu/command_buffer/client/vertex_array_object_manager.h" |
| 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 26 #include "gpu/command_buffer/common/trace_event.h" | 26 #include "gpu/command_buffer/common/trace_event.h" |
| 27 | |
| 28 #if defined(OS_ANDROID) | |
| 29 #include "ui/gfx/android/device_display_info.h" | |
| 30 #endif | |
| 31 | |
| 27 #include "ui/gfx/gpu_memory_buffer.h" | 32 #include "ui/gfx/gpu_memory_buffer.h" |
| 28 | 33 |
| 29 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 34 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 30 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS | 35 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS |
| 31 #endif | 36 #endif |
| 32 | 37 |
| 33 #if defined(GPU_CLIENT_DEBUG) | 38 #if defined(GPU_CLIENT_DEBUG) |
| 34 #include "ui/gl/gl_switches.h" | 39 #include "ui/gl/gl_switches.h" |
| 35 #include "base/command_line.h" | 40 #include "base/command_line.h" |
| 36 #endif | 41 #endif |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 if (!transfer_buffer_->Initialize( | 146 if (!transfer_buffer_->Initialize( |
| 142 starting_transfer_buffer_size, | 147 starting_transfer_buffer_size, |
| 143 kStartingOffset, | 148 kStartingOffset, |
| 144 min_transfer_buffer_size, | 149 min_transfer_buffer_size, |
| 145 max_transfer_buffer_size, | 150 max_transfer_buffer_size, |
| 146 kAlignment, | 151 kAlignment, |
| 147 kSizeToFlush)) { | 152 kSizeToFlush)) { |
| 148 return false; | 153 return false; |
| 149 } | 154 } |
| 150 | 155 |
| 156 #if defined(OS_ANDROID) | |
|
no sievers
2013/08/15 01:07:15
there is an ifdef android in a different place now
kaanb
2013/08/15 01:21:05
If we need to base this on the screen size of the
piman
2013/08/15 02:49:03
Agreed with Daniel, please inject this value inste
kaanb
2013/08/16 22:50:44
Done.
| |
| 157 static const size_t kBytesPerPixel = 4; | |
| 158 gfx::DeviceDisplayInfo display_info; | |
| 159 size_t full_screen_texture_size_in_bytes = | |
| 160 display_info.GetDisplayHeight() * | |
| 161 display_info.GetDisplayWidth() * | |
| 162 kBytesPerPixel; | |
| 163 mapped_memory_.reset( | |
| 164 new MappedMemoryManager(helper_, | |
| 165 2 * full_screen_texture_size_in_bytes)); | |
| 166 #else | |
| 151 mapped_memory_.reset(new MappedMemoryManager(helper_)); | 167 mapped_memory_.reset(new MappedMemoryManager(helper_)); |
| 152 SetSharedMemoryChunkSizeMultiple(1024 * 1024 * 2); | 168 #endif |
| 169 mapped_memory_->set_chunk_size_multiple(2 * 1024 * 1024); | |
| 153 | 170 |
| 154 if (!QueryAndCacheStaticState()) | 171 if (!QueryAndCacheStaticState()) |
| 155 return false; | 172 return false; |
| 156 | 173 |
| 157 util_.set_num_compressed_texture_formats( | 174 util_.set_num_compressed_texture_formats( |
| 158 static_state_.int_state.num_compressed_texture_formats); | 175 static_state_.int_state.num_compressed_texture_formats); |
| 159 util_.set_num_shader_binary_formats( | 176 util_.set_num_shader_binary_formats( |
| 160 static_state_.int_state.num_shader_binary_formats); | 177 static_state_.int_state.num_shader_binary_formats); |
| 161 | 178 |
| 162 texture_units_.reset( | 179 texture_units_.reset( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 } | 299 } |
| 283 | 300 |
| 284 int32 GLES2Implementation::GetResultShmId() { | 301 int32 GLES2Implementation::GetResultShmId() { |
| 285 return transfer_buffer_->GetShmId(); | 302 return transfer_buffer_->GetShmId(); |
| 286 } | 303 } |
| 287 | 304 |
| 288 uint32 GLES2Implementation::GetResultShmOffset() { | 305 uint32 GLES2Implementation::GetResultShmOffset() { |
| 289 return transfer_buffer_->GetResultOffset(); | 306 return transfer_buffer_->GetResultOffset(); |
| 290 } | 307 } |
| 291 | 308 |
| 292 void GLES2Implementation::SetSharedMemoryChunkSizeMultiple( | |
| 293 unsigned int multiple) { | |
| 294 mapped_memory_->set_chunk_size_multiple(multiple); | |
| 295 } | |
| 296 | |
| 297 void GLES2Implementation::FreeUnusedSharedMemory() { | 309 void GLES2Implementation::FreeUnusedSharedMemory() { |
| 298 mapped_memory_->FreeUnused(); | 310 mapped_memory_->FreeUnused(); |
| 299 } | 311 } |
| 300 | 312 |
| 301 void GLES2Implementation::FreeEverything() { | 313 void GLES2Implementation::FreeEverything() { |
| 302 WaitForCmd(); | 314 WaitForCmd(); |
| 303 query_tracker_->Shrink(); | 315 query_tracker_->Shrink(); |
| 304 FreeUnusedSharedMemory(); | 316 FreeUnusedSharedMemory(); |
| 305 transfer_buffer_->Free(); | 317 transfer_buffer_->Free(); |
| 306 helper_->FreeRingBuffer(); | 318 helper_->FreeRingBuffer(); |
| (...skipping 3515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3822 CheckGLError(); | 3834 CheckGLError(); |
| 3823 } | 3835 } |
| 3824 | 3836 |
| 3825 // Include the auto-generated part of this file. We split this because it means | 3837 // Include the auto-generated part of this file. We split this because it means |
| 3826 // we can easily edit the non-auto generated parts right here in this file | 3838 // we can easily edit the non-auto generated parts right here in this file |
| 3827 // instead of having to edit some template or the code generator. | 3839 // instead of having to edit some template or the code generator. |
| 3828 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 3840 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 3829 | 3841 |
| 3830 } // namespace gles2 | 3842 } // namespace gles2 |
| 3831 } // namespace gpu | 3843 } // namespace gpu |
| OLD | NEW |