#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/rand_util.h"
#include "base/strings/string_util.h"
#include "base/timer/timer.h"
#include "content/common/gpu/devtools_gpu_agent.h"
#include "content/common/gpu/media/gpu_video_encode_accelerator.h"
#include "content/common/gpu/sync_point_manager.h"
#include "content/public/common/content_switches.h"
-#include "crypto/hmac.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "gpu/command_buffer/service/image_manager.h"
class GpuChannelMessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
// Takes ownership of gpu_channel (see below).
- GpuChannelMessageFilter(const std::string& private_key,
- base::WeakPtr<GpuChannel>* gpu_channel,
+ GpuChannelMessageFilter(base::WeakPtr<GpuChannel>* gpu_channel,
scoped_refptr<SyncPointManager> sync_point_manager,
scoped_refptr<base::MessageLoopProxy> message_loop)
: preemption_state_(IDLE),
sync_point_manager_(sync_point_manager),
message_loop_(message_loop),
messages_forwarded_to_channel_(0),
- a_stub_is_descheduled_(false),
- hmac_(crypto::HMAC::SHA256) {
- bool success = hmac_.Init(base::StringPiece(private_key));
- DCHECK(success);
+ a_stub_is_descheduled_(false) {
}
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE {
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
DCHECK(channel_);
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message)
- IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNames,
- OnGenerateMailboxNames)
- IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNamesAsync,
- OnGenerateMailboxNamesAsync)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
+ bool handled = false;
if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) {
// This message should not be sent explicitly by the renderer.
- NOTREACHED();
+ DLOG(ERROR) << "Client should not send "
+ "GpuCommandBufferMsg_RetireSyncPoint message";
handled = true;
}
}
private:
- // Message handlers.
- void OnGenerateMailboxNames(unsigned num, std::vector<gpu::Mailbox>* result) {
- TRACE_EVENT1("gpu", "OnGenerateMailboxNames", "num", num);
-
- result->resize(num);
-
- for (unsigned i = 0; i < num; ++i) {
- char name[GL_MAILBOX_SIZE_CHROMIUM];
- base::RandBytes(name, sizeof(name) / 2);
-
- bool success = hmac_.Sign(
- base::StringPiece(name, sizeof(name) / 2),
- reinterpret_cast<unsigned char*>(name) + sizeof(name) / 2,
- sizeof(name) / 2);
- DCHECK(success);
-
- (*result)[i].SetName(reinterpret_cast<int8*>(name));
- }
- }
-
- void OnGenerateMailboxNamesAsync(unsigned num) {
- std::vector<gpu::Mailbox> names;
- OnGenerateMailboxNames(num, &names);
- Send(new GpuChannelMsg_GenerateMailboxNamesReply(names));
- }
-
enum PreemptionState {
// Either there's no other channel to preempt, there are no messages
// pending processing, or we just finished preempting and have to wait
base::OneShotTimer<GpuChannelMessageFilter> timer_;
bool a_stub_is_descheduled_;
-
- crypto::HMAC hmac_;
};
GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager,
channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
const CommandLine* command_line = CommandLine::ForCurrentProcess();
log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
- disallowed_features_.multisampling =
- command_line->HasSwitch(switches::kDisableGLMultisampling);
}
weak_factory_.GetWeakPtr()));
filter_ = new GpuChannelMessageFilter(
- mailbox_manager_->private_key(),
weak_ptr,
gpu_channel_manager_->sync_point_manager(),
base::MessageLoopProxy::current());
OnDevToolsStartEventsRecording)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DevToolsStopEventsRecording,
OnDevToolsStopEventsRecording)
- IPC_MESSAGE_HANDLER(
- GpuChannelMsg_CollectRenderingStatsForSurface,
- OnCollectRenderingStatsForSurface)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
DCHECK(handled) << msg.type();
devtools_gpu_agent_->StopEventsRecording();
}
-void GpuChannel::OnCollectRenderingStatsForSurface(
- int32 surface_id, GpuRenderingStats* stats) {
- for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
- !it.IsAtEnd(); it.Advance()) {
- int texture_upload_count =
- it.GetCurrentValue()->decoder()->GetTextureUploadCount();
- base::TimeDelta total_texture_upload_time =
- it.GetCurrentValue()->decoder()->GetTotalTextureUploadTime();
- base::TimeDelta total_processing_commands_time =
- it.GetCurrentValue()->decoder()->GetTotalProcessingCommandsTime();
-
- stats->global_texture_upload_count += texture_upload_count;
- stats->global_total_texture_upload_time += total_texture_upload_time;
- stats->global_total_processing_commands_time +=
- total_processing_commands_time;
- if (it.GetCurrentValue()->surface_id() == surface_id) {
- stats->texture_upload_count += texture_upload_count;
- stats->total_texture_upload_time += total_texture_upload_time;
- stats->total_processing_commands_time += total_processing_commands_time;
- }
- }
-
- GPUVideoMemoryUsageStats usage_stats;
- gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats(
- &usage_stats);
- stats->global_video_memory_bytes_allocated = usage_stats.bytes_allocated;
-}
-
void GpuChannel::MessageProcessed() {
messages_processed_++;
if (preempting_flag_.get()) {