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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_format_test.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 4 years, 12 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This file contains unit tests for gles2 commmands 5 // This file contains unit tests for gles2 commmands
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <limits> 10 #include <limits>
8 11
9 #include "base/bind.h" 12 #include "base/bind.h"
10 #include "base/location.h" 13 #include "base/location.h"
11 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
12 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
14 #include "gpu/command_buffer/common/gles2_cmd_format.h" 17 #include "gpu/command_buffer/common/gles2_cmd_format.h"
15 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
16 19
(...skipping 26 matching lines...) Expand all
43 46
44 void CheckBytesWrittenMatchesExpectedSize( 47 void CheckBytesWrittenMatchesExpectedSize(
45 const void* end, size_t expected_size) { 48 const void* end, size_t expected_size) {
46 CheckBytesWritten(end, expected_size, expected_size); 49 CheckBytesWritten(end, expected_size, expected_size);
47 } 50 }
48 51
49 private: 52 private:
50 unsigned char buffer_[1024]; 53 unsigned char buffer_[1024];
51 }; 54 };
52 55
53 void SignalCompletion(uint32* assigned_async_token_ptr, 56 void SignalCompletion(uint32_t* assigned_async_token_ptr,
54 uint32 async_token, 57 uint32_t async_token,
55 AsyncUploadSync* sync) { 58 AsyncUploadSync* sync) {
56 EXPECT_EQ(async_token, *assigned_async_token_ptr); 59 EXPECT_EQ(async_token, *assigned_async_token_ptr);
57 sync->SetAsyncUploadToken(async_token); 60 sync->SetAsyncUploadToken(async_token);
58 } 61 }
59 62
60 TEST(GLES2FormatAsyncUploadSyncTest, AsyncUploadSync) { 63 TEST(GLES2FormatAsyncUploadSyncTest, AsyncUploadSync) {
61 const size_t kSize = 10; 64 const size_t kSize = 10;
62 const size_t kCount = 1000; 65 const size_t kCount = 1000;
63 66
64 base::Thread thread("GLES2FormatUploadSyncTest - Fake Upload Thread"); 67 base::Thread thread("GLES2FormatUploadSyncTest - Fake Upload Thread");
65 thread.Start(); 68 thread.Start();
66 69
67 // Run the same test 50 times so we retest the wrap as well. 70 // Run the same test 50 times so we retest the wrap as well.
68 for (size_t test_run = 0; test_run < 50; ++test_run) { 71 for (size_t test_run = 0; test_run < 50; ++test_run) {
69 AsyncUploadSync sync; 72 AsyncUploadSync sync;
70 sync.Reset(); 73 sync.Reset();
71 74
72 uint32 buffer_tokens[kSize]; 75 uint32_t buffer_tokens[kSize];
73 memset(buffer_tokens, 0, sizeof(buffer_tokens)); 76 memset(buffer_tokens, 0, sizeof(buffer_tokens));
74 77
75 // Start with a token large enough so that we'll wrap. 78 // Start with a token large enough so that we'll wrap.
76 uint32 async_token = std::numeric_limits<uint32>::max() - kCount / 2; 79 uint32_t async_token = std::numeric_limits<uint32_t>::max() - kCount / 2;
77 80
78 // Set initial async token. 81 // Set initial async token.
79 sync.SetAsyncUploadToken(async_token); 82 sync.SetAsyncUploadToken(async_token);
80 83
81 for (size_t i = 0; i < kCount; ++i) { 84 for (size_t i = 0; i < kCount; ++i) {
82 size_t buffer = i % kSize; 85 size_t buffer = i % kSize;
83 86
84 // Loop until previous async token has passed if any was set. 87 // Loop until previous async token has passed if any was set.
85 while (buffer_tokens[buffer] && 88 while (buffer_tokens[buffer] &&
86 !sync.HasAsyncUploadTokenPassed(buffer_tokens[buffer])) 89 !sync.HasAsyncUploadTokenPassed(buffer_tokens[buffer]))
(...skipping 26 matching lines...) Expand all
113 // GCC requires these declarations, but MSVC requires they not be present 116 // GCC requires these declarations, but MSVC requires they not be present
114 #ifndef _MSC_VER 117 #ifndef _MSC_VER
115 const unsigned char GLES2FormatTest::kInitialValue; 118 const unsigned char GLES2FormatTest::kInitialValue;
116 #endif 119 #endif
117 120
118 #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h" 121 #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h"
119 122
120 } // namespace gles2 123 } // namespace gles2
121 } // namespace gpu 124 } // namespace gpu
122 125
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_format_autogen.h ('k') | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698