summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukasza <lukasza@chromium.org>2016-02-16 11:17:22 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-16 19:18:41 +0000
commit2573ce7d143bee9c1f88dac18b9213c03597daae (patch)
tree0ccd826244c171cab6ca06c346956c763bb93490
parent601699b4a642b051a4cddf63732cb3c84ab44359 (diff)
downloadchromium_src-2573ce7d143bee9c1f88dac18b9213c03597daae.zip
chromium_src-2573ce7d143bee9c1f88dac18b9213c03597daae.tar.gz
chromium_src-2573ce7d143bee9c1f88dac18b9213c03597daae.tar.bz2
Introducing gpu::CommandBufferId as a distinct, IdType<...>-based type.
This CL generalizes the pattern used by content::SavePackageId and cc::SurfaceId and puts it into //base/id_type.h. Using this pattern for gpu::CommandBufferId should hopefully help avoid bugs like the mixup fixed by https://crrev.com/365437. BUG=514815, 565545 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel TBR=wolenetz@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/1548443002 Cr-Commit-Position: refs/heads/master@{#375620}
-rw-r--r--cc/layers/texture_layer_unittest.cc13
-rw-r--r--cc/output/gl_renderer_unittest.cc3
-rw-r--r--cc/resources/resource_provider_unittest.cc15
-rw-r--r--cc/resources/video_resource_updater_unittest.cc10
-rw-r--r--cc/test/render_pass_test_utils.cc3
-rw-r--r--cc/test/test_web_graphics_context_3d.cc4
-rw-r--r--cc/trees/layer_tree_host_perftest.cc3
-rw-r--r--components/mus/gles2/command_buffer_driver.cc4
-rw-r--r--components/mus/gles2/command_buffer_driver.h9
-rw-r--r--components/mus/gles2/command_buffer_impl.cc6
-rw-r--r--components/mus/gles2/command_buffer_local.cc9
-rw-r--r--components/mus/gles2/command_buffer_local.h3
-rw-r--r--content/browser/download/save_types.h6
-rw-r--r--content/common/cc_messages_unittest.cc6
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc13
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.h5
-rw-r--r--content/common/gpu/client/gpu_context_tests.h5
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc15
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h11
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/content_tests.gypi1
-rw-r--r--content/renderer/pepper/ppb_graphics_3d_impl.cc13
-rw-r--r--content/renderer/pepper/ppb_graphics_3d_impl.h16
-rw-r--r--content/renderer/pepper/resource_creation_impl.cc2
-rw-r--r--content/renderer/pepper/resource_creation_impl.h2
-rw-r--r--gpu/BUILD.gn1
-rw-r--r--gpu/command_buffer/client/client_test_helper.h2
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc8
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc21
-rw-r--r--gpu/command_buffer/client/gpu_control.h3
-rw-r--r--gpu/command_buffer/common/BUILD.gn3
-rw-r--r--gpu/command_buffer/common/command_buffer_id.h17
-rw-r--r--gpu/command_buffer/common/id_type.h (renamed from content/common/id_type.h)11
-rw-r--r--gpu/command_buffer/common/id_type_unittest.cc (renamed from content/common/id_type_unittest.cc)6
-rw-r--r--gpu/command_buffer/common/sync_token.cc25
-rw-r--r--gpu/command_buffer/common/sync_token.h25
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h6
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.cc7
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.h6
-rw-r--r--gpu/command_buffer/service/mailbox_manager_unittest.cc2
-rw-r--r--gpu/command_buffer/service/sync_point_manager.cc12
-rw-r--r--gpu/command_buffer/service/sync_point_manager.h18
-rw-r--r--gpu/command_buffer/service/sync_point_manager_unittest.cc42
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc7
-rw-r--r--gpu/command_buffer/tests/gl_manager.h6
-rw-r--r--gpu/command_buffer_common.gypi3
-rw-r--r--gpu/gles2_conform_support/egl/display.cc4
-rw-r--r--gpu/gles2_conform_support/egl/display.h2
-rw-r--r--gpu/gpu.gyp1
-rw-r--r--gpu/gpu_ipc.gypi1
-rw-r--r--gpu/ipc/BUILD.gn1
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.cc10
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.h1
-rw-r--r--gpu/ipc/id_type_traits.h42
-rw-r--r--media/base/video_frame_unittest.cc7
-rw-r--r--media/video/gpu_memory_buffer_video_frame_pool_unittest.cc8
-rw-r--r--mojo/converters/surfaces/tests/surface_unittest.cc5
-rw-r--r--mojo/gles2/command_buffer_client_impl.cc8
-rw-r--r--mojo/gles2/command_buffer_client_impl.h5
-rw-r--r--ppapi/proxy/ppapi_command_buffer_proxy.cc4
-rw-r--r--ppapi/proxy/ppapi_command_buffer_proxy.h7
-rw-r--r--ppapi/proxy/ppapi_messages.h3
-rw-r--r--ppapi/proxy/ppb_graphics_3d_proxy.cc19
-rw-r--r--ppapi/proxy/ppb_graphics_3d_proxy.h5
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc2
-rw-r--r--ppapi/proxy/resource_creation_proxy.h2
-rw-r--r--ppapi/thunk/DEPS1
-rw-r--r--ppapi/thunk/resource_creation_api.h3
69 files changed, 349 insertions, 204 deletions
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 0cfedc3..45e5976 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -58,7 +58,8 @@ gpu::Mailbox MailboxFromChar(char value) {
}
gpu::SyncToken SyncTokenFromUInt(uint32_t value) {
- return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0, 0x123, value);
+ return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123), value);
}
class MockLayerTreeHost : public LayerTreeHost {
@@ -145,8 +146,14 @@ struct CommonMailboxObjects {
explicit CommonMailboxObjects(SharedBitmapManager* manager)
: mailbox_name1_(MailboxFromChar('1')),
mailbox_name2_(MailboxFromChar('2')),
- sync_token1_(gpu::CommandBufferNamespace::GPU_IO, 123, 0x234, 1),
- sync_token2_(gpu::CommandBufferNamespace::GPU_IO, 123, 0x234, 2) {
+ sync_token1_(gpu::CommandBufferNamespace::GPU_IO,
+ 123,
+ gpu::CommandBufferId::FromUnsafeValue(0x234),
+ 1),
+ sync_token2_(gpu::CommandBufferNamespace::GPU_IO,
+ 123,
+ gpu::CommandBufferId::FromUnsafeValue(0x234),
+ 2) {
release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
base::Unretained(&mock_callback_),
mailbox_name1_);
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index fd899c7..5d50b0e 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -2185,7 +2185,8 @@ TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
viewport_rect, gfx::Transform());
root_pass->has_transparent_background = false;
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x123, 29);
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123), 29);
TextureMailbox mailbox =
TextureMailbox(gpu::Mailbox::Generate(), sync_token, GL_TEXTURE_2D,
gfx::Size(256, 256), true);
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index a54e125..e971734 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -121,7 +121,8 @@ class TextureStateTrackingContext : public TestWebGraphicsContext3D {
void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override {
gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0,
- 0x123, fence_sync);
+ gpu::CommandBufferId::FromUnsafeValue(0x123),
+ fence_sync);
sync_token_data.SetVerifyFlush();
memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
}
@@ -199,7 +200,8 @@ class ResourceProviderContext : public TestWebGraphicsContext3D {
void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override {
gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0,
- 0x123, fence_sync);
+ gpu::CommandBufferId::FromUnsafeValue(0x123),
+ fence_sync);
sync_token_data.SetVerifyFlush();
// Commit the produceTextureCHROMIUM calls at this point, so that
// they're associated with the sync point.
@@ -2835,7 +2837,8 @@ class ResourceProviderTestTextureMailboxGLFilters
use_image_texture_targets_));
unsigned texture_id = 1;
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12,
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x12),
0x34);
unsigned target = GL_TEXTURE_2D;
const GLuint64 current_fence_sync = context->GetNextFenceSync();
@@ -2978,7 +2981,8 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
gpu_memory_buffer_manager_.get(), NULL, 0, 1,
use_gpu_memory_buffer_resources_, use_image_texture_targets_));
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12, 0x34);
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
const GLuint64 current_fence_sync = context->GetNextFenceSync();
unsigned target = GL_TEXTURE_EXTERNAL_OES;
@@ -3047,7 +3051,8 @@ TEST_P(ResourceProviderTest,
gpu_memory_buffer_manager_.get(), NULL, 0, 1,
use_gpu_memory_buffer_resources_, use_image_texture_targets_));
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12, 0x34);
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34);
const GLuint64 current_fence_sync = context->GetNextFenceSync();
unsigned target = GL_TEXTURE_2D;
diff --git a/cc/resources/video_resource_updater_unittest.cc b/cc/resources/video_resource_updater_unittest.cc
index 2595d5a..98b1fa7 100644
--- a/cc/resources/video_resource_updater_unittest.cc
+++ b/cc/resources/video_resource_updater_unittest.cc
@@ -182,8 +182,9 @@ class VideoResourceUpdaterTest : public testing::Test {
gpu::Mailbox mailbox;
mailbox.name[0] = 51;
- const gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
- 0x123, 7);
+ const gpu::SyncToken sync_token(
+ gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123), 7);
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::WrapNativeTexture(
media::PIXEL_FORMAT_ARGB,
@@ -219,8 +220,9 @@ class VideoResourceUpdaterTest : public testing::Test {
for (int i = 0; i < kPlanesNum; ++i) {
mailbox[i].name[0] = 50 + 1;
}
- const gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
- 0x123, 7);
+ const gpu::SyncToken sync_token(
+ gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123), 7);
const unsigned target = GL_TEXTURE_RECTANGLE_ARB;
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::WrapYUV420NativeTextures(
diff --git a/cc/test/render_pass_test_utils.cc b/cc/test/render_pass_test_utils.cc
index b746ea6..94d0824 100644
--- a/cc/test/render_pass_test_utils.cc
+++ b/cc/test/render_pass_test_utils.cc
@@ -159,7 +159,8 @@ void AddOneOfEveryQuadType(RenderPass* to_pass,
const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
static const gpu::SyncToken kSyncTokenForMailboxTextureQuad(
- gpu::CommandBufferNamespace::GPU_IO, 0, 0x123, 30);
+ gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123), 30);
*sync_token_for_mailbox_tebxture = kSyncTokenForMailboxTextureQuad;
ResourceId resource1 = resource_provider->CreateResource(
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 6375492..b3cd7b8 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -655,8 +655,8 @@ GLuint64 TestWebGraphicsContext3D::insertFenceSync() {
void TestWebGraphicsContext3D::genSyncToken(GLuint64 fence_sync,
GLbyte* sync_token) {
- gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, 0,
- fence_sync);
+ gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId(), fence_sync);
sync_token_data.SetVerifyFlush();
memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
}
diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc
index 556ad63..fa546b2 100644
--- a/cc/trees/layer_tree_host_perftest.cc
+++ b/cc/trees/layer_tree_host_perftest.cc
@@ -297,7 +297,8 @@ class BrowserCompositorInvalidateLayerTreePerfTest
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(&EmptyReleaseCallback));
- gpu::SyncToken next_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1,
+ gpu::SyncToken next_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(1),
next_fence_sync_);
next_sync_token.SetVerifyFlush();
TextureMailbox mailbox(gpu_mailbox, next_sync_token, GL_TEXTURE_2D);
diff --git a/components/mus/gles2/command_buffer_driver.cc b/components/mus/gles2/command_buffer_driver.cc
index a909517..e9c6a50 100644
--- a/components/mus/gles2/command_buffer_driver.cc
+++ b/components/mus/gles2/command_buffer_driver.cc
@@ -53,7 +53,7 @@ CommandBufferDriver::Client::~Client() {}
CommandBufferDriver::CommandBufferDriver(
gpu::CommandBufferNamespace command_buffer_namespace,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
gfx::AcceleratedWidget widget,
scoped_refptr<GpuState> gpu_state)
: command_buffer_namespace_(command_buffer_namespace),
@@ -450,7 +450,7 @@ void CommandBufferDriver::OnFenceSyncRelease(uint64_t release) {
bool CommandBufferDriver::OnWaitFenceSync(
gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release) {
DCHECK(CalledOnValidThread());
DCHECK(IsScheduled());
diff --git a/components/mus/gles2/command_buffer_driver.h b/components/mus/gles2/command_buffer_driver.h
index 08ee3c1..993d545 100644
--- a/components/mus/gles2/command_buffer_driver.h
+++ b/components/mus/gles2/command_buffer_driver.h
@@ -16,6 +16,7 @@
#include "base/time/time.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/system/buffer.h"
@@ -52,7 +53,7 @@ class CommandBufferDriver : base::NonThreadSafe {
virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0;
};
CommandBufferDriver(gpu::CommandBufferNamespace command_buffer_namespace,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
gfx::AcceleratedWidget widget,
scoped_refptr<GpuState> gpu_state);
~CommandBufferDriver();
@@ -81,7 +82,7 @@ class CommandBufferDriver : base::NonThreadSafe {
gpu::CommandBufferNamespace GetNamespaceID() const {
return command_buffer_namespace_;
}
- uint64_t GetCommandBufferID() const { return command_buffer_id_; }
+ gpu::CommandBufferId GetCommandBufferID() const { return command_buffer_id_; }
gpu::SyncPointOrderData* sync_point_order_data() {
return sync_point_order_data_.get();
}
@@ -113,13 +114,13 @@ class CommandBufferDriver : base::NonThreadSafe {
const base::TimeDelta interval);
void OnFenceSyncRelease(uint64_t release);
bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release);
void OnParseError();
void OnContextLost(uint32_t reason);
const gpu::CommandBufferNamespace command_buffer_namespace_;
- const uint64_t command_buffer_id_;
+ const gpu::CommandBufferId command_buffer_id_;
gfx::AcceleratedWidget widget_;
scoped_ptr<Client> client_;
scoped_ptr<gpu::CommandBufferService> command_buffer_;
diff --git a/components/mus/gles2/command_buffer_impl.cc b/components/mus/gles2/command_buffer_impl.cc
index 0c69eea..adb5845 100644
--- a/components/mus/gles2/command_buffer_impl.cc
+++ b/components/mus/gles2/command_buffer_impl.cc
@@ -189,7 +189,8 @@ void CommandBufferImpl::InitializeOnGpuThread(
void(mojom::CommandBufferInitializeResultPtr)>& callback) {
DCHECK(!driver_);
driver_.reset(new CommandBufferDriver(
- gpu::CommandBufferNamespace::MOJO, ++g_next_command_buffer_id,
+ gpu::CommandBufferNamespace::MOJO,
+ gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id),
gfx::kNullAcceleratedWidget, gpu_state_));
driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this)));
client_ = mojo::MakeProxy(client.PassInterface());
@@ -199,7 +200,8 @@ void CommandBufferImpl::InitializeOnGpuThread(
if (result) {
initialize_result = mojom::CommandBufferInitializeResult::New();
initialize_result->command_buffer_namespace = driver_->GetNamespaceID();
- initialize_result->command_buffer_id = driver_->GetCommandBufferID();
+ initialize_result->command_buffer_id =
+ driver_->GetCommandBufferID().GetUnsafeValue();
initialize_result->capabilities = driver_->GetCapabilities();
}
gpu_state_->control_task_runner()->PostTask(
diff --git a/components/mus/gles2/command_buffer_local.cc b/components/mus/gles2/command_buffer_local.cc
index 649161e..b45b0f9 100644
--- a/components/mus/gles2/command_buffer_local.cc
+++ b/components/mus/gles2/command_buffer_local.cc
@@ -323,7 +323,7 @@ gpu::CommandBufferNamespace CommandBufferLocal::GetNamespaceID() const {
return gpu::CommandBufferNamespace::MOJO_LOCAL;
}
-uint64_t CommandBufferLocal::GetCommandBufferID() const {
+gpu::CommandBufferId CommandBufferLocal::GetCommandBufferID() const {
DCHECK(CalledOnValidThread());
return driver_->GetCommandBufferID();
}
@@ -421,9 +421,10 @@ void CommandBufferLocal::MakeProgressAndUpdateState() {
void CommandBufferLocal::InitializeOnGpuThread(base::WaitableEvent* event,
bool* result) {
- driver_.reset(new CommandBufferDriver(gpu::CommandBufferNamespace::MOJO_LOCAL,
- ++g_next_command_buffer_id, widget_,
- gpu_state_));
+ driver_.reset(new CommandBufferDriver(
+ gpu::CommandBufferNamespace::MOJO_LOCAL,
+ gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id),
+ widget_, gpu_state_));
const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState);
void* memory = nullptr;
mojo::ScopedSharedBufferHandle duped;
diff --git a/components/mus/gles2/command_buffer_local.h b/components/mus/gles2/command_buffer_local.h
index 4743523..2777654 100644
--- a/components/mus/gles2/command_buffer_local.h
+++ b/components/mus/gles2/command_buffer_local.h
@@ -19,6 +19,7 @@
#include "components/mus/public/interfaces/command_buffer.mojom.h"
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
@@ -88,7 +89,7 @@ class CommandBufferLocal : public gpu::CommandBuffer,
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ gpu::CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
diff --git a/content/browser/download/save_types.h b/content/browser/download/save_types.h
index 83d890b..a9ab45c 100644
--- a/content/browser/download/save_types.h
+++ b/content/browser/download/save_types.h
@@ -13,16 +13,16 @@
#include <vector>
#include "base/files/file_path.h"
-#include "content/common/id_type.h"
+#include "gpu/command_buffer/common/id_type.h"
#include "url/gurl.h"
namespace content {
class SavePackage;
-using SavePackageId = IdType32<SavePackage>;
+using SavePackageId = gpu::IdType32<SavePackage>;
class SaveItem;
-using SaveItemId = IdType32<SaveItem>;
+using SaveItemId = gpu::IdType32<SaveItem>;
// Map from save_item_id into final file path.
using FinalNamesMap = std::map<SaveItemId, base::FilePath>;
diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc
index 35218e7..423bfff 100644
--- a/content/common/cc_messages_unittest.cc
+++ b/content/common/cc_messages_unittest.cc
@@ -617,10 +617,12 @@ TEST_F(CCMessagesTest, UnusedSharedQuadStates) {
TEST_F(CCMessagesTest, Resources) {
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
gfx::Size arbitrary_size(757, 1281);
- gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0, 0x123,
+ gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123),
71234838);
arbitrary_token1.SetVerifyFlush();
- gpu::SyncToken arbitrary_token2(gpu::CommandBufferNamespace::GPU_IO, 0, 0x123,
+ gpu::SyncToken arbitrary_token2(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(0x123),
53589793);
arbitrary_token2.SetVerifyFlush();
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 027936f..8f63045 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -20,6 +20,7 @@
#include "content/common/view_messages.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/common/cmd_buffer_common.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "gpu/command_buffer/common/sync_token.h"
@@ -31,8 +32,9 @@ namespace content {
namespace {
-uint64_t CommandBufferProxyID(int channel_id, int32_t route_id) {
- return (static_cast<uint64_t>(channel_id) << 32) | route_id;
+gpu::CommandBufferId CommandBufferProxyID(int channel_id, int32_t route_id) {
+ return gpu::CommandBufferId::FromUnsafeValue(
+ (static_cast<uint64_t>(channel_id) << 32) | route_id);
}
} // namespace
@@ -538,7 +540,7 @@ gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const {
return gpu::CommandBufferNamespace::GPU_IO;
}
-uint64_t CommandBufferProxyImpl::GetCommandBufferID() const {
+gpu::CommandBufferId CommandBufferProxyImpl::GetCommandBufferID() const {
return command_buffer_id_;
}
@@ -602,8 +604,9 @@ void CommandBufferProxyImpl::SignalSyncToken(const gpu::SyncToken& sync_token,
bool CommandBufferProxyImpl::CanWaitUnverifiedSyncToken(
const gpu::SyncToken* sync_token) {
// Can only wait on an unverified sync token if it is from the same channel.
- const uint64_t token_channel = sync_token->command_buffer_id() >> 32;
- const uint64_t channel = command_buffer_id_ >> 32;
+ const uint64_t token_channel =
+ sync_token->command_buffer_id().GetUnsafeValue() >> 32;
+ const uint64_t channel = command_buffer_id_.GetUnsafeValue() >> 32;
if (sync_token->namespace_id() != gpu::CommandBufferNamespace::GPU_IO ||
token_channel != channel) {
return false;
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h
index 2f0ed90..5de26f52 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.h
+++ b/content/common/gpu/client/command_buffer_proxy_impl.h
@@ -22,6 +22,7 @@
#include "base/observer_list.h"
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "ipc/ipc_listener.h"
@@ -121,7 +122,7 @@ class CommandBufferProxyImpl
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ gpu::CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
@@ -229,7 +230,7 @@ class CommandBufferProxyImpl
// |*this| is owned by |*channel_| and so is always outlived by it, so using a
// raw pointer is ok.
GpuChannelHost* channel_;
- const uint64_t command_buffer_id_;
+ const gpu::CommandBufferId command_buffer_id_;
const int32_t route_id_;
const int32_t stream_id_;
uint32_t flush_count_;
diff --git a/content/common/gpu/client/gpu_context_tests.h b/content/common/gpu/client/gpu_context_tests.h
index 8810789..9547ea1 100644
--- a/content/common/gpu/client/gpu_context_tests.h
+++ b/content/common/gpu/client/gpu_context_tests.h
@@ -69,9 +69,8 @@ CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
// Signalling something that doesn't exist should run the callback
// immediately.
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO,
- 0,
- 1297824234,
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(1297824234),
9123743439);
TestSignalSyncToken(sync_token);
};
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index d0ed3d1c..61512aa 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -156,8 +156,9 @@ DevToolsChannelData::CreateForChannel(GpuChannel* channel) {
return new DevToolsChannelData(res.release());
}
-uint64_t GetCommandBufferID(int channel_id, int32_t route_id) {
- return (static_cast<uint64_t>(channel_id) << 32) | route_id;
+gpu::CommandBufferId GetCommandBufferID(int channel_id, int32_t route_id) {
+ return gpu::CommandBufferId::FromUnsafeValue(
+ (static_cast<uint64_t>(channel_id) << 32) | route_id);
}
gfx::GLSurface::Format GetSurfaceFormatFromAttribute(
@@ -227,8 +228,8 @@ GpuCommandBufferStub::GpuCommandBufferStub(
attrib_parser.bind_generates_resource);
} else {
context_group_ = new gpu::gles2::ContextGroup(
- mailbox_manager,
- new GpuCommandBufferMemoryTracker(channel, command_buffer_id_),
+ mailbox_manager, new GpuCommandBufferMemoryTracker(
+ channel, command_buffer_id_.GetUnsafeValue()),
channel_->gpu_channel_manager()->shader_translator_cache(),
channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL,
subscription_ref_set, pending_valuebuffer_state,
@@ -914,7 +915,7 @@ void GpuCommandBufferStub::OnCreateVideoEncoder(
void GpuCommandBufferStub::PullTextureUpdates(
gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint32_t release) {
gpu::gles2::MailboxManager* mailbox_manager =
context_group_->mailbox_manager();
@@ -981,7 +982,7 @@ void GpuCommandBufferStub::OnFenceSyncRelease(uint64_t release) {
bool GpuCommandBufferStub::OnWaitFenceSync(
gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release) {
DCHECK(!waiting_for_sync_point_);
DCHECK(scheduler_->scheduled());
@@ -1015,7 +1016,7 @@ bool GpuCommandBufferStub::OnWaitFenceSync(
void GpuCommandBufferStub::OnWaitFenceSyncCompleted(
gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release) {
DCHECK(waiting_for_sync_point_);
TRACE_EVENT_ASYNC_END1("gpu", "WaitFenceSync", this, "GpuCommandBufferStub",
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index a74ab64..0a3fdba 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -18,6 +18,7 @@
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/common/gpu/gpu_memory_manager.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
@@ -115,7 +116,7 @@ class GpuCommandBufferStub
GpuChannel* channel() const { return channel_; }
// Unique command buffer ID for this command buffer stub.
- uint64_t command_buffer_id() const { return command_buffer_id_; }
+ gpu::CommandBufferId command_buffer_id() const { return command_buffer_id_; }
// Identifies the various GpuCommandBufferStubs in the GPU process belonging
// to the same renderer process.
@@ -199,10 +200,10 @@ class GpuCommandBufferStub
void OnFenceSyncRelease(uint64_t release);
bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release);
void OnWaitFenceSyncCompleted(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release);
void OnCreateImage(const GpuCommandBufferMsg_CreateImage_Params& params);
@@ -233,7 +234,7 @@ class GpuCommandBufferStub
bool CheckContextLost();
void CheckCompleteWaits();
void PullTextureUpdates(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint32_t release);
// The lifetime of objects of this class is managed by a GpuChannel. The
@@ -257,7 +258,7 @@ class GpuCommandBufferStub
std::vector<int32_t> requested_attribs_;
gfx::GpuPreference gpu_preference_;
bool use_virtualized_gl_context_;
- const uint64_t command_buffer_id_;
+ const gpu::CommandBufferId command_buffer_id_;
const int32_t stream_id_;
const int32_t route_id_;
const bool offscreen_;
diff --git a/content/content_common.gypi b/content/content_common.gypi
index e6ca554..f914660 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -370,7 +370,6 @@
'common/host_discardable_shared_memory_manager.h',
'common/host_shared_bitmap_manager.cc',
'common/host_shared_bitmap_manager.h',
- 'common/id_type.h',
'common/in_process_child_thread_params.cc',
'common/in_process_child_thread_params.h',
'common/indexed_db/indexed_db_constants.h',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index a4a6166..24131a0 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -667,7 +667,6 @@
'common/gpu/gpu_channel_unittest.cc',
'common/host_discardable_shared_memory_manager_unittest.cc',
'common/host_shared_bitmap_manager_unittest.cc',
- 'common/id_type_unittest.cc',
'common/indexed_db/indexed_db_key_unittest.cc',
'common/input/event_with_latency_info_unittest.cc',
'common/input/gesture_event_stream_validator_unittest.cc',
diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc
index 46ea946..c999fad 100644
--- a/content/renderer/pepper/ppb_graphics_3d_impl.cc
+++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc
@@ -80,7 +80,7 @@ PP_Resource PPB_Graphics3D_Impl::CreateRaw(
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state_handle,
- uint64_t* command_buffer_id) {
+ gpu::CommandBufferId* command_buffer_id) {
PPB_Graphics3D_API* share_api = NULL;
if (share_context) {
EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
@@ -215,12 +215,11 @@ bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2);
}
-bool PPB_Graphics3D_Impl::InitRaw(
- PPB_Graphics3D_API* share_context,
- const int32_t* attrib_list,
- gpu::Capabilities* capabilities,
- base::SharedMemoryHandle* shared_state_handle,
- uint64_t* command_buffer_id) {
+bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context,
+ const int32_t* attrib_list,
+ gpu::Capabilities* capabilities,
+ base::SharedMemoryHandle* shared_state_handle,
+ gpu::CommandBufferId* command_buffer_id) {
PepperPluginInstanceImpl* plugin_instance =
HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.h b/content/renderer/pepper/ppb_graphics_3d_impl.h
index 651efd2..dec43cf 100644
--- a/content/renderer/pepper/ppb_graphics_3d_impl.h
+++ b/content/renderer/pepper/ppb_graphics_3d_impl.h
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/shared_memory.h"
#include "base/memory/weak_ptr.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
@@ -28,13 +29,12 @@ class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared {
static PP_Resource Create(PP_Instance instance,
PP_Resource share_context,
const int32_t* attrib_list);
- static PP_Resource CreateRaw(
- PP_Instance instance,
- PP_Resource share_context,
- const int32_t* attrib_list,
- gpu::Capabilities* capabilities,
- base::SharedMemoryHandle* shared_state_handle,
- uint64_t* command_buffer_id);
+ static PP_Resource CreateRaw(PP_Instance instance,
+ PP_Resource share_context,
+ const int32_t* attrib_list,
+ gpu::Capabilities* capabilities,
+ base::SharedMemoryHandle* shared_state_handle,
+ gpu::CommandBufferId* command_buffer_id);
// PPB_Graphics3D_API trusted implementation.
PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override;
@@ -83,7 +83,7 @@ class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared {
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state_handle,
- uint64_t* command_buffer_id);
+ gpu::CommandBufferId* command_buffer_id);
// Notifications received from the GPU process.
void OnSwapBuffers();
diff --git a/content/renderer/pepper/resource_creation_impl.cc b/content/renderer/pepper/resource_creation_impl.cc
index c76d0b1..a8bf96b 100644
--- a/content/renderer/pepper/resource_creation_impl.cc
+++ b/content/renderer/pepper/resource_creation_impl.cc
@@ -124,7 +124,7 @@ PP_Resource ResourceCreationImpl::CreateGraphics3DRaw(
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state,
- uint64_t* command_buffer_id) {
+ gpu::CommandBufferId* command_buffer_id) {
return PPB_Graphics3D_Impl::CreateRaw(instance, share_context, attrib_list,
capabilities, shared_state,
command_buffer_id);
diff --git a/content/renderer/pepper/resource_creation_impl.h b/content/renderer/pepper/resource_creation_impl.h
index 3e44cee..b40d17d 100644
--- a/content/renderer/pepper/resource_creation_impl.h
+++ b/content/renderer/pepper/resource_creation_impl.h
@@ -60,7 +60,7 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state,
- uint64_t* command_buffer_id) override;
+ gpu::CommandBufferId* command_buffer_id) override;
PP_Resource CreateHostResolver(PP_Instance instance) override;
PP_Resource CreateHostResolverPrivate(PP_Instance instance) override;
PP_Resource CreateImageData(PP_Instance instance,
diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn
index b602ed42..0bf669a 100644
--- a/gpu/BUILD.gn
+++ b/gpu/BUILD.gn
@@ -232,6 +232,7 @@ test("gpu_unittests") {
"command_buffer/common/gles2_cmd_format_test_autogen.h",
"command_buffer/common/gles2_cmd_utils_unittest.cc",
"command_buffer/common/id_allocator_test.cc",
+ "command_buffer/common/id_type_unittest.cc",
"command_buffer/common/unittest_main.cc",
"command_buffer/service/buffer_manager_unittest.cc",
"command_buffer/service/cmd_parser_test.cc",
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h
index e125c76..30e3dd9 100644
--- a/gpu/command_buffer/client/client_test_helper.h
+++ b/gpu/command_buffer/client/client_test_helper.h
@@ -115,7 +115,7 @@ class MockClientGpuControl : public GpuControl {
MOCK_METHOD0(IsGpuChannelLost, bool());
MOCK_METHOD0(EnsureWorkVisible, void());
MOCK_CONST_METHOD0(GetNamespaceID, CommandBufferNamespace());
- MOCK_CONST_METHOD0(GetCommandBufferID, uint64_t());
+ MOCK_CONST_METHOD0(GetCommandBufferID, CommandBufferId());
MOCK_CONST_METHOD0(GetExtraCommandBufferData, int32_t());
MOCK_METHOD0(GenerateFenceSyncRelease, uint64_t());
MOCK_METHOD1(IsFenceSyncRelease, bool(uint64_t release));
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 3a18ee5..fc051b1 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -147,8 +147,9 @@ GLES2Implementation::GLES2Implementation(
share_group_ =
(share_group ? share_group
- : new ShareGroup(bind_generates_resource,
- gpu_control_->GetCommandBufferID()));
+ : new ShareGroup(
+ bind_generates_resource,
+ gpu_control_->GetCommandBufferID().GetUnsafeValue()));
DCHECK(share_group_->bind_generates_resource() == bind_generates_resource);
memset(&reserved_ids_, 0, sizeof(reserved_ids_));
@@ -5650,7 +5651,8 @@ void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) {
helper_->WaitSyncTokenCHROMIUM(
static_cast<GLint>(sync_token_data.namespace_id()),
- sync_token_data.command_buffer_id(), sync_token_data.release_count());
+ sync_token_data.command_buffer_id().GetUnsafeValue(),
+ sync_token_data.release_count());
}
}
}
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index e408610..8d50686 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -3757,7 +3757,8 @@ TEST_F(GLES2ImplementationTest, InsertFenceSyncCHROMIUM) {
TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
- const GLuint64 kCommandBufferId = 234u;
+ const CommandBufferId kCommandBufferId =
+ CommandBufferId::FromUnsafeValue(234u);
const GLuint64 kFenceSync = 123u;
GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
@@ -3802,7 +3803,8 @@ TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) {
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
- const GLuint64 kCommandBufferId = 234u;
+ const CommandBufferId kCommandBufferId =
+ CommandBufferId::FromUnsafeValue(234u);
const GLuint64 kFenceSync = 123u;
GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
@@ -3853,7 +3855,8 @@ TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM) {
.RetiresOnSaturation();
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
- const GLuint64 kCommandBufferId = 234u;
+ const CommandBufferId kCommandBufferId =
+ CommandBufferId::FromUnsafeValue(234u);
const GLuint64 kFenceSync = 123u;
gpu::SyncToken sync_token;
GLbyte* sync_token_datas[] = { sync_token.GetData() };
@@ -3906,7 +3909,8 @@ TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM_Sequence) {
.RetiresOnSaturation();
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
- const GLuint64 kCommandBufferId = 234u;
+ const CommandBufferId kCommandBufferId =
+ CommandBufferId::FromUnsafeValue(234u);
const GLuint64 kFenceSync1 = 123u;
const GLuint64 kFenceSync2 = 234u;
gpu::SyncToken sync_token1;
@@ -3958,7 +3962,8 @@ TEST_F(GLES2ImplementationTest, VerifySyncTokensCHROMIUM_Sequence) {
TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
- const GLuint64 kCommandBufferId = 234u;
+ const CommandBufferId kCommandBufferId =
+ CommandBufferId::FromUnsafeValue(234u);
const GLuint64 kFenceSync = 456u;
GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
@@ -3978,7 +3983,8 @@ TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
cmds::WaitSyncTokenCHROMIUM wait_sync_token;
};
Cmds expected;
- expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId, kFenceSync);
+ expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId.GetUnsafeValue(),
+ kFenceSync);
gl_->WaitSyncTokenCHROMIUM(sync_token);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
@@ -4006,7 +4012,8 @@ TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUMErrors) {
// Unverified sync token should produce INVALID_OPERATION.
ClearCommands();
- gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0, 0, 0);
+ gpu::SyncToken unverified_sync_token(CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId(), 0);
EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_))
.WillOnce(testing::Return(false));
gl_->WaitSyncTokenCHROMIUM(unverified_sync_token.GetConstData());
diff --git a/gpu/command_buffer/client/gpu_control.h b/gpu/command_buffer/client/gpu_control.h
index 28cd67a..12ad377 100644
--- a/gpu/command_buffer/client/gpu_control.h
+++ b/gpu/command_buffer/client/gpu_control.h
@@ -13,6 +13,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "gpu/command_buffer/common/capabilities.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/gpu_export.h"
@@ -83,7 +84,7 @@ class GPU_EXPORT GpuControl {
// extra field to identify unverified sync tokens for the implementation of
// the CanWaitUnverifiedSyncToken() function.
virtual CommandBufferNamespace GetNamespaceID() const = 0;
- virtual uint64_t GetCommandBufferID() const = 0;
+ virtual CommandBufferId GetCommandBufferID() const = 0;
virtual int32_t GetExtraCommandBufferData() const = 0;
// Fence Syncs use release counters at a context level, these fence syncs
diff --git a/gpu/command_buffer/common/BUILD.gn b/gpu/command_buffer/common/BUILD.gn
index c04d5d2..af72aba 100644
--- a/gpu/command_buffer/common/BUILD.gn
+++ b/gpu/command_buffer/common/BUILD.gn
@@ -32,6 +32,7 @@ source_set("common_sources") {
"cmd_buffer_common.cc",
"cmd_buffer_common.h",
"command_buffer.h",
+ "command_buffer_id.h",
"constants.h",
"debug_marker_manager.cc",
"debug_marker_manager.h",
@@ -42,10 +43,12 @@ source_set("common_sources") {
"gles2_cmd_ids_autogen.h",
"id_allocator.cc",
"id_allocator.h",
+ "id_type.h",
"mailbox.cc",
"mailbox.h",
"mailbox_holder.cc",
"mailbox_holder.h",
+ "sync_token.cc",
"sync_token.h",
"thread_local.h",
"time.h",
diff --git a/gpu/command_buffer/common/command_buffer_id.h b/gpu/command_buffer/common/command_buffer_id.h
new file mode 100644
index 0000000..99b5bb8
--- /dev/null
+++ b/gpu/command_buffer/common/command_buffer_id.h
@@ -0,0 +1,17 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_ID_H_
+#define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_ID_H_
+
+#include "gpu/command_buffer/common/id_type.h"
+
+namespace gpu {
+
+class CommandBuffer;
+using CommandBufferId = gpu::IdTypeU64<CommandBuffer>;
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_ID_H_
diff --git a/content/common/id_type.h b/gpu/command_buffer/common/id_type.h
index 5e1c453..1977364 100644
--- a/content/common/id_type.h
+++ b/gpu/command_buffer/common/id_type.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_ID_TYPE_H_
-#define CONTENT_COMMON_ID_TYPE_H_
+#ifndef GPU_COMMAND_BUFFER_COMMON_ID_TYPE_H_
+#define GPU_COMMAND_BUFFER_COMMON_ID_TYPE_H_
#include <stdint.h>
#include <cstddef>
@@ -28,13 +28,14 @@
// IdType32<T> / IdTypeU32<T>: Signed / unsigned 32-bit IDs
// IdType64<T> / IdTypeU64<T>: Signed / unsigned 64-bit IDs
// IdType<>: For when you need a different underlying type or
-// a default/invalid value other than zero.
+// a default/null value other than zero.
//
// IdType32<Foo> behaves just like an int32_t in the following aspects:
// - it can be used as a key in std::map and/or std::unordered_map;
// - it can be used as an argument to DCHECK_EQ or streamed to LOG(ERROR);
// - it has the same memory footprint and runtime overhead as int32_t;
// - it can be copied by memcpy.
+// - it can be used in IPC messages (for now via gpu/ipc/id_type_traits.h)
//
// IdType32<Foo> has the following differences from a bare int32_t:
// - it forces coercions to go through GetUnsafeValue and FromUnsafeValue;
@@ -42,7 +43,7 @@
// - it ensures initialization to zero and allows checking against
// default-initialized values via is_null method.
-namespace content {
+namespace gpu {
template <typename TypeMarker, typename WrappedType, WrappedType kInvalidValue>
class IdType {
@@ -102,6 +103,6 @@ std::ostream& operator<<(
return stream << id.GetUnsafeValue();
}
-} // namespace content
+} // namespace gpu
#endif // CONTENT_COMMON_ID_TYPE_H_
diff --git a/content/common/id_type_unittest.cc b/gpu/command_buffer/common/id_type_unittest.cc
index de221cf1..1ba2d01 100644
--- a/content/common/id_type_unittest.cc
+++ b/gpu/command_buffer/common/id_type_unittest.cc
@@ -9,10 +9,10 @@
#include <type_traits>
#include <unordered_map>
-#include "content/common/id_type.h"
+#include "gpu/command_buffer/common/id_type.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace content {
+namespace gpu {
namespace {
@@ -197,4 +197,4 @@ INSTANTIATE_TEST_CASE_P(,
123,
std::numeric_limits<int>::max()));
-} // namespace content
+} // namespace gpu
diff --git a/gpu/command_buffer/common/sync_token.cc b/gpu/command_buffer/common/sync_token.cc
new file mode 100644
index 0000000..c938fe0
--- /dev/null
+++ b/gpu/command_buffer/common/sync_token.cc
@@ -0,0 +1,25 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/common/sync_token.h"
+
+namespace gpu {
+
+SyncToken::SyncToken()
+ : verified_flush_(false),
+ namespace_id_(CommandBufferNamespace::INVALID),
+ extra_data_field_(0),
+ release_count_(0) {}
+
+SyncToken::SyncToken(CommandBufferNamespace namespace_id,
+ int32_t extra_data_field,
+ CommandBufferId command_buffer_id,
+ uint64_t release_count)
+ : verified_flush_(false),
+ namespace_id_(namespace_id),
+ extra_data_field_(extra_data_field),
+ command_buffer_id_(command_buffer_id),
+ release_count_(release_count) {}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/common/sync_token.h b/gpu/command_buffer/common/sync_token.h
index 73b232a..655f5e24 100644
--- a/gpu/command_buffer/common/sync_token.h
+++ b/gpu/command_buffer/common/sync_token.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <string.h>
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/gpu_export.h"
@@ -23,26 +24,16 @@ namespace gpu {
// See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more
// details.
struct GPU_EXPORT SyncToken {
- SyncToken()
- : verified_flush_(false),
- namespace_id_(CommandBufferNamespace::INVALID),
- extra_data_field_(0),
- command_buffer_id_(0),
- release_count_(0) {}
+ SyncToken();
SyncToken(CommandBufferNamespace namespace_id,
int32_t extra_data_field,
- uint64_t command_buffer_id,
- uint64_t release_count)
- : verified_flush_(false),
- namespace_id_(namespace_id),
- extra_data_field_(extra_data_field),
- command_buffer_id_(command_buffer_id),
- release_count_(release_count) {}
+ CommandBufferId command_buffer_id,
+ uint64_t release_count);
void Set(CommandBufferNamespace namespace_id,
int32_t extra_data_field,
- uint64_t command_buffer_id,
+ CommandBufferId command_buffer_id,
uint64_t release_count) {
namespace_id_ = namespace_id;
extra_data_field_ = extra_data_field;
@@ -54,7 +45,7 @@ struct GPU_EXPORT SyncToken {
verified_flush_ = false;
namespace_id_ = CommandBufferNamespace::INVALID;
extra_data_field_ = 0;
- command_buffer_id_ = 0;
+ command_buffer_id_ = CommandBufferId();
release_count_ = 0;
}
@@ -74,7 +65,7 @@ struct GPU_EXPORT SyncToken {
bool verified_flush() const { return verified_flush_; }
CommandBufferNamespace namespace_id() const { return namespace_id_; }
- uint64_t command_buffer_id() const { return command_buffer_id_; }
+ CommandBufferId command_buffer_id() const { return command_buffer_id_; }
uint64_t release_count() const { return release_count_; }
// This extra data field can be used by command buffers to add extra
@@ -107,7 +98,7 @@ struct GPU_EXPORT SyncToken {
bool verified_flush_;
CommandBufferNamespace namespace_id_;
int32_t extra_data_field_;
- uint64_t command_buffer_id_;
+ CommandBufferId command_buffer_id_;
uint64_t release_count_;
};
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index ae331e5..c68e159 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -12670,7 +12670,8 @@ error::Error GLES2DecoderImpl::HandleWaitSyncTokenCHROMIUM(
(c.namespace_id < static_cast<int32_t>(kMaxNamespaceId)))
? static_cast<gpu::CommandBufferNamespace>(c.namespace_id)
: gpu::CommandBufferNamespace::INVALID;
- const uint64_t command_buffer_id = c.command_buffer_id();
+ const CommandBufferId command_buffer_id =
+ CommandBufferId::FromUnsafeValue(c.command_buffer_id());
const uint64_t release = c.release_count();
if (wait_fence_sync_callback_.is_null())
return error::kNoError;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index c5a044b..23faaed 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -19,6 +19,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/capabilities.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/service/common_decoder.h"
#include "gpu/gpu_export.h"
@@ -85,8 +86,9 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>,
typedef error::Error Error;
typedef base::Callback<void(uint64_t release)> FenceSyncReleaseCallback;
typedef base::Callback<bool(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
- uint64_t release)> WaitFenceSyncCallback;
+ gpu::CommandBufferId command_buffer_id,
+ uint64_t release)>
+ WaitFenceSyncCallback;
// The default stencil mask, which has all bits set. This really should be a
// GLuint, but we can't #include gl_bindings.h in this file without causing
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc
index 516e5c1..7ea7d34 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.cc
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc
@@ -198,7 +198,8 @@ gpu::gles2::ProgramCache* InProcessCommandBuffer::Service::program_cache() {
InProcessCommandBuffer::InProcessCommandBuffer(
const scoped_refptr<Service>& service)
- : command_buffer_id_(g_next_command_buffer_id.GetNext()),
+ : command_buffer_id_(
+ CommandBufferId::FromUnsafeValue(g_next_command_buffer_id.GetNext())),
context_lost_(false),
delayed_work_pending_(false),
image_factory_(nullptr),
@@ -838,7 +839,7 @@ void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) {
bool InProcessCommandBuffer::WaitFenceSyncOnGpuThread(
gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release) {
gpu::SyncPointManager* sync_point_manager = service_->sync_point_manager();
DCHECK(sync_point_manager);
@@ -923,7 +924,7 @@ CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const {
return CommandBufferNamespace::IN_PROCESS;
}
-uint64_t InProcessCommandBuffer::GetCommandBufferID() const {
+CommandBufferId InProcessCommandBuffer::GetCommandBufferID() const {
return command_buffer_id_;
}
diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h
index 58c214f..37b888a 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.h
+++ b/gpu/command_buffer/service/in_process_command_buffer.h
@@ -127,7 +127,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
@@ -219,7 +219,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
void CheckSequencedThread();
void FenceSyncReleaseOnGpuThread(uint64_t release);
bool WaitFenceSyncOnGpuThread(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release);
void SignalSyncTokenOnGpuThread(const SyncToken& sync_token,
const base::Closure& callback);
@@ -241,7 +241,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
void PumpCommands();
void PerformDelayedWork();
- const uint64_t command_buffer_id_;
+ const CommandBufferId command_buffer_id_;
// Members accessed on the gpu thread (possibly with the exception of
// creation):
diff --git a/gpu/command_buffer/service/mailbox_manager_unittest.cc b/gpu/command_buffer/service/mailbox_manager_unittest.cc
index 76e1732..735fd4a 100644
--- a/gpu/command_buffer/service/mailbox_manager_unittest.cc
+++ b/gpu/command_buffer/service/mailbox_manager_unittest.cc
@@ -21,7 +21,7 @@ using namespace ::testing;
static const SyncToken g_sync_token(gpu::CommandBufferNamespace::GPU_IO,
0,
- 123,
+ gpu::CommandBufferId::FromUnsafeValue(123),
0);
class MailboxManagerTest : public GpuServiceTest {
diff --git a/gpu/command_buffer/service/sync_point_manager.cc b/gpu/command_buffer/service/sync_point_manager.cc
index c3d7d68..38d603e 100644
--- a/gpu/command_buffer/service/sync_point_manager.cc
+++ b/gpu/command_buffer/service/sync_point_manager.cc
@@ -327,12 +327,12 @@ void SyncPointClient::ReleaseFenceSync(uint64_t release) {
SyncPointClient::SyncPointClient()
: sync_point_manager_(nullptr),
namespace_id_(gpu::CommandBufferNamespace::INVALID),
- client_id_(0) {}
+ client_id_() {}
SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager,
scoped_refptr<SyncPointOrderData> order_data,
CommandBufferNamespace namespace_id,
- uint64_t client_id)
+ CommandBufferId client_id)
: sync_point_manager_(sync_point_manager),
client_state_(new SyncPointClientState(order_data)),
namespace_id_(namespace_id),
@@ -351,7 +351,7 @@ SyncPointManager::~SyncPointManager() {
scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClient(
scoped_refptr<SyncPointOrderData> order_data,
CommandBufferNamespace namespace_id,
- uint64_t client_id) {
+ CommandBufferId client_id) {
DCHECK_GE(namespace_id, 0);
DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
base::AutoLock auto_lock(client_maps_lock_);
@@ -370,7 +370,8 @@ scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClientWaiter() {
}
scoped_refptr<SyncPointClientState> SyncPointManager::GetSyncPointClientState(
- CommandBufferNamespace namespace_id, uint64_t client_id) {
+ CommandBufferNamespace namespace_id,
+ CommandBufferId client_id) {
if (namespace_id >= 0) {
DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
base::AutoLock auto_lock(client_maps_lock_);
@@ -388,7 +389,8 @@ uint32_t SyncPointManager::GenerateOrderNumber() {
}
void SyncPointManager::DestroySyncPointClient(
- CommandBufferNamespace namespace_id, uint64_t client_id) {
+ CommandBufferNamespace namespace_id,
+ CommandBufferId client_id) {
DCHECK_GE(namespace_id, 0);
DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
diff --git a/gpu/command_buffer/service/sync_point_manager.h b/gpu/command_buffer/service/sync_point_manager.h
index 8c39441..eea2dfc 100644
--- a/gpu/command_buffer/service/sync_point_manager.h
+++ b/gpu/command_buffer/service/sync_point_manager.h
@@ -9,11 +9,11 @@
#include <functional>
#include <queue>
+#include <unordered_map>
#include <vector>
#include "base/atomic_sequence_num.h"
#include "base/callback.h"
-#include "base/containers/hash_tables.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -21,6 +21,7 @@
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/gpu_export.h"
@@ -248,7 +249,7 @@ class GPU_EXPORT SyncPointClient {
SyncPointClient(SyncPointManager* sync_point_manager,
scoped_refptr<SyncPointOrderData> order_data,
CommandBufferNamespace namespace_id,
- uint64_t client_id);
+ CommandBufferId client_id);
// Sync point manager is guaranteed to exist in the lifetime of the client.
SyncPointManager* sync_point_manager_;
@@ -258,7 +259,7 @@ class GPU_EXPORT SyncPointClient {
// Unique namespace/client id pair for this sync point client.
const CommandBufferNamespace namespace_id_;
- const uint64_t client_id_;
+ const CommandBufferId client_id_;
DISALLOW_COPY_AND_ASSIGN(SyncPointClient);
};
@@ -274,7 +275,7 @@ class GPU_EXPORT SyncPointManager {
scoped_ptr<SyncPointClient> CreateSyncPointClient(
scoped_refptr<SyncPointOrderData> order_data,
CommandBufferNamespace namespace_id,
- uint64_t client_id);
+ CommandBufferId client_id);
// Creates a sync point client which cannot process order numbers but can only
// Wait out of order.
@@ -282,17 +283,20 @@ class GPU_EXPORT SyncPointManager {
// Finds the state of an already created sync point client.
scoped_refptr<SyncPointClientState> GetSyncPointClientState(
- CommandBufferNamespace namespace_id, uint64_t client_id);
+ CommandBufferNamespace namespace_id,
+ CommandBufferId client_id);
private:
friend class SyncPointClient;
friend class SyncPointOrderData;
- typedef base::hash_map<uint64_t, SyncPointClient*> ClientMap;
+ using ClientMap = std::unordered_map<CommandBufferId,
+ SyncPointClient*,
+ CommandBufferId::Hasher>;
uint32_t GenerateOrderNumber();
void DestroySyncPointClient(CommandBufferNamespace namespace_id,
- uint64_t client_id);
+ CommandBufferId client_id);
// Order number is global for all clients.
base::AtomicSequenceNumber global_order_num_;
diff --git a/gpu/command_buffer/service/sync_point_manager_unittest.cc b/gpu/command_buffer/service/sync_point_manager_unittest.cc
index cc67ff9..61b3a8f 100644
--- a/gpu/command_buffer/service/sync_point_manager_unittest.cc
+++ b/gpu/command_buffer/service/sync_point_manager_unittest.cc
@@ -38,7 +38,7 @@ struct SyncPointStream {
SyncPointStream(SyncPointManager* sync_point_manager,
CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id)
+ CommandBufferId command_buffer_id)
: order_data(SyncPointOrderData::Create()),
client(sync_point_manager->CreateSyncPointClient(order_data,
namespace_id,
@@ -103,7 +103,7 @@ TEST_F(SyncPointManagerTest, BasicSyncPointOrderDataTest) {
TEST_F(SyncPointManagerTest, SyncPointClientRegistration) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId = 0x123;
+ const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
scoped_refptr<SyncPointClientState> empty_state =
sync_point_manager_->GetSyncPointClientState(kNamespaceId, kBufferId);
@@ -124,7 +124,7 @@ TEST_F(SyncPointManagerTest, SyncPointClientRegistration) {
TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId = 0x123;
+ const CommandBufferId kBufferId = CommandBufferId::FromUnsafeValue(0x123);
scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
scoped_ptr<SyncPointClient> client =
@@ -148,8 +148,8 @@ TEST_F(SyncPointManagerTest, BasicFenceSyncRelease) {
TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
scoped_refptr<SyncPointOrderData> order_data = SyncPointOrderData::Create();
scoped_ptr<SyncPointClient> client1 =
@@ -175,8 +175,8 @@ TEST_F(SyncPointManagerTest, MultipleClientsPerOrderData) {
TEST_F(SyncPointManagerTest, BasicFenceSyncWaitRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -202,8 +202,8 @@ TEST_F(SyncPointManagerTest, BasicFenceSyncWaitRelease) {
TEST_F(SyncPointManagerTest, WaitOnSelfFails) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -226,8 +226,8 @@ TEST_F(SyncPointManagerTest, WaitOnSelfFails) {
TEST_F(SyncPointManagerTest, OutOfOrderRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -250,8 +250,8 @@ TEST_F(SyncPointManagerTest, OutOfOrderRelease) {
TEST_F(SyncPointManagerTest, HigherOrderNumberRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -279,8 +279,8 @@ TEST_F(SyncPointManagerTest, HigherOrderNumberRelease) {
TEST_F(SyncPointManagerTest, DestroyedClientRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -306,8 +306,8 @@ TEST_F(SyncPointManagerTest, DestroyedClientRelease) {
TEST_F(SyncPointManagerTest, NonExistentRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -339,8 +339,8 @@ TEST_F(SyncPointManagerTest, NonExistentRelease) {
TEST_F(SyncPointManagerTest, NonExistentRelease2) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
@@ -383,8 +383,8 @@ TEST_F(SyncPointManagerTest, NonExistentRelease2) {
TEST_F(SyncPointManagerTest, NonExistentOrderNumRelease) {
const CommandBufferNamespace kNamespaceId =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kBufferId1 = 0x123;
- const uint64_t kBufferId2 = 0x234;
+ const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123);
+ const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234);
SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId,
kBufferId1);
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index 92664315..8560399 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -125,7 +125,8 @@ GLManager::GLManager()
context_lost_allowed_(false),
pause_commands_(false),
paused_order_num_(0),
- command_buffer_id_(g_next_command_buffer_id++),
+ command_buffer_id_(
+ CommandBufferId::FromUnsafeValue(g_next_command_buffer_id++)),
next_fence_sync_release_(1) {
SetupBaseContext();
}
@@ -345,7 +346,7 @@ void GLManager::OnFenceSyncRelease(uint64_t release) {
}
bool GLManager::OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release) {
DCHECK(sync_point_client_);
scoped_refptr<gpu::SyncPointClientState> release_state =
@@ -505,7 +506,7 @@ gpu::CommandBufferNamespace GLManager::GetNamespaceID() const {
return gpu::CommandBufferNamespace::IN_PROCESS;
}
-uint64_t GLManager::GetCommandBufferID() const {
+CommandBufferId GLManager::GetCommandBufferID() const {
return command_buffer_id_;
}
diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h
index 02d01e4..f0b2a21 100644
--- a/gpu/command_buffer/tests/gl_manager.h
+++ b/gpu/command_buffer/tests/gl_manager.h
@@ -132,7 +132,7 @@ class GLManager : private GpuControl {
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
@@ -148,7 +148,7 @@ class GLManager : private GpuControl {
void SetupBaseContext();
void OnFenceSyncRelease(uint64_t release);
bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id,
- uint64_t command_buffer_id,
+ gpu::CommandBufferId command_buffer_id,
uint64_t release);
SyncPointManager* sync_point_manager_; // Non-owning.
@@ -169,7 +169,7 @@ class GLManager : private GpuControl {
bool pause_commands_;
uint32_t paused_order_num_;
- const uint64_t command_buffer_id_;
+ const CommandBufferId command_buffer_id_;
uint64_t next_fence_sync_release_;
// Used on Android to virtualize GL for all contexts.
diff --git a/gpu/command_buffer_common.gypi b/gpu/command_buffer_common.gypi
index 0c6233c..1831a92 100644
--- a/gpu/command_buffer_common.gypi
+++ b/gpu/command_buffer_common.gypi
@@ -15,6 +15,7 @@
'command_buffer/common/cmd_buffer_common.cc',
'command_buffer/common/cmd_buffer_common.h',
'command_buffer/common/command_buffer.h',
+ 'command_buffer/common/command_buffer_id.h',
'command_buffer/common/constants.h',
'command_buffer/common/debug_marker_manager.cc',
'command_buffer/common/debug_marker_manager.h',
@@ -25,10 +26,12 @@
'command_buffer/common/gles2_cmd_ids_autogen.h',
'command_buffer/common/id_allocator.cc',
'command_buffer/common/id_allocator.h',
+ 'command_buffer/common/id_type.h',
'command_buffer/common/mailbox.cc',
'command_buffer/common/mailbox.h',
'command_buffer/common/mailbox_holder.cc',
'command_buffer/common/mailbox_holder.h',
+ 'command_buffer/common/sync_token.cc',
'command_buffer/common/sync_token.h',
'command_buffer/common/thread_local.h',
'command_buffer/common/time.h',
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index bf63108..4b010f2 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -369,8 +369,8 @@ gpu::CommandBufferNamespace Display::GetNamespaceID() const {
return gpu::CommandBufferNamespace::IN_PROCESS;
}
-uint64_t Display::GetCommandBufferID() const {
- return 0;
+gpu::CommandBufferId Display::GetCommandBufferID() const {
+ return gpu::CommandBufferId();
}
int32_t Display::GetExtraCommandBufferData() const {
diff --git a/gpu/gles2_conform_support/egl/display.h b/gpu/gles2_conform_support/egl/display.h
index e3a57bc..292d68b 100644
--- a/gpu/gles2_conform_support/egl/display.h
+++ b/gpu/gles2_conform_support/egl/display.h
@@ -92,7 +92,7 @@ class Display : private gpu::GpuControl {
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ gpu::CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 2b529e1..eef5382 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -199,6 +199,7 @@
'command_buffer/common/gles2_cmd_format_test_autogen.h',
'command_buffer/common/gles2_cmd_utils_unittest.cc',
'command_buffer/common/id_allocator_test.cc',
+ 'command_buffer/common/id_type_unittest.cc',
'command_buffer/common/unittest_main.cc',
'command_buffer/service/buffer_manager_unittest.cc',
'command_buffer/service/cmd_parser_test.cc',
diff --git a/gpu/gpu_ipc.gypi b/gpu/gpu_ipc.gypi
index d1cb292..1d6e1c9 100644
--- a/gpu/gpu_ipc.gypi
+++ b/gpu/gpu_ipc.gypi
@@ -13,6 +13,7 @@
'sources': [
'ipc/gpu_command_buffer_traits.cc',
'ipc/gpu_command_buffer_traits.h',
+ 'ipc/id_type_traits.h',
],
'conditions': [
# This section applies to gpu_ipc_win64, used by the NaCl Win64 helper
diff --git a/gpu/ipc/BUILD.gn b/gpu/ipc/BUILD.gn
index c78dea7..bcf999d 100644
--- a/gpu/ipc/BUILD.gn
+++ b/gpu/ipc/BUILD.gn
@@ -20,6 +20,7 @@ source_set("ipc_sources") {
sources = [
"gpu_command_buffer_traits.cc",
"gpu_command_buffer_traits.h",
+ "id_type_traits.h",
]
configs += [
diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc
index fdf2e15..be302db 100644
--- a/gpu/ipc/gpu_command_buffer_traits.cc
+++ b/gpu/ipc/gpu_command_buffer_traits.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/common/value_state.h"
@@ -95,7 +96,7 @@ bool ParamTraits<gpu::SyncToken>::Read(const base::Pickle* m,
bool verified_flush = false;
gpu::CommandBufferNamespace namespace_id =
gpu::CommandBufferNamespace::INVALID;
- uint64_t command_buffer_id = 0;
+ gpu::CommandBufferId command_buffer_id;
uint64_t release_count = 0;
if (!ReadParam(m, iter, &verified_flush) ||
@@ -116,10 +117,9 @@ bool ParamTraits<gpu::SyncToken>::Read(const base::Pickle* m,
}
void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) {
- *l +=
- base::StringPrintf("[%d:%llX] %llu", static_cast<int>(p.namespace_id()),
- static_cast<unsigned long long>(p.command_buffer_id()),
- static_cast<unsigned long long>(p.release_count()));
+ *l += base::StringPrintf(
+ "[%" PRId8 ":%" PRIX64 "] %" PRIu64, p.namespace_id(),
+ p.command_buffer_id().GetUnsafeValue(), p.release_count());
}
void ParamTraits<gpu::Mailbox>::GetSize(base::PickleSizer* s,
diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h
index 7951297..a968f02 100644
--- a/gpu/ipc/gpu_command_buffer_traits.h
+++ b/gpu/ipc/gpu_command_buffer_traits.h
@@ -8,6 +8,7 @@
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/gpu_command_buffer_traits_multi.h"
+#include "gpu/ipc/id_type_traits.h"
#include "ipc/ipc_message_utils.h"
namespace gpu {
diff --git a/gpu/ipc/id_type_traits.h b/gpu/ipc/id_type_traits.h
new file mode 100644
index 0000000..d2decb7
--- /dev/null
+++ b/gpu/ipc/id_type_traits.h
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_IPC_ID_TYPE_TRAITS_H_
+#define GPU_IPC_ID_TYPE_TRAITS_H_
+
+#include <string>
+
+#include "base/pickle.h"
+#include "gpu/command_buffer/common/id_type.h"
+#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_param_traits.h"
+
+namespace IPC {
+
+template <typename TypeMarker, typename WrappedType, WrappedType kInvalidValue>
+struct ParamTraits<gpu::IdType<TypeMarker, WrappedType, kInvalidValue>> {
+ using param_type = gpu::IdType<TypeMarker, WrappedType, kInvalidValue>;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p) {
+ GetParamSize(sizer, p.GetUnsafeValue());
+ }
+ static void Write(base::Pickle* m, const param_type& p) {
+ WriteParam(m, p.GetUnsafeValue());
+ }
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ WrappedType value;
+ if (!ReadParam(m, iter, &value))
+ return false;
+ *r = param_type::FromUnsafeValue(value);
+ return true;
+ }
+ static void Log(const param_type& p, std::string* l) {
+ LogParam(p.GetUnsafeValue(), l);
+ }
+};
+
+} // namespace IPC
+
+#endif // GPU_IPC_ID_TYPE_TRAITS_H_
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index 18e1893..eabb21b 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -274,8 +274,8 @@ static void TextureCallback(gpu::SyncToken* called_sync_token,
// Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
// destroyed with the default release sync point.
TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) {
- gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1,
- 1);
+ gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(1), 1);
{
scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
@@ -321,7 +321,8 @@ TEST(VideoFrame,
const int kPlanesNum = 3;
const gpu::CommandBufferNamespace kNamespace =
gpu::CommandBufferNamespace::GPU_IO;
- const uint64_t kCommandBufferId = 0x123;
+ const gpu::CommandBufferId kCommandBufferId =
+ gpu::CommandBufferId::FromUnsafeValue(0x123);
gpu::Mailbox mailbox[kPlanesNum];
for (int i = 0; i < kPlanesNum; ++i) {
mailbox[i].name[0] = 50 + 1;
diff --git a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
index 55dc969..b107e5d 100644
--- a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
+++ b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
@@ -36,8 +36,8 @@ class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) override {
gpu::SyncToken sync_token_data;
if (fence_sync <= flushed_fence_sync_) {
- sync_token_data.Set(gpu::CommandBufferNamespace::GPU_IO, 0, 0,
- fence_sync);
+ sync_token_data.Set(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId(), fence_sync);
sync_token_data.SetVerifyFlush();
}
memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
@@ -47,8 +47,8 @@ class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
GLbyte* sync_token) override {
gpu::SyncToken sync_token_data;
if (fence_sync <= flushed_fence_sync_) {
- sync_token_data.Set(gpu::CommandBufferNamespace::GPU_IO, 0, 0,
- fence_sync);
+ sync_token_data.Set(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId(), fence_sync);
}
memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
}
diff --git a/mojo/converters/surfaces/tests/surface_unittest.cc b/mojo/converters/surfaces/tests/surface_unittest.cc
index 9617062..4fce0aa 100644
--- a/mojo/converters/surfaces/tests/surface_unittest.cc
+++ b/mojo/converters/surfaces/tests/surface_unittest.cc
@@ -15,6 +15,7 @@
#include "cc/resources/resource_provider.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
+#include "gpu/command_buffer/common/sync_token.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
#include "mojo/converters/transform/transform_type_converters.h"
@@ -381,7 +382,6 @@ TEST(SurfaceLibTest, RenderPass) {
EXPECT_EQ(y_flipped, round_trip_texture_quad->y_flipped);
}
-
TEST(SurfaceLibTest, TransferableResource) {
uint32_t id = 7u;
cc::ResourceFormat format = cc::BGRA_8888;
@@ -420,7 +420,8 @@ TEST(SurfaceLibTest, TransferableResource) {
TEST(SurfaceLibTest, ReturnedResource) {
uint32_t id = 5u;
- gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1, 24u);
+ gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
+ gpu::CommandBufferId::FromUnsafeValue(1), 24u);
sync_token.SetVerifyFlush();
int count = 2;
bool lost = false;
diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc
index 5000bce..4813c42 100644
--- a/mojo/gles2/command_buffer_client_impl.cc
+++ b/mojo/gles2/command_buffer_client_impl.cc
@@ -16,6 +16,7 @@
#include "components/mus/gles2/command_buffer_type_conversions.h"
#include "components/mus/gles2/mojo_buffer_backing.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/service/image_factory.h"
#include "mojo/platform_handle/platform_handle_functions.h"
@@ -72,7 +73,7 @@ CommandBufferClientImpl::CommandBufferClientImpl(
: delegate_(delegate),
attribs_(attribs),
client_binding_(this),
- command_buffer_id_(0),
+ command_buffer_id_(),
shared_state_(NULL),
last_put_offset_(-1),
next_transfer_buffer_id_(0),
@@ -124,7 +125,8 @@ bool CommandBufferClientImpl::Initialize() {
DCHECK_EQ(gpu::CommandBufferNamespace::MOJO,
initialize_result->command_buffer_namespace);
- command_buffer_id_ = initialize_result->command_buffer_id;
+ command_buffer_id_ = gpu::CommandBufferId::FromUnsafeValue(
+ initialize_result->command_buffer_id);
capabilities_ = initialize_result->capabilities;
return true;
}
@@ -345,7 +347,7 @@ gpu::CommandBufferNamespace CommandBufferClientImpl::GetNamespaceID() const {
return gpu::CommandBufferNamespace::MOJO;
}
-uint64_t CommandBufferClientImpl::GetCommandBufferID() const {
+gpu::CommandBufferId CommandBufferClientImpl::GetCommandBufferID() const {
return command_buffer_id_;
}
diff --git a/mojo/gles2/command_buffer_client_impl.h b/mojo/gles2/command_buffer_client_impl.h
index 3595f06..473c228 100644
--- a/mojo/gles2/command_buffer_client_impl.h
+++ b/mojo/gles2/command_buffer_client_impl.h
@@ -16,6 +16,7 @@
#include "components/mus/public/interfaces/command_buffer.mojom.h"
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -73,7 +74,7 @@ class CommandBufferClientImpl
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ gpu::CommandBufferId GetCommandBufferID() const override;
int32_t GetExtraCommandBufferData() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
@@ -101,7 +102,7 @@ class CommandBufferClientImpl
mojo::Binding<mus::mojom::CommandBufferClient> client_binding_;
mus::mojom::CommandBufferPtr command_buffer_;
- uint64_t command_buffer_id_;
+ gpu::CommandBufferId command_buffer_id_;
gpu::Capabilities capabilities_;
State last_state_;
mojo::ScopedSharedBufferHandle shared_state_handle_;
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc
index 0a7524b..58ad59a 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.cc
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc
@@ -20,7 +20,7 @@ PpapiCommandBufferProxy::PpapiCommandBufferProxy(
PluginDispatcher* dispatcher,
const gpu::Capabilities& capabilities,
const SerializedHandle& shared_state,
- uint64_t command_buffer_id)
+ gpu::CommandBufferId command_buffer_id)
: command_buffer_id_(command_buffer_id),
capabilities_(capabilities),
resource_(resource),
@@ -195,7 +195,7 @@ gpu::CommandBufferNamespace PpapiCommandBufferProxy::GetNamespaceID() const {
return gpu::CommandBufferNamespace::GPU_IO;
}
-uint64_t PpapiCommandBufferProxy::GetCommandBufferID() const {
+gpu::CommandBufferId PpapiCommandBufferProxy::GetCommandBufferID() const {
return command_buffer_id_;
}
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h
index 486e310..e0629bf 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.h
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.h
@@ -14,6 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
@@ -35,7 +36,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
PluginDispatcher* dispatcher,
const gpu::Capabilities& capabilities,
const SerializedHandle& shared_state,
- uint64_t command_buffer_id);
+ gpu::CommandBufferId command_buffer_id);
~PpapiCommandBufferProxy() override;
// gpu::CommandBuffer implementation:
@@ -67,7 +68,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
bool IsGpuChannelLost() override;
void EnsureWorkVisible() override;
gpu::CommandBufferNamespace GetNamespaceID() const override;
- uint64_t GetCommandBufferID() const override;
+ gpu::CommandBufferId GetCommandBufferID() const override;
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
bool IsFenceSyncFlushed(uint64_t release) override;
@@ -89,7 +90,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
void FlushInternal();
- const uint64_t command_buffer_id_;
+ const gpu::CommandBufferId command_buffer_id_;
gpu::Capabilities capabilities_;
State last_state_;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 19ed110..ebaeed9 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -17,6 +17,7 @@
#include "base/sync_socket.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/ipc/gpu_command_buffer_traits.h"
@@ -1015,7 +1016,7 @@ IPC_SYNC_MESSAGE_ROUTED3_4(PpapiHostMsg_PPBGraphics3D_Create,
ppapi::HostResource /* result */,
gpu::Capabilities /* capabilities */,
ppapi::proxy::SerializedHandle /* shared_state */,
- uint64_t /* command_buffer_id */)
+ gpu::CommandBufferId /* command_buffer_id */)
IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
ppapi::HostResource /* context */,
int32_t /* transfer_buffer_id */)
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc
index 0ad81ad..9646df7 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -59,7 +59,7 @@ Graphics3D::~Graphics3D() {
bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
const gpu::Capabilities& capabilities,
const SerializedHandle& shared_state,
- uint64_t command_buffer_id) {
+ gpu::CommandBufferId command_buffer_id) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
if (!dispatcher)
return false;
@@ -177,7 +177,7 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
HostResource result;
gpu::Capabilities capabilities;
ppapi::proxy::SerializedHandle shared_state;
- uint64_t command_buffer_id = 0;
+ gpu::CommandBufferId command_buffer_id;
dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D,
instance, share_host, attribs, &result, &capabilities, &shared_state,
&command_buffer_id));
@@ -226,13 +226,14 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
}
#if !defined(OS_NACL)
-void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance,
- HostResource share_context,
- const std::vector<int32_t>& attribs,
- HostResource* result,
- gpu::Capabilities* capabilities,
- SerializedHandle* shared_state,
- uint64_t* command_buffer_id) {
+void PPB_Graphics3D_Proxy::OnMsgCreate(
+ PP_Instance instance,
+ HostResource share_context,
+ const std::vector<int32_t>& attribs,
+ HostResource* result,
+ gpu::Capabilities* capabilities,
+ SerializedHandle* shared_state,
+ gpu::CommandBufferId* command_buffer_id) {
shared_state->set_null_shmem();
if (attribs.empty() ||
attribs.back() != PP_GRAPHICS3DATTRIB_NONE ||
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h
index f6805da..e2b4dda 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "ppapi/c/pp_graphics_3d.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
@@ -41,7 +42,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
bool Init(gpu::gles2::GLES2Implementation* share_gles2,
const gpu::Capabilities& capabilities,
const SerializedHandle& shared_state,
- uint64_t command_buffer_id);
+ gpu::CommandBufferId command_buffer_id);
// Graphics3DTrusted API. These are not implemented in the proxy.
PP_Bool SetGetBuffer(int32_t shm_id) override;
@@ -88,7 +89,7 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy {
HostResource* result,
gpu::Capabilities* capabilities,
SerializedHandle* handle,
- uint64_t* command_buffer_id);
+ gpu::CommandBufferId* command_buffer_id);
void OnMsgSetGetBuffer(const HostResource& context, int32_t id);
void OnMsgWaitForTokenInRange(const HostResource& context,
int32_t start,
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index fa08843..31b2cfd 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -267,7 +267,7 @@ PP_Resource ResourceCreationProxy::CreateGraphics3DRaw(
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state,
- uint64_t* command_buffer_id) {
+ gpu::CommandBufferId* command_buffer_id) {
// Not proxied. The raw creation function is used only in the implementation
// of the proxy on the host side.
return 0;
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h
index aad6bf3..498c93c 100644
--- a/ppapi/proxy/resource_creation_proxy.h
+++ b/ppapi/proxy/resource_creation_proxy.h
@@ -126,7 +126,7 @@ class ResourceCreationProxy : public InterfaceProxy,
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state,
- uint64_t* command_buffer_id) override;
+ gpu::CommandBufferId* command_buffer_id) override;
PP_Resource CreateHostResolver(PP_Instance instance) override;
PP_Resource CreateHostResolverPrivate(PP_Instance instance) override;
PP_Resource CreateImageData(PP_Instance instance,
diff --git a/ppapi/thunk/DEPS b/ppapi/thunk/DEPS
index ded1323..0621249 100644
--- a/ppapi/thunk/DEPS
+++ b/ppapi/thunk/DEPS
@@ -1,6 +1,7 @@
include_rules = [
# For gpu::CommandBuffer::State
"+gpu/command_buffer/common/command_buffer.h",
+ "+gpu/command_buffer/common/command_buffer_id.h",
"+gpu/command_buffer/common/sync_token.h",
"-ppapi/cpp",
"-ppapi/proxy",
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index e9ca691..582d9a1 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -9,6 +9,7 @@
#include "base/memory/shared_memory.h"
#include "build/build_config.h"
+#include "gpu/command_buffer/common/command_buffer_id.h"
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
@@ -144,7 +145,7 @@ class ResourceCreationAPI {
const int32_t* attrib_list,
gpu::Capabilities* capabilities,
base::SharedMemoryHandle* shared_state,
- uint64_t* command_buffer_id) = 0;
+ gpu::CommandBufferId* command_buffer_id) = 0;
virtual PP_Resource CreateHostResolver(PP_Instance instance) = 0;
virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0;
virtual PP_Resource CreateImageData(PP_Instance instance,