Commit 6b6e7ee2 authored by gman@chromium.org's avatar gman@chromium.org

Add IPC to allow gpu process to send message for console back to renderer

BUG=107294
TEST=none


Review URL: http://codereview.chromium.org/8917027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114191 0039d316-1c4b-4281-b951-d872f2087c98
parent 51a5ca55
......@@ -249,6 +249,10 @@ void GpuCommandBufferStub::OnInitialize(
decoder_->set_debug(true);
}
decoder_->SetMsgCallback(
base::Bind(&GpuCommandBufferStub::SendConsoleMessage,
base::Unretained(this)));
SetSwapInterval();
command_buffer_->SetPutOffsetChangeCallback(
......@@ -474,4 +478,16 @@ void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
surface_->SetVisible(visible);
}
void GpuCommandBufferStub::SendConsoleMessage(
int32 id,
const std::string& message) {
GPUCommandBufferConsoleMessage console_message;
console_message.id = id;
console_message.message = message;
IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg(
route_id_, console_message);
msg->set_unblock(true);
Send(msg);
}
#endif // defined(ENABLE_GPU)
......@@ -86,6 +86,9 @@ class GpuCommandBufferStub
gfx::GpuPreference gpu_preference() { return gpu_preference_; }
// Sends a message to the console.
void SendConsoleMessage(int32 id, const std::string& message);
private:
void Destroy();
......
......@@ -82,6 +82,11 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params)
#endif
IPC_STRUCT_END()
IPC_STRUCT_BEGIN(GPUCommandBufferConsoleMessage)
IPC_STRUCT_MEMBER(int32, id)
IPC_STRUCT_MEMBER(std::string, message)
IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(content::DxDiagNode)
IPC_STRUCT_TRAITS_MEMBER(values)
IPC_STRUCT_TRAITS_MEMBER(children)
......@@ -352,6 +357,10 @@ IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_Rescheduled)
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_UpdateState,
gpu::CommandBuffer::State /* state */)
// Sent by the GPU process to display messages in the console.
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_ConsoleMsg,
GPUCommandBufferConsoleMessage /* msg */)
// Create a shared memory transfer buffer. Returns an id that can be used to
// identify the transfer buffer from a comment.
IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_CreateTransferBuffer,
......
......@@ -49,6 +49,7 @@ bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint,
OnNotifyRepaint);
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EchoAck, OnEchoAck);
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
......@@ -87,6 +88,13 @@ void CommandBufferProxy::OnEchoAck() {
callback.Run();
}
void CommandBufferProxy::OnConsoleMessage(
const GPUCommandBufferConsoleMessage& message) {
// TODO(gman): Pass this on to the console.
DLOG(INFO) << "CONSOLE_MESSAGE: "
<< message.id << " : " << message.message;
}
void CommandBufferProxy::SetChannelErrorCallback(
const base::Closure& callback) {
channel_error_callback_ = callback;
......
......@@ -22,6 +22,7 @@
#include "ipc/ipc_message.h"
class GpuChannelHost;
struct GPUCommandBufferConsoleMessage;
namespace base {
class SharedMemory;
......@@ -102,6 +103,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
void OnNotifyRepaint();
void OnDestroyed(gpu::error::ContextLostReason reason);
void OnEchoAck();
void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message);
// Local cache of id to transfer buffer mapping.
typedef std::map<int32, gpu::Buffer> TransferBufferMap;
......
......@@ -60,6 +60,13 @@ class CommandBuffer {
uint32 generation;
};
struct ConsoleMessage {
// An user supplied id.
int32 id;
// The message.
std::string message;
};
CommandBuffer() {
}
......
......@@ -521,6 +521,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
const base::Callback<void(gfx::Size)>& callback);
virtual void SetSwapBuffersCallback(const base::Closure& callback);
virtual void SetMsgCallback(const MsgCallback& callback);
virtual void SetStreamTextureManager(StreamTextureManager* manager);
virtual bool GetServiceTextureId(uint32 client_texture_id,
......@@ -1424,6 +1425,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
base::Callback<void(gfx::Size)> resize_callback_;
base::Closure swap_buffers_callback_;
MsgCallback msg_callback_;
StreamTextureManager* stream_texture_manager_;
......@@ -2593,6 +2595,10 @@ void GLES2DecoderImpl::SetSwapBuffersCallback(const base::Closure& callback) {
swap_buffers_callback_ = callback;
}
void GLES2DecoderImpl::SetMsgCallback(const MsgCallback& callback) {
msg_callback_ = callback;
}
void GLES2DecoderImpl::SetStreamTextureManager(StreamTextureManager* manager) {
stream_texture_manager_ = manager;
}
......@@ -4568,6 +4574,9 @@ void GLES2DecoderImpl::SetGLError(GLenum error, const char* msg) {
if (msg) {
last_error_ = msg;
LOG(ERROR) << last_error_;
if (!msg_callback_.is_null()) {
msg_callback_.Run(0, GLES2Util::GetStringEnum(error) + " : " + msg);
}
}
error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
}
......
......@@ -43,6 +43,7 @@ struct DisallowedFeatures {
class GLES2Decoder : public CommonDecoder {
public:
typedef error::Error Error;
typedef base::Callback<void(int32 id, const std::string& msg)> MsgCallback;
// Creates a decoder.
static GLES2Decoder* Create(ContextGroup* group);
......@@ -133,6 +134,9 @@ class GLES2Decoder : public CommonDecoder {
int width,
int height) = 0;
// A callback for messages from the decoder.
virtual void SetMsgCallback(const MsgCallback& callback) = 0;
protected:
GLES2Decoder();
......
......@@ -66,6 +66,7 @@ class MockGLES2Decoder : public GLES2Decoder {
unsigned type,
int width,
int height));
MOCK_METHOD1(SetMsgCallback, void(const MsgCallback& callback));
DISALLOW_COPY_AND_ASSIGN(MockGLES2Decoder);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment