summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-06 20:04:13 +0000
committerscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-06 20:04:13 +0000
commit820d851f56e3712a2f9ac7db545601d1b0355718 (patch)
tree18f4af5173da3f78086b409fa4ae9ceefb3f9f71 /gpu
parent91c3c300069d27c6ec8749636fec1c4c9018b29f (diff)
downloadchromium_src-820d851f56e3712a2f9ac7db545601d1b0355718.zip
chromium_src-820d851f56e3712a2f9ac7db545601d1b0355718.tar.gz
chromium_src-820d851f56e3712a2f9ac7db545601d1b0355718.tar.bz2
Merge gpu_trace_event back into base/debug/trace_event.
Initial land attempt at http://codereview.chromium.org/6551019/ gpu_trace_event fork at http://codereview.chromium.org/6691013 - gpu_trace_event renamed to base/debug/trace_event and modified as appropriate for base::debug - Unit Tests implemented for trace_event - gpu_common library removed (was added only for gpu_trace_event) - Existing calls to trace_event suffixed with _ETW to make ETW calls (see decisions and incremental plans at end of 6551019) - GPU trace calls renamed to new calls. - Tracing switch removed from test_shell, as linux log file support removed. BUG=79509 TEST=trace_event_win_unittest and about:gpu Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=84284 Review URL: http://codereview.chromium.org/6862002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/client/cmd_buffer_helper.cc12
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc42
-rw-r--r--gpu/command_buffer/common/trace_event.h30
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc14
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.cc4
-rw-r--r--gpu/common/gpu_trace_event.cc330
-rw-r--r--gpu/common/gpu_trace_event.h439
-rwxr-xr-x[-rw-r--r--]gpu/gpu.gyp39
8 files changed, 73 insertions, 837 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index 1054055..f31afa3 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -6,7 +6,7 @@
#include "../client/cmd_buffer_helper.h"
#include "../common/command_buffer.h"
-#include "gpu/common/gpu_trace_event.h"
+#include "../common/trace_event.h"
namespace gpu {
@@ -62,7 +62,7 @@ void CommandBufferHelper::Flush() {
// Calls Flush() and then waits until the buffer is empty. Break early if the
// error is set.
bool CommandBufferHelper::Finish() {
- GPU_TRACE_EVENT0("gpu", "CommandBufferHelper::Finish");
+ TRACE_EVENT0("gpu", "CommandBufferHelper::Finish");
do {
// Do not loop forever if the flush fails, meaning the command buffer reader
// has shutdown.
@@ -84,7 +84,7 @@ int32 CommandBufferHelper::InsertToken() {
cmd::SetToken& cmd = GetCmdSpace<cmd::SetToken>();
cmd.Init(token_);
if (token_ == 0) {
- GPU_TRACE_EVENT0("gpu", "CommandBufferHelper::InsertToken(wrapped)");
+ TRACE_EVENT0("gpu", "CommandBufferHelper::InsertToken(wrapped)");
// we wrapped
Finish();
GPU_DCHECK_EQ(token_, last_token_read_);
@@ -95,7 +95,7 @@ int32 CommandBufferHelper::InsertToken() {
// Waits until the current token value is greater or equal to the value passed
// in argument.
void CommandBufferHelper::WaitForToken(int32 token) {
- GPU_TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForToken");
+ TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForToken");
// Return immediately if corresponding InsertToken failed.
if (token < 0)
return;
@@ -131,7 +131,7 @@ void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
// put will wrap to 0 after we add the jump).
GPU_DCHECK_LE(1, put_);
if (get_ > put_ || get_ == 0) {
- GPU_TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForAvailableEntries");
+ TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForAvailableEntries");
while (get_ > put_ || get_ == 0) {
// Do not loop forever if the flush fails, meaning the command buffer
// reader has shutdown.
@@ -144,7 +144,7 @@ void CommandBufferHelper::WaitForAvailableEntries(int32 count) {
put_ = 0;
}
if (AvailableEntries() < count) {
- GPU_TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForAvailableEntries1");
+ TRACE_EVENT0("gpu", "CommandBufferHelper::WaitForAvailableEntries1");
while (AvailableEntries() < count) {
// Do not loop forever if the flush fails, meaning the command buffer
// reader has shutdown.
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 6b85a55..3810919 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -9,7 +9,7 @@
#include "../client/mapped_memory.h"
#include "../common/gles2_cmd_utils.h"
#include "../common/id_allocator.h"
-#include "gpu/common/gpu_trace_event.h"
+#include "../common/trace_event.h"
#if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
#define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
@@ -491,7 +491,7 @@ GLES2Implementation::~GLES2Implementation() {
}
void GLES2Implementation::WaitForCmd() {
- GPU_TRACE_EVENT0("gpu", "GLES2::WaitForCmd");
+ TRACE_EVENT0("gpu", "GLES2::WaitForCmd");
helper_->CommandBufferHelper::Finish();
}
@@ -500,7 +500,7 @@ GLenum GLES2Implementation::GetError() {
}
GLenum GLES2Implementation::GetGLError() {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetGLError");
+ TRACE_EVENT0("gpu", "GLES2::GetGLError");
// Check the GL error first, then our wrapped error.
typedef gles2::GetError::Result Result;
Result* result = GetResultAs<Result*>();
@@ -533,7 +533,7 @@ void GLES2Implementation::SetGLError(GLenum error, const char* msg) {
void GLES2Implementation::GetBucketContents(uint32 bucket_id,
std::vector<int8>* data) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetBucketContents");
+ TRACE_EVENT0("gpu", "GLES2::GetBucketContents");
GPU_DCHECK(data);
typedef cmd::GetBucketSize::Result Result;
Result* result = GetResultAs<Result*>();
@@ -674,7 +674,7 @@ void GLES2Implementation::Flush() {
}
void GLES2Implementation::Finish() {
- GPU_TRACE_EVENT0("gpu", "GLES2::Finish");
+ TRACE_EVENT0("gpu", "GLES2::Finish");
// Insert the cmd to call glFinish
helper_->Finish();
// Finish our command buffer
@@ -717,7 +717,7 @@ void GLES2Implementation::CopyTextureToParentTextureCHROMIUM(
void GLES2Implementation::GenSharedIdsCHROMIUM(
GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM");
+ TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM");
GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n,
transfer_buffer_id_,
@@ -729,7 +729,7 @@ void GLES2Implementation::GenSharedIdsCHROMIUM(
void GLES2Implementation::DeleteSharedIdsCHROMIUM(
GLuint namespace_id, GLsizei n, const GLuint* ids) {
- GPU_TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM");
+ TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM");
GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
memcpy(id_buffer, ids, sizeof(*ids) * n);
helper_->DeleteSharedIdsCHROMIUM(namespace_id, n,
@@ -741,7 +741,7 @@ void GLES2Implementation::DeleteSharedIdsCHROMIUM(
void GLES2Implementation::RegisterSharedIdsCHROMIUM(
GLuint namespace_id, GLsizei n, const GLuint* ids) {
- GPU_TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM");
+ TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM");
GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
memcpy(id_buffer, ids, sizeof(*ids) * n);
helper_->RegisterSharedIdsCHROMIUM(namespace_id, n,
@@ -767,7 +767,7 @@ void GLES2Implementation::GetVertexAttribPointerv(
}
#endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
- GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv");
+ TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv");
typedef gles2::GetVertexAttribPointerv::Result Result;
Result* result = GetResultAs<Result*>();
result->SetNumResults(0);
@@ -779,7 +779,7 @@ void GLES2Implementation::GetVertexAttribPointerv(
GLint GLES2Implementation::GetAttribLocation(
GLuint program, const char* name) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
+ TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
typedef GetAttribLocationBucket::Result Result;
Result* result = GetResultAs<Result*>();
*result = -1;
@@ -793,7 +793,7 @@ GLint GLES2Implementation::GetAttribLocation(
GLint GLES2Implementation::GetUniformLocation(
GLuint program, const char* name) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
+ TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
typedef GetUniformLocationBucket::Result Result;
Result* result = GetResultAs<Result*>();
*result = -1;
@@ -1104,7 +1104,7 @@ void GLES2Implementation::GetActiveAttrib(
SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0");
return;
}
- GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
+ TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
// Clear the bucket so if we the command fails nothing will be in it.
helper_->SetBucketSize(kResultBucketId, 0);
typedef gles2::GetActiveAttrib::Result Result;
@@ -1145,7 +1145,7 @@ void GLES2Implementation::GetActiveUniform(
SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0");
return;
}
- GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
+ TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
// Clear the bucket so if we the command fails nothing will be in it.
helper_->SetBucketSize(kResultBucketId, 0);
typedef gles2::GetActiveUniform::Result Result;
@@ -1185,7 +1185,7 @@ void GLES2Implementation::GetAttachedShaders(
SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0");
return;
}
- GPU_TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders");
+ TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders");
typedef gles2::GetAttachedShaders::Result Result;
uint32 size = Result::ComputeSize(maxcount);
Result* result = transfer_buffer_.AllocTyped<Result>(size);
@@ -1206,7 +1206,7 @@ void GLES2Implementation::GetAttachedShaders(
void GLES2Implementation::GetShaderPrecisionFormat(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat");
+ TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat");
typedef gles2::GetShaderPrecisionFormat::Result Result;
Result* result = static_cast<Result*>(result_buffer_);
result->success = false;
@@ -1258,7 +1258,7 @@ const GLubyte* GLES2Implementation::GetString(GLenum name) {
void GLES2Implementation::GetUniformfv(
GLuint program, GLint location, GLfloat* params) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformfv");
+ TRACE_EVENT0("gpu", "GLES2::GetUniformfv");
typedef gles2::GetUniformfv::Result Result;
Result* result = static_cast<Result*>(result_buffer_);
result->SetNumResults(0);
@@ -1270,7 +1270,7 @@ void GLES2Implementation::GetUniformfv(
void GLES2Implementation::GetUniformiv(
GLuint program, GLint location, GLint* params) {
- GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformiv");
+ TRACE_EVENT0("gpu", "GLES2::GetUniformiv");
typedef gles2::GetUniformiv::Result Result;
Result* result = static_cast<Result*>(result_buffer_);
result->SetNumResults(0);
@@ -1297,7 +1297,7 @@ void GLES2Implementation::ReadPixels(
// and that when we copy the results to the user's buffer we need to not
// write those padding bytes but leave them as they are.
- GPU_TRACE_EVENT0("gpu", "GLES2::ReadPixels");
+ TRACE_EVENT0("gpu", "GLES2::ReadPixels");
typedef gles2::ReadPixels::Result Result;
Result* result = static_cast<Result*>(result_buffer_);
int8* dest = reinterpret_cast<int8*>(pixels);
@@ -1537,7 +1537,7 @@ void GLES2Implementation::GetVertexAttribfv(
return;
}
#endif
- GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv");
+ TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv");
typedef GetVertexAttribfv::Result Result;
Result* result = GetResultAs<Result*>();
result->SetNumResults(0);
@@ -1556,7 +1556,7 @@ void GLES2Implementation::GetVertexAttribiv(
return;
}
#endif
- GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv");
+ TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv");
typedef GetVertexAttribiv::Result Result;
Result* result = GetResultAs<Result*>();
result->SetNumResults(0);
@@ -1568,7 +1568,7 @@ void GLES2Implementation::GetVertexAttribiv(
GLboolean GLES2Implementation::CommandBufferEnableCHROMIUM(
const char* feature) {
- GPU_TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM");
+ TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM");
typedef CommandBufferEnableCHROMIUM::Result Result;
Result* result = GetResultAs<Result*>();
*result = 0;
diff --git a/gpu/command_buffer/common/trace_event.h b/gpu/command_buffer/common/trace_event.h
new file mode 100644
index 0000000..9327063
--- /dev/null
+++ b/gpu/command_buffer/common/trace_event.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 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_TRACE_EVENT_H_
+#define GPU_COMMAND_BUFFER_COMMON_TRACE_EVENT_H_
+#pragma once
+
+#if !defined(__native_client__)
+
+#include "base/debug/trace_event.h"
+
+#else
+
+#define TRACE_EVENT0(x0, x1) { }
+#define TRACE_EVENT1(x0, x1, x2, x3) { }
+#define TRACE_EVENT2(x0, x1, x2, x3, x4, x5) { }
+#define TRACE_EVENT_INSTANT0(x0, x1) { }
+#define TRACE_EVENT_INSTANT1(x0, x1, x2, x3) { }
+#define TRACE_EVENT_INSTANT2(x0, x1, x2, x3, x4, x5) { }
+#define TRACE_BEGIN0(x0, x1) { }
+#define TRACE_BEGIN1(x0, x1, x2, x3) { }
+#define TRACE_BEGIN2(x0, x1, x2, x3, x4, x5) { }
+#define TRACE_END0(x0, x1) { }
+#define TRACE_END1(x0, x1, x2, x3) { }
+#define TRACE_END2(x0, x1, x2, x3, x4, x5) { }
+
+#endif // __native_client__
+
+#endif // GPU_COMMAND_BUFFER_COMMON_TRACE_EVENT_H_
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 13e73c1..ccaf5c3 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -22,6 +22,7 @@
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/common/id_allocator.h"
+#include "gpu/command_buffer/common/trace_event.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
@@ -34,7 +35,6 @@
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/command_buffer/service/shader_translator.h"
#include "gpu/command_buffer/service/texture_manager.h"
-#include "gpu/common/gpu_trace_event.h"
#include "gpu/GLES2/gles2_command_buffer.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_implementation.h"
@@ -5576,7 +5576,7 @@ error::Error GLES2DecoderImpl::DoTexImage2D(
error::Error GLES2DecoderImpl::HandleTexImage2D(
uint32 immediate_data_size, const gles2::TexImage2D& c) {
- GPU_TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexImage2D");
+ TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexImage2D");
tex_image_2d_failed_ = true;
GLenum target = static_cast<GLenum>(c.target);
GLint level = static_cast<GLint>(c.level);
@@ -5890,7 +5890,7 @@ void GLES2DecoderImpl::DoTexSubImage2D(
error::Error GLES2DecoderImpl::HandleTexSubImage2D(
uint32 immediate_data_size, const gles2::TexSubImage2D& c) {
- GPU_TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D");
+ TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D");
GLboolean internal = static_cast<GLboolean>(c.internal);
if (internal == GL_TRUE && tex_image_2d_failed_)
return error::kNoError;
@@ -6314,7 +6314,7 @@ error::Error GLES2DecoderImpl::HandleShaderBinary(
error::Error GLES2DecoderImpl::HandleSwapBuffers(
uint32 immediate_data_size, const gles2::SwapBuffers& c) {
- GPU_TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleSwapBuffers");
+ TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleSwapBuffers");
// If offscreen then don't actually SwapBuffers to the display. Just copy
// the rendered frame to another frame buffer.
if (offscreen_target_frame_buffer_.get()) {
@@ -6360,7 +6360,7 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
return error::kNoError;
}
} else {
- GPU_TRACE_EVENT0("gpu", "GLContext::SwapBuffers");
+ TRACE_EVENT0("gpu", "GLContext::SwapBuffers");
if (!context_->SwapBuffers()) {
LOG(ERROR) << "Context lost because SwapBuffers failed.";
return error::kLostContext;
@@ -6376,7 +6376,7 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM(
uint32 immediate_data_size, const gles2::SetLatchCHROMIUM& c) {
- GPU_TRACE_EVENT0("gpu", "SetLatch");
+ TRACE_EVENT0("gpu", "SetLatch");
// Ensure the side effects of previous commands are visible to other contexts.
// There is no need to do this for ANGLE because it uses a
// single D3D device for all contexts.
@@ -6403,7 +6403,7 @@ error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM(
error::Error GLES2DecoderImpl::HandleWaitLatchCHROMIUM(
uint32 immediate_data_size, const gles2::WaitLatchCHROMIUM& c) {
- GPU_TRACE_EVENT0("gpu", "WaitLatch");
+ TRACE_EVENT0("gpu", "WaitLatch");
int32 shm_id = gpu::kLatchSharedMemoryId;
uint32 latch_id = c.latch_id;
uint32 shm_offset = 0;
diff --git a/gpu/command_buffer/service/gpu_scheduler.cc b/gpu/command_buffer/service/gpu_scheduler.cc
index 09a24fd..059cc8f 100644
--- a/gpu/command_buffer/service/gpu_scheduler.cc
+++ b/gpu/command_buffer/service/gpu_scheduler.cc
@@ -6,8 +6,8 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/debug/trace_event.h"
#include "base/message_loop.h"
-#include "gpu/common/gpu_trace_event.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_bindings.h"
@@ -128,7 +128,7 @@ void GpuScheduler::PutChanged(bool sync) {
}
void GpuScheduler::ProcessCommands() {
- GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands");
+ TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands");
CommandBuffer::State state = command_buffer_->GetState();
if (state.error != error::kNoError)
return;
diff --git a/gpu/common/gpu_trace_event.cc b/gpu/common/gpu_trace_event.cc
deleted file mode 100644
index b92ce6d..0000000
--- a/gpu/common/gpu_trace_event.cc
+++ /dev/null
@@ -1,330 +0,0 @@
-// Copyright (c) 2011 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/common/gpu_trace_event.h"
-
-#include "base/format_macros.h"
-#include "base/process_util.h"
-#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
-#include "base/time.h"
-
-#define USE_UNRELIABLE_NOW
-
-using namespace base;
-
-namespace gpu {
-
-// Controls the number of trace events we will buffer in-memory
-// before throwing them away.
-#define TRACE_EVENT_BUFFER_SIZE 500000
-#define TRACE_EVENT_BATCH_SIZE 1000
-
-#define TRACE_EVENT_MAX_CATEGORIES 42
-
-static TraceCategory g_categories[TRACE_EVENT_MAX_CATEGORIES];
-static int g_category_index = 0;
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// TraceLog::Category
-//
-////////////////////////////////////////////////////////////////////////////////
-TraceCategory::TraceCategory()
- : name_(NULL) {
- base::subtle::NoBarrier_Store(&enabled_,
- static_cast<base::subtle::Atomic32>(0));
-}
-
-TraceCategory::~TraceCategory() {
- base::subtle::NoBarrier_Store(&enabled_,
- static_cast<base::subtle::Atomic32>(0));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// TraceValue
-//
-////////////////////////////////////////////////////////////////////////////////
-
-void TraceValue::Destroy() {
- if (type_ == TRACE_TYPE_STRING) {
- free(value_.as_string);
- value_.as_string = NULL;
- }
- type_ = TRACE_TYPE_UNDEFINED;
- value_.as_uint = 0ull;
-}
-
-TraceValue& TraceValue::operator=(const TraceValue& rhs) {
- DCHECK(sizeof(value_) == sizeof(uint64));
- Destroy();
- type_ = rhs.type_;
- if (rhs.type_ == TRACE_TYPE_STRING) {
- value_.as_string = base::strdup(rhs.value_.as_string);
- } else {
- // Copy all 64 bits for all other types.
- value_.as_uint = rhs.value_.as_uint;
- }
- return *this;
-}
-
-bool TraceValue::operator==(const TraceValue& rhs) const {
- if (type_ != rhs.type())
- return false;
- if (rhs.type_ == TRACE_TYPE_STRING) {
- return (strcmp(value_.as_string, rhs.value_.as_string) == 0);
- } else {
- // Compare all 64 bits for all other types. Unused bits are set to zero
- // by the constructors of types that may be less than 64 bits.
- return (value_.as_uint == rhs.value_.as_uint);
- }
-}
-
-void TraceValue::AppendAsJSON(std::string* out) const {
- char temp_string[128];
- std::string::size_type start_pos;
- switch (type_) {
- case TRACE_TYPE_BOOL:
- *out += as_bool()? "true" : "false";
- break;
- case TRACE_TYPE_UINT:
- base::snprintf(temp_string, sizeof(temp_string), "%llu",
- static_cast<unsigned long long>(as_uint()));
- *out += temp_string;
- break;
- case TRACE_TYPE_INT:
- base::snprintf(temp_string, sizeof(temp_string), "%lld",
- static_cast<long long>(as_int()));
- *out += temp_string;
- break;
- case TRACE_TYPE_DOUBLE:
- base::snprintf(temp_string, sizeof(temp_string), "%f", as_double());
- *out += temp_string;
- break;
- case TRACE_TYPE_POINTER:
- base::snprintf(temp_string, sizeof(temp_string), "%p", as_pointer());
- *out += temp_string;
- break;
- case TRACE_TYPE_STRING:
- start_pos = out->size();
- *out += as_string();
- // replace " character with '
- while ((start_pos = out->find_first_of('\"', start_pos)) !=
- std::string::npos)
- (*out)[start_pos] = '\'';
- break;
- default:
- break;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// TraceEvent
-//
-////////////////////////////////////////////////////////////////////////////////
-
-namespace {
-const char* GetPhaseStr(TraceEventPhase phase) {
- if (phase == GPU_TRACE_EVENT_PHASE_BEGIN) {
- return "B";
- } else if (phase == GPU_TRACE_EVENT_PHASE_INSTANT) {
- return "I";
- } else if (phase == GPU_TRACE_EVENT_PHASE_END) {
- return "E";
- } else {
- DCHECK(false);
- return "?";
- }
-}
-}
-
-TraceEvent::TraceEvent()
- : processId(0),
- threadId(0),
- phase(GPU_TRACE_EVENT_PHASE_BEGIN),
- category(NULL),
- name(NULL) {
- memset(&argNames, 0, sizeof(argNames));
-}
-
-TraceEvent::~TraceEvent() {
-}
-
-
-void TraceEvent::AppendAsJSON(std::string* out,
- const std::vector<TraceEvent>& events,
- size_t start,
- size_t count) {
- *out += "[";
- for (size_t i = 0; i < count && start + i < events.size(); ++i) {
- if (i > 0)
- *out += ",";
- events[i + start].AppendAsJSON(out);
- }
- *out += "]";
-}
-
-void TraceEvent::AppendAsJSON(std::string* out) const {
- int nargs = 0;
- for (int i = 0; i < TRACE_MAX_NUM_ARGS; ++i) {
- if (argNames[i] == NULL)
- break;
- nargs += 1;
- }
-
- const char* phaseStr = GetPhaseStr(phase);
- int64 time_int64 = timestamp.ToInternalValue();
- StringAppendF(out,
- "{\"cat\":\"%s\",\"pid\":%i,\"tid\":%i,\"ts\":%lld,"
- "\"ph\":\"%s\",\"name\":\"%s\",\"args\":{",
- category->name(),
- static_cast<int>(processId),
- static_cast<int>(threadId),
- static_cast<long long>(time_int64),
- phaseStr,
- name);
- for (int i = 0; i < nargs; ++i) {
- if (i > 0)
- *out += ",";
- *out += "\"";
- *out += argNames[i];
- *out += "\":\"";
- argValues[i].AppendAsJSON(out);
- *out += "\"";
- }
- *out += "}}";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// TraceLog
-//
-////////////////////////////////////////////////////////////////////////////////
-
-// static
-TraceLog* TraceLog::GetInstance() {
- return Singleton<TraceLog, StaticMemorySingletonTraits<TraceLog> >::get();
-}
-
-TraceLog::TraceLog()
- : enabled_(false)
-{
- logged_events_.reserve(1024);
-}
-
-TraceLog::~TraceLog() {
-}
-
-TraceCategory* TraceLog::GetCategory(const char* name) {
- AutoLock lock(lock_);
- for (int i = 0; i < g_category_index; i++) {
- if (strcmp(g_categories[i].name(), name) == 0)
- return &g_categories[i];
- }
- CHECK(g_category_index < TRACE_EVENT_MAX_CATEGORIES) <<
- "must increase TRACE_EVENT_MAX_CATEGORIES";
- int new_index = g_category_index++;
- g_categories[new_index].set(name, enabled_);
- return &g_categories[new_index];
-}
-
-void TraceLog::SetEnabled(bool enabled) {
- AutoLock lock(lock_);
- if (enabled == enabled_)
- return;
- if (enabled) {
- // Enable all categories.
- enabled_ = true;
- for (int i = 0; i < g_category_index; i++) {
- base::subtle::NoBarrier_Store(&g_categories[i].enabled_,
- static_cast<base::subtle::Atomic32>(1));
- }
- } else {
- // Disable all categories.
- for (int i = 0; i < g_category_index; i++) {
- base::subtle::NoBarrier_Store(&g_categories[i].enabled_,
- static_cast<base::subtle::Atomic32>(0));
- }
- enabled_ = false;
- FlushWithLockAlreadyHeld();
- }
-}
-
-float TraceLog::GetBufferPercentFull() const {
- return (float)((double)logged_events_.size()/(double)TRACE_EVENT_BUFFER_SIZE);
-}
-
-void TraceLog::SetOutputCallback(TraceLog::OutputCallback* cb) {
- AutoLock lock(lock_);
- if (enabled_) {
- FlushWithLockAlreadyHeld();
- }
- output_callback_.reset(cb);
-}
-
-void TraceLog::SetBufferFullCallback(TraceLog::BufferFullCallback* cb) {
- AutoLock lock(lock_);
- buffer_full_callback_.reset(cb);
-}
-
-void TraceLog::AddRemotelyCollectedData(const std::string& json_events) {
- AutoLock lock(lock_);
- if (output_callback_.get())
- output_callback_->Run(json_events);
-}
-
-void TraceLog::Flush() {
- AutoLock lock(lock_);
- FlushWithLockAlreadyHeld();
-}
-
-void TraceLog::FlushWithLockAlreadyHeld() {
- if (output_callback_.get() && logged_events_.size()) {
- for (size_t i = 0; i < logged_events_.size(); i += TRACE_EVENT_BATCH_SIZE) {
- std::string json_events;
- TraceEvent::AppendAsJSON(&json_events, logged_events_,
- i, TRACE_EVENT_BATCH_SIZE);
- output_callback_->Run(json_events);
- }
- }
- logged_events_.erase(logged_events_.begin(), logged_events_.end());
-}
-
-void TraceLog::AddTraceEvent(TraceEventPhase phase,
- const char* file, int line,
- TraceCategory* category,
- const char* name,
- const char* arg1name, TraceValue arg1val,
- const char* arg2name, TraceValue arg2val) {
- DCHECK(file && name);
-#ifdef USE_UNRELIABLE_NOW
- TimeTicks now = TimeTicks::HighResNow();
-#else
- TimeTicks now = TimeTicks::Now();
-#endif
- //static_cast<unsigned long>(base::GetCurrentProcId()),
- AutoLock lock(lock_);
- if (logged_events_.size() >= TRACE_EVENT_BUFFER_SIZE)
- return;
- logged_events_.push_back(TraceEvent());
- TraceEvent& event = logged_events_.back();
- event.processId = static_cast<unsigned long>(base::GetCurrentProcId());
- event.threadId = PlatformThread::CurrentId();
- event.timestamp = now;
- event.phase = phase;
- event.category = category;
- event.name = name;
- event.argNames[0] = arg1name;
- event.argValues[0] = arg1val;
- event.argNames[1] = arg2name;
- event.argValues[1] = arg2val;
- COMPILE_ASSERT(TRACE_MAX_NUM_ARGS == 2, TraceEvent_arc_count_out_of_sync);
- if (logged_events_.size() == TRACE_EVENT_BUFFER_SIZE &&
- buffer_full_callback_.get())
- buffer_full_callback_->Run();
-}
-
-} // namespace gpu
diff --git a/gpu/common/gpu_trace_event.h b/gpu/common/gpu_trace_event.h
deleted file mode 100644
index 581b66e..0000000
--- a/gpu/common/gpu_trace_event.h
+++ /dev/null
@@ -1,439 +0,0 @@
-// Copyright (c) 2011 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.
-
-// Trace events are for tracking application performance.
-//
-// Events are issued against categories. Whereas LOG's
-// categories are statically defined, TRACE categories are created
-// implicitly with a string. For example:
-// GPU_TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
-//
-// Events can be INSTANT, or can be pairs of BEGIN and END:
-// GPU_TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
-// doSomethingCostly()
-// GPU_TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
-//
-// A common use case is to trace entire function scopes. This
-// issues a trace BEGIN and END automatically:
-// void doSomethingCostly() {
-// GPU_TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
-// ...
-// }
-//
-// Additional parameters can be associated with an event:
-// void doSomethingCostly2(int howMuch) {
-// GPU_TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
-// "howMuch", StringPrintf("%i", howMuch).c_str());
-// ...
-// }
-//
-// The trace system will automatically add to this information the
-// current process id, thread id, a timestamp down to the
-// microsecond, as well as the file and line number of the calling location.
-//
-// By default, trace collection is compiled in, but turned off at runtime.
-// Collecting trace data is the responsibility of the embedding
-// application. In Chrome's case, navigating to about:gpu will turn on
-// tracing and display data collected across all active processes.
-//
-
-#ifndef GPU_TRACE_EVENT_H_
-#define GPU_TRACE_EVENT_H_
-#pragma once
-
-#if defined(__native_client__)
-
-// Native Client needs to avoid pulling in base/ headers,
-// so stub out the tracing code at compile time.
-#define GPU_TRACE_EVENT0(x0, x1) { }
-#define GPU_TRACE_EVENT1(x0, x1, x2, x3) { }
-#define GPU_TRACE_EVENT2(x0, x1, x2, x3, x4, x5) { }
-#define GPU_TRACE_EVENT_INSTANT0(x0, x1) { }
-#define GPU_TRACE_EVENT_INSTANT1(x0, x1, x2, x3) { }
-#define GPU_TRACE_EVENT_INSTANT2(x0, x1, x2, x3, x4, x5) { }
-#define GPU_TRACE_BEGIN0(x0, x1) { }
-#define GPU_TRACE_BEGIN1(x0, x1, x2, x3) { }
-#define GPU_TRACE_BEGIN2(x0, x1, x2, x3, x4, x5) { }
-#define GPU_TRACE_END0(x0, x1) { }
-#define GPU_TRACE_END1(x0, x1, x2, x3) { }
-#define GPU_TRACE_END2(x0, x1, x2, x3, x4, x5) { }
-
-#else
-
-#include "build/build_config.h"
-
-#include <string>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/atomicops.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/singleton.h"
-#include "base/time.h"
-#include "base/timer.h"
-#include "base/callback.h"
-#include "base/string_util.h"
-#include <vector>
-
-
-// Implementation detail: trace event macros create temporary variables
-// to keep instrumentation overhead low. These macros give each temporary
-// variable a unique name based on the line number to prevent name collissions.
-#define GPU_TRACE_EVENT_UNIQUE_IDENTIFIER3(a,b) a##b
-#define GPU_TRACE_EVENT_UNIQUE_IDENTIFIER2(a,b) \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER3(a,b)
-#define GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(name_prefix) \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER2(name_prefix, __LINE__)
-
-// Records a pair of begin and end events called "name" for the current
-// scope, with 0, 1 or 2 associated arguments. If the category is not
-// enabled, then this does nothing.
-#define GPU_TRACE_EVENT0(category, name) \
- GPU_TRACE_EVENT1(category, name, NULL, 0)
-#define GPU_TRACE_EVENT1(category, name, arg1name, arg1val) \
- GPU_TRACE_EVENT2(category, name, arg1name, arg1val, NULL, 0)
-#define GPU_TRACE_EVENT2(category, name, arg1name, arg1val, arg2name, arg2val) \
- static gpu::TraceCategory* \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic) = \
- gpu::TraceLog::GetInstance()->GetCategory(category); \
- if (base::subtle::Acquire_Load(\
- &(GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic))->enabled_)) { \
- gpu::TraceLog::GetInstance()->AddTraceEvent( \
- gpu::GPU_TRACE_EVENT_PHASE_BEGIN, \
- __FILE__, __LINE__, \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic), \
- name, \
- arg1name, arg1val, \
- arg2name, arg2val); \
- } \
- gpu::internal::TraceEndOnScopeClose __profileScope ## __LINE ( \
- __FILE__, __LINE__, \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic), name);
-
-// Records a single event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-#define GPU_TRACE_EVENT_INSTANT0(category, name) \
- GPU_TRACE_EVENT_INSTANT1(category, name, NULL, 0)
-#define GPU_TRACE_EVENT_INSTANT1(category, name, arg1name, arg1val) \
- GPU_TRACE_EVENT_INSTANT2(category, name, arg1name, arg1val, NULL, 0)
-#define GPU_TRACE_EVENT_INSTANT2(category, name, arg1name, arg1val, \
- arg2name, arg2val) \
- static gpu::TraceCategory* \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic) = \
- gpu::TraceLog::GetInstance()->GetCategory(category); \
- if (base::subtle::Acquire_Load( \
- &(GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic))->enabled_)) { \
- gpu::TraceLog::GetInstance()->AddTraceEvent( \
- gpu::GPU_TRACE_EVENT_PHASE_INSTANT, \
- __FILE__, __LINE__, \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic), \
- name, \
- arg1name, arg1val, \
- arg2name, arg2val); \
- }
-
-// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-#define GPU_TRACE_EVENT_BEGIN0(category, name) \
- GPU_TRACE_EVENT_BEGIN1(category, name, NULL, 0)
-#define GPU_TRACE_EVENT_BEGIN1(category, name, arg1name, arg1val) \
- GPU_TRACE_EVENT_BEGIN2(category, name, arg1name, arg1val, NULL, 0)
-#define GPU_TRACE_EVENT_BEGIN2(category, name, arg1name, arg1val, \
- arg2name, arg2val) \
- static gpu::TraceCategory* \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic) = \
- gpu::TraceLog::GetInstance()->GetCategory(category); \
- if (base::subtle::Acquire_Load( \
- &(GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic))->enabled_)) { \
- gpu::TraceLog::GetInstance()->AddTraceEvent( \
- gpu::GPU_TRACE_EVENT_PHASE_BEGIN, \
- __FILE__, __LINE__, \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic), \
- name, \
- arg1name, arg1val, \
- arg2name, arg2val); \
- }
-
-// Records a single END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-#define GPU_TRACE_EVENT_END0(category, name) \
- static gpu::TraceCategory* \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic) = \
- gpu::TraceLog::GetInstance()->GetCategory(category); \
- if (base::subtle::Acquire_Load( \
- &(GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic))->enabled_)) { \
- gpu::TraceLog::GetInstance()->AddTraceEvent( \
- gpu::GPU_TRACE_EVENT_PHASE_END, \
- __FILE__, __LINE__, \
- GPU_TRACE_EVENT_UNIQUE_IDENTIFIER(catstatic), \
- name, \
- NULL, 0, \
- NULL, 0); \
- }
-
-
-namespace gpu {
-
-// Categories allow enabling/disabling of streams of trace events
-// Don't manipulate the category object directly, as this may lead
-// to threading issues. Use the TraceLog methods instead.
-class TraceCategory {
- public:
- TraceCategory();
- ~TraceCategory();
-
- void set(const char* name, bool enabled) {
- name_ = name;
- base::subtle::NoBarrier_Store(&enabled_,
- static_cast<base::subtle::Atomic32>(enabled));
- }
-
- const char* name() const { return name_; }
-
- // NEVER read these directly, let the macros do it for you
- volatile base::subtle::Atomic32 enabled_;
- protected:
- const char* name_;
-};
-
-#define TRACE_MAX_NUM_ARGS 2
-
-enum TraceEventPhase {
- GPU_TRACE_EVENT_PHASE_BEGIN,
- GPU_TRACE_EVENT_PHASE_END,
- GPU_TRACE_EVENT_PHASE_INSTANT
-};
-
-// Simple union of values. This is much lighter weight than base::Value, which
-// requires dynamic allocation and a vtable. To keep the trace runtime overhead
-// low, we want constant size storage here.
-class TraceValue {
- public:
- enum Type {
- TRACE_TYPE_UNDEFINED,
- TRACE_TYPE_BOOL,
- TRACE_TYPE_UINT,
- TRACE_TYPE_INT,
- TRACE_TYPE_DOUBLE,
- TRACE_TYPE_POINTER,
- TRACE_TYPE_STRING
- };
-
- TraceValue() : type_(TRACE_TYPE_UNDEFINED) {
- value_.as_uint = 0ull;
- }
- TraceValue(bool rhs) : type_(TRACE_TYPE_BOOL) {
- value_.as_uint = 0ull; // zero all bits
- value_.as_bool = rhs;
- }
- TraceValue(uint64 rhs) : type_(TRACE_TYPE_UINT) {
- value_.as_uint = rhs;
- }
- TraceValue(uint32 rhs) : type_(TRACE_TYPE_UINT) {
- value_.as_uint = rhs;
- }
- TraceValue(uint16 rhs) : type_(TRACE_TYPE_UINT) {
- value_.as_uint = rhs;
- }
- TraceValue(uint8 rhs) : type_(TRACE_TYPE_UINT) {
- value_.as_uint = rhs;
- }
- TraceValue(int64 rhs) : type_(TRACE_TYPE_INT) {
- value_.as_int = rhs;
- }
- TraceValue(int32 rhs) : type_(TRACE_TYPE_INT) {
- value_.as_int = rhs;
- }
- TraceValue(int16 rhs) : type_(TRACE_TYPE_INT) {
- value_.as_int = rhs;
- }
- TraceValue(int8 rhs) : type_(TRACE_TYPE_INT) {
- value_.as_int = rhs;
- }
- TraceValue(double rhs) : type_(TRACE_TYPE_DOUBLE) {
- value_.as_double = rhs;
- }
- TraceValue(const void* rhs) : type_(TRACE_TYPE_POINTER) {
- value_.as_uint = 0ull; // zero all bits
- value_.as_pointer = rhs;
- }
- explicit TraceValue(const char* rhs) : type_(TRACE_TYPE_STRING) {
- value_.as_uint = 0ull; // zero all bits
- value_.as_string = base::strdup(rhs);
- }
- TraceValue(const TraceValue& rhs) : type_(TRACE_TYPE_UNDEFINED) {
- operator=(rhs);
- }
- ~TraceValue() {
- Destroy();
- }
-
- TraceValue& operator=(const TraceValue& rhs);
- bool operator==(const TraceValue& rhs) const;
- bool operator!=(const TraceValue& rhs) const {
- return !operator==(rhs);
- }
-
- void Destroy();
-
- void AppendAsJSON(std::string* out) const;
-
- Type type() const {
- return type_;
- }
- uint64 as_uint() const {
- return value_.as_uint;
- }
- bool as_bool() const {
- return value_.as_bool;
- }
- int64 as_int() const {
- return value_.as_int;
- }
- double as_double() const {
- return value_.as_double;
- }
- const void* as_pointer() const {
- return value_.as_pointer;
- }
- const char* as_string() const {
- return value_.as_string;
- }
-
- private:
- union Value {
- bool as_bool;
- uint64 as_uint;
- int64 as_int;
- double as_double;
- const void* as_pointer;
- char* as_string;
- };
-
- Type type_;
- Value value_;
-};
-
-// Output records are "Events" and can be obtained via the
-// OutputCallback whenever the logging system decides to flush. This
-// can happen at any time, on any thread, or you can programatically
-// force it to happen.
-struct TraceEvent {
- static void AppendAsJSON(std::string* out,
- const std::vector<TraceEvent>& events,
- size_t start,
- size_t count);
- TraceEvent();
- ~TraceEvent();
- void AppendAsJSON(std::string* out) const;
-
-
- unsigned long processId;
- unsigned long threadId;
- base::TimeTicks timestamp;
- TraceEventPhase phase;
- TraceCategory* category;
- const char* name;
- const char* argNames[TRACE_MAX_NUM_ARGS];
- TraceValue argValues[TRACE_MAX_NUM_ARGS];
-};
-
-
-class TraceLog {
- public:
- static TraceLog* GetInstance();
-
- // Global enable of tracing. Currently enables all categories or not.
- // TODO(nduca) Replaced with an Enable/DisableCategory() that
- // implicitly controls the global logging state.
- void SetEnabled(bool enabled);
-
- float GetBufferPercentFull() const;
-
- // When enough events are collected, they are handed (in bulk) to
- // the output callback. If no callback is set, the output will be
- // silently dropped.
- typedef Callback1<const std::string& /* json_events */>::Type OutputCallback;
- void SetOutputCallback(OutputCallback* cb);
-
- // The trace buffer does not flush dynamically, so when it fills up,
- // subsequent trace events will be dropped. This callback is generated when
- // the trace buffer is full.
- typedef Callback0::Type BufferFullCallback;
- void SetBufferFullCallback(BufferFullCallback* cb);
-
- // Forwards data collected by a child process to the registered
- // output callback.
- void AddRemotelyCollectedData(const std::string& json_events);
-
- // Flushes all logged data to the callback.
- void Flush();
-
- // Called by GPU_TRACE_EVENT* macros, don't call this directly.
- TraceCategory* GetCategory(const char* name);
-
- // Called by GPU_TRACE_EVENT* macros, don't call this directly.
- void AddTraceEvent(TraceEventPhase phase,
- const char* file, int line,
- TraceCategory* category,
- const char* name,
- const char* arg1name, TraceValue arg1val,
- const char* arg2name, TraceValue arg2val);
-
- private:
- // This allows constructor and destructor to be private and usable only
- // by the Singleton class.
- friend struct StaticMemorySingletonTraits<TraceLog>;
-
- TraceLog();
- ~TraceLog();
- void FlushWithLockAlreadyHeld();
-
- // TODO(nduca): switch to per-thread trace buffers to reduce thread
- // synchronization.
- base::Lock lock_;
- bool enabled_;
- scoped_ptr<OutputCallback> output_callback_;
- scoped_ptr<BufferFullCallback> buffer_full_callback_;
- std::vector<TraceEvent> logged_events_;
-
- DISALLOW_COPY_AND_ASSIGN(TraceLog);
-};
-
-namespace internal {
-
-// Used by GPU_TRACE_EVENTx macro. Do not use directly.
-class TraceEndOnScopeClose {
- public:
- TraceEndOnScopeClose(const char* file, int line,
- TraceCategory* category,
- const char* name)
- : file_(file)
- , line_(line)
- , category_(category)
- , name_(name) { }
-
- ~TraceEndOnScopeClose() {
- if (base::subtle::Acquire_Load(&category_->enabled_))
- gpu::TraceLog::GetInstance()->AddTraceEvent(
- gpu::GPU_TRACE_EVENT_PHASE_END,
- file_, line_,
- category_,
- name_,
- NULL, 0, NULL, 0);
- }
-
- private:
- const char* file_;
- int line_;
- TraceCategory* category_;
- const char* name_;
-};
-
-} // namespace internal
-
-} // namespace gpu
-#endif // __native_client__
-#endif // GPU_TRACE_EVENT_H_
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 265ec80..5bbef50 100644..100755
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -25,21 +25,6 @@
},
'targets': [
{
- 'target_name': 'gpu_common',
- 'type': 'static_library',
- 'dependencies': [
- '../base/base.gyp:base',
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- ],
- 'include_dirs': [
- '..',
- ],
- 'sources': [
- 'common/gpu_trace_event.cc',
- 'common/gpu_trace_event.h',
- ],
- },
- {
'target_name': 'command_buffer_common',
'type': 'static_library',
'include_dirs': [
@@ -95,6 +80,7 @@
'target_name': 'gles2_implementation',
'type': 'static_library',
'dependencies': [
+ '../base/base.gyp:base',
'gles2_cmd_helper',
],
'all_dependent_settings': {
@@ -167,7 +153,6 @@
},
'dependencies': [
'command_buffer_common',
- 'gpu_common',
],
'sources': [
'command_buffer/client/cmd_buffer_helper.cc',
@@ -193,7 +178,6 @@
},
'dependencies': [
'command_buffer_common',
- 'gpu_common',
'../base/base.gyp:base',
'../ui/gfx/gl/gl.gyp:gl',
'../ui/gfx/surface/surface.gyp:surface',
@@ -264,7 +248,6 @@
'command_buffer_client',
'command_buffer_common',
'command_buffer_service',
- 'gpu_common',
'gpu_unittest_utils',
'gles2_implementation_client_side_arrays',
'gles2_cmd_helper',
@@ -283,26 +266,15 @@
'command_buffer/common/gles2_cmd_format_test_autogen.h',
'command_buffer/common/gles2_cmd_id_test.cc',
'command_buffer/common/gles2_cmd_id_test_autogen.h',
- 'command_buffer/common/gles2_cmd_format_test.cc',
- 'command_buffer/common/gles2_cmd_format_test_autogen.h',
- 'command_buffer/common/gles2_cmd_id_test.cc',
- 'command_buffer/common/gles2_cmd_id_test_autogen.h',
- 'command_buffer/common/gles2_cmd_format_test.cc',
- 'command_buffer/common/gles2_cmd_format_test_autogen.h',
- 'command_buffer/common/gles2_cmd_id_test.cc',
- 'command_buffer/common/gles2_cmd_id_test_autogen.h',
'command_buffer/common/id_allocator_test.cc',
+ 'command_buffer/common/trace_event.h',
'command_buffer/common/unittest_main.cc',
'command_buffer/service/buffer_manager_unittest.cc',
- 'command_buffer/service/context_group_unittest.cc',
- 'command_buffer/service/cmd_parser_test.cc',
'command_buffer/service/cmd_parser_test.cc',
'command_buffer/service/common_decoder_unittest.cc',
+ 'command_buffer/service/context_group_unittest.cc',
'command_buffer/service/feature_info_unittest.cc',
'command_buffer/service/framebuffer_manager_unittest.cc',
- 'command_buffer/service/gpu_scheduler_unittest.cc',
- 'command_buffer/service/gles2_cmd_decoder_unittest_base.h',
- 'command_buffer/service/gles2_cmd_decoder_unittest_base.cc',
'command_buffer/service/gles2_cmd_decoder_unittest.cc',
'command_buffer/service/gles2_cmd_decoder_unittest_1.cc',
'command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h',
@@ -310,6 +282,9 @@
'command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h',
'command_buffer/service/gles2_cmd_decoder_unittest_3.cc',
'command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_base.cc',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_base.h',
+ 'command_buffer/service/gpu_scheduler_unittest.cc',
'command_buffer/service/id_manager_unittest.cc',
'command_buffer/service/mocks.cc',
'command_buffer/service/mocks.h',
@@ -317,8 +292,8 @@
'command_buffer/service/renderbuffer_manager_unittest.cc',
'command_buffer/service/shader_manager_unittest.cc',
'command_buffer/service/shader_translator_unittest.cc',
- 'command_buffer/service/test_helper.h',
'command_buffer/service/test_helper.cc',
+ 'command_buffer/service/test_helper.h',
'command_buffer/service/texture_manager_unittest.cc',
],
},