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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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 (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>
11 #include <stdint.h>
10 12
11 #include <vector> 13 #include <vector>
12 14
13 #include "base/at_exit.h" 15 #include "base/at_exit.h"
14 #include "base/bind.h" 16 #include "base/bind.h"
15 #include "base/memory/ref_counted_memory.h" 17 #include "base/memory/ref_counted_memory.h"
16 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 18 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
17 #include "gpu/command_buffer/client/gles2_implementation.h" 19 #include "gpu/command_buffer/client/gles2_implementation.h"
18 #include "gpu/command_buffer/client/gles2_lib.h" 20 #include "gpu/command_buffer/client/gles2_lib.h"
19 #include "gpu/command_buffer/client/transfer_buffer.h" 21 #include "gpu/command_buffer/client/transfer_buffer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 59
58 // Overridden from gfx::GpuMemoryBuffer: 60 // Overridden from gfx::GpuMemoryBuffer:
59 bool Map() override { 61 bool Map() override {
60 DCHECK(!mapped_); 62 DCHECK(!mapped_);
61 mapped_ = true; 63 mapped_ = true;
62 return true; 64 return true;
63 } 65 }
64 void* memory(size_t plane) override { 66 void* memory(size_t plane) override {
65 DCHECK(mapped_); 67 DCHECK(mapped_);
66 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 68 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
67 return reinterpret_cast<uint8*>(&bytes_->data().front()) + 69 return reinterpret_cast<uint8_t*>(&bytes_->data().front()) +
68 gfx::BufferOffsetForBufferFormat(size_, format_, plane); 70 gfx::BufferOffsetForBufferFormat(size_, format_, plane);
69 } 71 }
70 void Unmap() override { 72 void Unmap() override {
71 DCHECK(mapped_); 73 DCHECK(mapped_);
72 mapped_ = false; 74 mapped_ = false;
73 } 75 }
74 gfx::Size GetSize() const override { return size_; } 76 gfx::Size GetSize() const override { return size_; }
75 gfx::BufferFormat GetFormat() const override { return format_; } 77 gfx::BufferFormat GetFormat() const override { return format_; }
76 int stride(size_t plane) const override { 78 int stride(size_t plane) const override {
77 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); 79 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
78 return gfx::RowSizeForBufferFormat(size_.width(), format_, plane); 80 return gfx::RowSizeForBufferFormat(size_.width(), format_, plane);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 delete base_context_; 142 delete base_context_;
141 base_context_ = NULL; 143 base_context_ = NULL;
142 } 144 }
143 } 145 }
144 } 146 }
145 147
146 // static 148 // static
147 scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( 149 scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer(
148 const gfx::Size& size, 150 const gfx::Size& size,
149 gfx::BufferFormat format) { 151 gfx::BufferFormat format) {
150 std::vector<uint8> data(gfx::BufferSizeForBufferFormat(size, format), 0); 152 std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0);
151 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); 153 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data));
152 return make_scoped_ptr<gfx::GpuMemoryBuffer>( 154 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
153 new GpuMemoryBufferImpl(bytes.get(), size, format)); 155 new GpuMemoryBufferImpl(bytes.get(), size, format));
154 } 156 }
155 157
156 void GLManager::Initialize(const GLManager::Options& options) { 158 void GLManager::Initialize(const GLManager::Options& options) {
157 InitializeWithCommandLine(options, nullptr); 159 InitializeWithCommandLine(options, nullptr);
158 } 160 }
159 161
160 void GLManager::InitializeWithCommandLine(const GLManager::Options& options, 162 void GLManager::InitializeWithCommandLine(const GLManager::Options& options,
161 base::CommandLine* command_line) { 163 base::CommandLine* command_line) {
162 const int32 kCommandBufferSize = 1024 * 1024; 164 const int32_t kCommandBufferSize = 1024 * 1024;
163 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; 165 const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
164 const size_t kMinTransferBufferSize = 1 * 256 * 1024; 166 const size_t kMinTransferBufferSize = 1 * 256 * 1024;
165 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; 167 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
166 168
167 context_lost_allowed_ = options.context_lost_allowed; 169 context_lost_allowed_ = options.context_lost_allowed;
168 170
169 gles2::MailboxManager* mailbox_manager = NULL; 171 gles2::MailboxManager* mailbox_manager = NULL;
170 if (options.share_mailbox_manager) { 172 if (options.share_mailbox_manager) {
171 mailbox_manager = options.share_mailbox_manager->mailbox_manager(); 173 mailbox_manager = options.share_mailbox_manager->mailbox_manager();
172 } else if (options.share_group_manager) { 174 } else if (options.share_group_manager) {
(...skipping 19 matching lines...) Expand all
192 if (options.virtual_manager) { 194 if (options.virtual_manager) {
193 real_gl_context = options.virtual_manager->context(); 195 real_gl_context = options.virtual_manager->context();
194 } 196 }
195 197
196 mailbox_manager_ = 198 mailbox_manager_ =
197 mailbox_manager ? mailbox_manager : new gles2::MailboxManagerImpl; 199 mailbox_manager ? mailbox_manager : new gles2::MailboxManagerImpl;
198 share_group_ = 200 share_group_ =
199 share_group ? share_group : new gfx::GLShareGroup; 201 share_group ? share_group : new gfx::GLShareGroup;
200 202
201 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 203 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu);
202 std::vector<int32> attribs; 204 std::vector<int32_t> attribs;
203 gles2::ContextCreationAttribHelper attrib_helper; 205 gles2::ContextCreationAttribHelper attrib_helper;
204 attrib_helper.red_size = 8; 206 attrib_helper.red_size = 8;
205 attrib_helper.green_size = 8; 207 attrib_helper.green_size = 8;
206 attrib_helper.blue_size = 8; 208 attrib_helper.blue_size = 8;
207 attrib_helper.alpha_size = 8; 209 attrib_helper.alpha_size = 8;
208 attrib_helper.depth_size = 16; 210 attrib_helper.depth_size = 16;
209 attrib_helper.stencil_size = 8; 211 attrib_helper.stencil_size = 8;
210 attrib_helper.context_type = options.context_type; 212 attrib_helper.context_type = options.context_type;
211 213
212 attrib_helper.Serialize(&attribs); 214 attrib_helper.Serialize(&attribs);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (!context_lost_allowed_) { 412 if (!context_lost_allowed_) {
411 ASSERT_EQ(::gpu::error::kNoError, state.error); 413 ASSERT_EQ(::gpu::error::kNoError, state.error);
412 } 414 }
413 415
414 if (sync_point_manager_) { 416 if (sync_point_manager_) {
415 // Finish processing order number here. 417 // Finish processing order number here.
416 sync_point_order_data_->FinishProcessingOrderNumber(order_num); 418 sync_point_order_data_->FinishProcessingOrderNumber(order_num);
417 } 419 }
418 } 420 }
419 421
420 bool GLManager::GetBufferChanged(int32 transfer_buffer_id) { 422 bool GLManager::GetBufferChanged(int32_t transfer_buffer_id) {
421 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 423 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
422 } 424 }
423 425
424 Capabilities GLManager::GetCapabilities() { 426 Capabilities GLManager::GetCapabilities() {
425 return decoder_->GetCapabilities(); 427 return decoder_->GetCapabilities();
426 } 428 }
427 429
428 int32 GLManager::CreateImage(ClientBuffer buffer, 430 int32_t GLManager::CreateImage(ClientBuffer buffer,
429 size_t width, 431 size_t width,
430 size_t height, 432 size_t height,
431 unsigned internalformat) { 433 unsigned internalformat) {
432 GpuMemoryBufferImpl* gpu_memory_buffer = 434 GpuMemoryBufferImpl* gpu_memory_buffer =
433 GpuMemoryBufferImpl::FromClientBuffer(buffer); 435 GpuMemoryBufferImpl::FromClientBuffer(buffer);
434 436
435 scoped_refptr<gl::GLImageRefCountedMemory> image( 437 scoped_refptr<gl::GLImageRefCountedMemory> image(
436 new gl::GLImageRefCountedMemory(gfx::Size(width, height), 438 new gl::GLImageRefCountedMemory(gfx::Size(width, height),
437 internalformat)); 439 internalformat));
438 if (!image->Initialize(gpu_memory_buffer->bytes(), 440 if (!image->Initialize(gpu_memory_buffer->bytes(),
439 gpu_memory_buffer->GetFormat())) { 441 gpu_memory_buffer->GetFormat())) {
440 return -1; 442 return -1;
441 } 443 }
442 444
443 static int32 next_id = 1; 445 static int32_t next_id = 1;
444 int32 new_id = next_id++; 446 int32_t new_id = next_id++;
445 447
446 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 448 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
447 DCHECK(image_manager); 449 DCHECK(image_manager);
448 image_manager->AddImage(image.get(), new_id); 450 image_manager->AddImage(image.get(), new_id);
449 return new_id; 451 return new_id;
450 } 452 }
451 453
452 int32 GLManager::CreateGpuMemoryBufferImage(size_t width, 454 int32_t GLManager::CreateGpuMemoryBufferImage(size_t width,
453 size_t height, 455 size_t height,
454 unsigned internalformat, 456 unsigned internalformat,
455 unsigned usage) { 457 unsigned usage) {
456 DCHECK_EQ(usage, static_cast<unsigned>(GL_READ_WRITE_CHROMIUM)); 458 DCHECK_EQ(usage, static_cast<unsigned>(GL_READ_WRITE_CHROMIUM));
457 scoped_ptr<gfx::GpuMemoryBuffer> buffer = GLManager::CreateGpuMemoryBuffer( 459 scoped_ptr<gfx::GpuMemoryBuffer> buffer = GLManager::CreateGpuMemoryBuffer(
458 gfx::Size(width, height), gfx::BufferFormat::RGBA_8888); 460 gfx::Size(width, height), gfx::BufferFormat::RGBA_8888);
459 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); 461 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
460 } 462 }
461 463
462 void GLManager::DestroyImage(int32 id) { 464 void GLManager::DestroyImage(int32_t id) {
463 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 465 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
464 DCHECK(image_manager); 466 DCHECK(image_manager);
465 image_manager->RemoveImage(id); 467 image_manager->RemoveImage(id);
466 } 468 }
467 469
468 uint32 GLManager::InsertSyncPoint() { 470 uint32_t GLManager::InsertSyncPoint() {
469 NOTIMPLEMENTED(); 471 NOTIMPLEMENTED();
470 return 0u; 472 return 0u;
471 } 473 }
472 474
473 uint32 GLManager::InsertFutureSyncPoint() { 475 uint32_t GLManager::InsertFutureSyncPoint() {
474 NOTIMPLEMENTED(); 476 NOTIMPLEMENTED();
475 return 0u; 477 return 0u;
476 } 478 }
477 479
478 void GLManager::RetireSyncPoint(uint32 sync_point) { 480 void GLManager::RetireSyncPoint(uint32_t sync_point) {
479 NOTIMPLEMENTED(); 481 NOTIMPLEMENTED();
480 } 482 }
481 483
482 void GLManager::SignalSyncPoint(uint32 sync_point, 484 void GLManager::SignalSyncPoint(uint32_t sync_point,
483 const base::Closure& callback) { 485 const base::Closure& callback) {
484 NOTIMPLEMENTED(); 486 NOTIMPLEMENTED();
485 } 487 }
486 488
487 void GLManager::SignalQuery(uint32 query, const base::Closure& callback) { 489 void GLManager::SignalQuery(uint32_t query, const base::Closure& callback) {
488 NOTIMPLEMENTED(); 490 NOTIMPLEMENTED();
489 } 491 }
490 492
491 void GLManager::SetLock(base::Lock*) { 493 void GLManager::SetLock(base::Lock*) {
492 NOTIMPLEMENTED(); 494 NOTIMPLEMENTED();
493 } 495 }
494 496
495 bool GLManager::IsGpuChannelLost() { 497 bool GLManager::IsGpuChannelLost() {
496 NOTIMPLEMENTED(); 498 NOTIMPLEMENTED();
497 return false; 499 return false;
(...skipping 30 matching lines...) Expand all
528 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token, 530 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token,
529 const base::Closure& callback) { 531 const base::Closure& callback) {
530 NOTIMPLEMENTED(); 532 NOTIMPLEMENTED();
531 } 533 }
532 534
533 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 535 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
534 return false; 536 return false;
535 } 537 }
536 538
537 } // namespace gpu 539 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_pointcoord_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698