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 "gpu/command_buffer/tests/gl_manager.h" | 5 #include "gpu/command_buffer/tests/gl_manager.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/at_exit.h" | 15 #include "base/at_exit.h" |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/memory/ptr_util.h" |
17 #include "base/memory/ref_counted_memory.h" | 18 #include "base/memory/ref_counted_memory.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 20 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
20 #include "gpu/command_buffer/client/gles2_implementation.h" | 21 #include "gpu/command_buffer/client/gles2_implementation.h" |
21 #include "gpu/command_buffer/client/gles2_lib.h" | 22 #include "gpu/command_buffer/client/gles2_lib.h" |
22 #include "gpu/command_buffer/client/transfer_buffer.h" | 23 #include "gpu/command_buffer/client/transfer_buffer.h" |
23 #include "gpu/command_buffer/common/constants.h" | 24 #include "gpu/command_buffer/common/constants.h" |
24 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
25 #include "gpu/command_buffer/common/sync_token.h" | 26 #include "gpu/command_buffer/common/sync_token.h" |
26 #include "gpu/command_buffer/common/value_state.h" | 27 #include "gpu/command_buffer/common/value_state.h" |
(...skipping 180 matching lines...) Loading... |
207 delete base_surface_; | 208 delete base_surface_; |
208 base_surface_ = NULL; | 209 base_surface_ = NULL; |
209 } | 210 } |
210 if (base_context_) { | 211 if (base_context_) { |
211 delete base_context_; | 212 delete base_context_; |
212 base_context_ = NULL; | 213 base_context_ = NULL; |
213 } | 214 } |
214 } | 215 } |
215 } | 216 } |
216 | 217 |
217 scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( | 218 std::unique_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( |
218 const gfx::Size& size, | 219 const gfx::Size& size, |
219 gfx::BufferFormat format) { | 220 gfx::BufferFormat format) { |
220 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
221 if (use_iosurface_memory_buffers_) { | 222 if (use_iosurface_memory_buffers_) { |
222 return make_scoped_ptr<gfx::GpuMemoryBuffer>( | 223 return base::WrapUnique<gfx::GpuMemoryBuffer>( |
223 new IOSurfaceGpuMemoryBuffer(size, format)); | 224 new IOSurfaceGpuMemoryBuffer(size, format)); |
224 } | 225 } |
225 #endif // defined(OS_MACOSX) | 226 #endif // defined(OS_MACOSX) |
226 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0); | 227 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0); |
227 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 228 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); |
228 return make_scoped_ptr<gfx::GpuMemoryBuffer>( | 229 return base::WrapUnique<gfx::GpuMemoryBuffer>( |
229 new GpuMemoryBufferImpl(bytes.get(), size, format)); | 230 new GpuMemoryBufferImpl(bytes.get(), size, format)); |
230 } | 231 } |
231 | 232 |
232 void GLManager::Initialize(const GLManager::Options& options) { | 233 void GLManager::Initialize(const GLManager::Options& options) { |
233 InitializeWithCommandLine(options, nullptr); | 234 InitializeWithCommandLine(options, nullptr); |
234 } | 235 } |
235 | 236 |
236 void GLManager::InitializeWithCommandLine(const GLManager::Options& options, | 237 void GLManager::InitializeWithCommandLine(const GLManager::Options& options, |
237 base::CommandLine* command_line) { | 238 base::CommandLine* command_line) { |
238 const int32_t kCommandBufferSize = 1024 * 1024; | 239 const int32_t kCommandBufferSize = 1024 * 1024; |
(...skipping 316 matching lines...) Loading... |
555 DCHECK(image_manager); | 556 DCHECK(image_manager); |
556 image_manager->AddImage(gl_image.get(), new_id); | 557 image_manager->AddImage(gl_image.get(), new_id); |
557 return new_id; | 558 return new_id; |
558 } | 559 } |
559 | 560 |
560 int32_t GLManager::CreateGpuMemoryBufferImage(size_t width, | 561 int32_t GLManager::CreateGpuMemoryBufferImage(size_t width, |
561 size_t height, | 562 size_t height, |
562 unsigned internalformat, | 563 unsigned internalformat, |
563 unsigned usage) { | 564 unsigned usage) { |
564 DCHECK_EQ(usage, static_cast<unsigned>(GL_READ_WRITE_CHROMIUM)); | 565 DCHECK_EQ(usage, static_cast<unsigned>(GL_READ_WRITE_CHROMIUM)); |
565 scoped_ptr<gfx::GpuMemoryBuffer> buffer = CreateGpuMemoryBuffer( | 566 std::unique_ptr<gfx::GpuMemoryBuffer> buffer = CreateGpuMemoryBuffer( |
566 gfx::Size(width, height), gfx::BufferFormat::RGBA_8888); | 567 gfx::Size(width, height), gfx::BufferFormat::RGBA_8888); |
567 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 568 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
568 } | 569 } |
569 | 570 |
570 void GLManager::DestroyImage(int32_t id) { | 571 void GLManager::DestroyImage(int32_t id) { |
571 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 572 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
572 DCHECK(image_manager); | 573 DCHECK(image_manager); |
573 image_manager->RemoveImage(id); | 574 image_manager->RemoveImage(id); |
574 } | 575 } |
575 | 576 |
(...skipping 58 matching lines...) Loading... |
634 | 635 |
635 // Something went wrong, just run the callback now. | 636 // Something went wrong, just run the callback now. |
636 callback.Run(); | 637 callback.Run(); |
637 } | 638 } |
638 | 639 |
639 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { | 640 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { |
640 return false; | 641 return false; |
641 } | 642 } |
642 | 643 |
643 } // namespace gpu | 644 } // namespace gpu |
OLD | NEW |