summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 00:52:44 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 00:52:44 +0000
commitbca15907b277999c70820ce785624bd2b8284ae0 (patch)
tree9d6ffcab3a5e209bac0225704a8fa68c9101ffdc /content/common
parent673266c4267a4bee5c8e63934d65f9accd534f42 (diff)
downloadchromium_src-bca15907b277999c70820ce785624bd2b8284ae0.zip
chromium_src-bca15907b277999c70820ce785624bd2b8284ae0.tar.gz
chromium_src-bca15907b277999c70820ce785624bd2b8284ae0.tar.bz2
cc: Add CompositorFrame class with IPC param traits for it
Tests: content_unittests:CCMessagesTest.AllQuads content_unittests:CCMessagesTest.Resources BUG=152337 R=piman NOTRY=true Review URL: https://chromiumcodereview.appspot.com/11308306 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/cc_messages.cc64
-rw-r--r--content/common/cc_messages.h38
-rw-r--r--content/common/cc_messages_unittest.cc82
3 files changed, 181 insertions, 3 deletions
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc
index 166e77a..bcdf0f0 100644
--- a/content/common/cc_messages.cc
+++ b/content/common/cc_messages.cc
@@ -4,6 +4,7 @@
#include "content/common/cc_messages.h"
+#include "cc/compositor_frame.h"
#include "content/public/common/common_param_traits.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
@@ -574,4 +575,67 @@ void ParamTraits<cc::RenderPass>::Log(
l->append("])");
}
+void ParamTraits<cc::Mailbox>::Write(Message* m, const param_type& p) {
+ m->WriteBytes(p.name, sizeof(p.name));
+}
+
+bool ParamTraits<cc::Mailbox>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ const char* bytes = NULL;
+ if (!m->ReadBytes(iter, &bytes, sizeof(p->name)))
+ return false;
+ DCHECK(bytes);
+ memcpy(p->name, bytes, sizeof(p->name));
+ return true;
+}
+
+void ParamTraits<cc::Mailbox>::Log(const param_type& p, std::string* l) {
+ for (size_t i = 0; i < sizeof(p.name); ++i)
+ *l += base::StringPrintf("%02x", p.name[i]);
+}
+
+void ParamTraits<cc::CompositorFrame>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.size);
+ WriteParam(m, p.resource_list);
+ WriteParam(m, p.render_pass_list.size());
+ for (size_t i = 0; i < p.render_pass_list.size(); ++i)
+ WriteParam(m, *p.render_pass_list[i]);
+}
+
+bool ParamTraits<cc::CompositorFrame>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ const static size_t kMaxRenderPasses = 10000;
+
+ size_t num_render_passes;
+ if (!ReadParam(m, iter, &p->size) ||
+ !ReadParam(m, iter, &p->resource_list) ||
+ !ReadParam(m, iter, &num_render_passes) ||
+ num_render_passes > kMaxRenderPasses)
+ return false;
+ for (size_t i = 0; i < num_render_passes; ++i) {
+ scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
+ if (!ReadParam(m, iter, render_pass.get()))
+ return false;
+ p->render_pass_list.append(render_pass.Pass());
+ }
+ return true;
+}
+
+void ParamTraits<cc::CompositorFrame>::Log(const param_type& p,
+ std::string* l) {
+ l->append("CompositorFrame(");
+ LogParam(p.size, l);
+ l->append(", ");
+ LogParam(p.resource_list, l);
+ l->append(", [");
+ for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
+ if (i)
+ l->append(", ");
+ LogParam(*p.render_pass_list[i], l);
+ }
+ l->append("])");
+}
+
} // namespace IPC
diff --git a/content/common/cc_messages.h b/content/common/cc_messages.h
index 74f2479..058d81e 100644
--- a/content/common/cc_messages.h
+++ b/content/common/cc_messages.h
@@ -5,6 +5,7 @@
// IPC Messages sent between compositor instances.
#include "cc/checkerboard_draw_quad.h"
+#include "cc/compositor_frame_ack.h"
#include "cc/debug_border_draw_quad.h"
#include "cc/draw_quad.h"
#include "cc/io_surface_draw_quad.h"
@@ -15,6 +16,7 @@
#include "cc/stream_video_draw_quad.h"
#include "cc/texture_draw_quad.h"
#include "cc/tile_draw_quad.h"
+#include "cc/transferable_resource.h"
#include "cc/video_layer_impl.h"
#include "cc/yuv_video_draw_quad.h"
#include "content/common/content_export.h"
@@ -24,6 +26,10 @@
#ifndef CONTENT_COMMON_CC_MESSAGES_H_
#define CONTENT_COMMON_CC_MESSAGES_H_
+namespace cc {
+class CompositorFrame;
+}
+
namespace gfx {
class Transform;
}
@@ -75,6 +81,22 @@ struct CONTENT_EXPORT ParamTraits<cc::RenderPass> {
static void Log(const param_type& p, std::string* l);
};
+template<>
+struct CONTENT_EXPORT ParamTraits<cc::Mailbox> {
+ typedef cc::Mailbox param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template<>
+struct CONTENT_EXPORT ParamTraits<cc::CompositorFrame> {
+ typedef cc::CompositorFrame param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // CONTENT_COMMON_CC_MESSAGES_H_
@@ -184,3 +206,19 @@ IPC_STRUCT_TRAITS_BEGIN(cc::SharedQuadState)
IPC_STRUCT_TRAITS_MEMBER(is_clipped)
IPC_STRUCT_TRAITS_MEMBER(opacity)
IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(cc::TransferableResource)
+ IPC_STRUCT_TRAITS_MEMBER(id)
+ IPC_STRUCT_TRAITS_MEMBER(format)
+ IPC_STRUCT_TRAITS_MEMBER(size)
+ IPC_STRUCT_TRAITS_MEMBER(mailbox)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(cc::TransferableResourceList)
+ IPC_STRUCT_TRAITS_MEMBER(sync_point)
+ IPC_STRUCT_TRAITS_MEMBER(resources)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(cc::CompositorFrameAck)
+ IPC_STRUCT_TRAITS_MEMBER(resources)
+IPC_STRUCT_TRAITS_END()
diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc
index d58c518..4e20e2b 100644
--- a/content/common/cc_messages_unittest.cc
+++ b/content/common/cc_messages_unittest.cc
@@ -6,10 +6,12 @@
#include <string.h>
+#include "cc/compositor_frame.h"
#include "ipc/ipc_message.h"
#include "testing/gtest/include/gtest/gtest.h"
using cc::CheckerboardDrawQuad;
+using cc::CompositorFrame;
using cc::DebugBorderDrawQuad;
using cc::DrawQuad;
using cc::IOSurfaceDrawQuad;
@@ -20,6 +22,7 @@ using cc::SharedQuadState;
using cc::SolidColorDrawQuad;
using cc::TextureDrawQuad;
using cc::TileDrawQuad;
+using cc::TransferableResource;
using cc::StreamVideoDrawQuad;
using cc::VideoLayerImpl;
using cc::YUVVideoDrawQuad;
@@ -27,6 +30,9 @@ using gfx::Transform;
using WebKit::WebFilterOperation;
using WebKit::WebFilterOperations;
+namespace content {
+namespace {
+
class CCMessagesTest : public testing::Test {
protected:
void Compare(const RenderPass* a, const RenderPass* b) {
@@ -168,6 +174,14 @@ class CCMessagesTest : public testing::Test {
EXPECT_EQ(a->v_plane.size.ToString(), b->v_plane.size.ToString());
EXPECT_EQ(a->v_plane.format, b->v_plane.format);
}
+
+ void Compare(const TransferableResource& a, const TransferableResource& b) {
+ EXPECT_EQ(a.id, b.id);
+ EXPECT_EQ(a.format, b.format);
+ EXPECT_EQ(a.size.ToString(), b.size.ToString());
+ for (size_t i = 0; i < arraysize(a.mailbox.name); ++i)
+ EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]);
+ }
};
TEST_F(CCMessagesTest, AllQuads) {
@@ -403,13 +417,20 @@ TEST_F(CCMessagesTest, AllQuads) {
EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
}
- IPC::ParamTraits<RenderPass>::Write(&msg, *pass_in);
+ CompositorFrame frame_in;
+ frame_in.size = arbitrary_size1;
+ frame_in.render_pass_list.append(pass_in.Pass());
- scoped_ptr<RenderPass> pass_out = RenderPass::Create();
+ IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
+
+ CompositorFrame frame_out;
PickleIterator iter(msg);
- EXPECT_TRUE(IPC::ParamTraits<RenderPass>::Read(&msg, &iter, pass_out.get()));
+ EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
+
+ EXPECT_EQ(arbitrary_size1, frame_out.size);
// Make sure the out and cmp RenderPasses match.
+ scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take(0);
Compare(pass_cmp.get(), pass_out.get());
ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
ASSERT_EQ(7u, pass_out->quad_list.size());
@@ -429,3 +450,58 @@ TEST_F(CCMessagesTest, AllQuads) {
EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
}
}
+
+TEST_F(CCMessagesTest, Resources) {
+ IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
+ gfx::Size arbitrary_size(757, 1281);
+ unsigned int arbitrary_uint = 71234838;
+
+ GLbyte arbitrary_mailbox1[64] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4
+ };
+
+ GLbyte arbitrary_mailbox2[64] = {
+ 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
+ 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
+ 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
+ 0, 9, 8, 7
+ };
+
+ TransferableResource arbitrary_resource1;
+ arbitrary_resource1.id = 2178312;
+ arbitrary_resource1.format = 7;
+ arbitrary_resource1.size = gfx::Size(37189, 123123);
+ arbitrary_resource1.mailbox.setName(arbitrary_mailbox1);
+
+ TransferableResource arbitrary_resource2;
+ arbitrary_resource2.id = 789132;
+ arbitrary_resource2.format = 30;
+ arbitrary_resource2.size = gfx::Size(89123, 23789);
+ arbitrary_resource2.mailbox.setName(arbitrary_mailbox2);
+
+ CompositorFrame frame_in;
+ frame_in.size = arbitrary_size;
+
+ frame_in.resource_list.sync_point = arbitrary_uint;
+ frame_in.resource_list.resources.push_back(arbitrary_resource1);
+ frame_in.resource_list.resources.push_back(arbitrary_resource2);
+
+ IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
+
+ CompositorFrame frame_out;
+ PickleIterator iter(msg);
+ EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
+
+ EXPECT_EQ(arbitrary_size.ToString(), frame_out.size.ToString());
+ EXPECT_EQ(arbitrary_uint, frame_out.resource_list.sync_point);
+
+ EXPECT_EQ(2u, frame_out.resource_list.resources.size());
+ Compare(arbitrary_resource1, frame_out.resource_list.resources[0]);
+ Compare(arbitrary_resource2, frame_out.resource_list.resources[1]);
+}
+
+} // namespace
+} // namespace content