summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2015-06-02 15:14:46 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-02 22:15:17 +0000
commit0eca2e87110112c678c5f4c89b7f99e2de6026bb (patch)
tree6a3e39b085e5d8851c42ccf0b8a0f3e0a92775f6 /content/common
parent6c8207fe7d79a2150ce7c4007678d10c23475630 (diff)
downloadchromium_src-0eca2e87110112c678c5f4c89b7f99e2de6026bb.zip
chromium_src-0eca2e87110112c678c5f4c89b7f99e2de6026bb.tar.gz
chromium_src-0eca2e87110112c678c5f4c89b7f99e2de6026bb.tar.bz2
cc: Remove DrawQuad::IterateResoruces
This patch removes IterateResources function in favor of iterating resources directly on the quad. In order to accomplish this, each derived quad uses new resources object on the base class to store all of the resources it needs. This allows the calling code that used to call IterateResources with a callback to instead directly iterate all of the ids and manipulate them in any way that is required. This improves the performance of the IterateResources test by ~30%. BUG=492765 R=danakj, piman@chromium.org CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1152473006 Cr-Commit-Position: refs/heads/master@{#332476}
Diffstat (limited to 'content/common')
-rw-r--r--content/common/cc_messages.cc41
-rw-r--r--content/common/cc_messages.h18
-rw-r--r--content/common/cc_messages_unittest.cc18
3 files changed, 59 insertions, 18 deletions
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc
index e7c2ad2..bf8413c 100644
--- a/content/common/cc_messages.cc
+++ b/content/common/cc_messages.cc
@@ -6,6 +6,7 @@
#include "cc/output/compositor_frame.h"
#include "cc/output/filter_operations.h"
+#include "cc/quads/draw_quad.h"
#include "cc/quads/largest_draw_quad.h"
#include "cc/quads/render_pass_id.h"
#include "content/public/common/common_param_traits.h"
@@ -808,4 +809,44 @@ void ParamTraits<cc::SoftwareFrameData>::Log(const param_type& p,
l->append(")");
}
+void ParamTraits<cc::DrawQuad::Resources>::Write(Message* m,
+ const param_type& p) {
+ DCHECK_LE(p.count, cc::DrawQuad::Resources::kMaxResourceIdCount);
+ WriteParam(m, p.count);
+ for (size_t i = 0; i < p.count; ++i)
+ WriteParam(m, p.ids[i]);
+}
+
+bool ParamTraits<cc::DrawQuad::Resources>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ if (!ReadParam(m, iter, &p->count))
+ return false;
+ if (p->count > cc::DrawQuad::Resources::kMaxResourceIdCount)
+ return false;
+ for (size_t i = 0; i < p->count; ++i) {
+ if (!ReadParam(m, iter, &p->ids[i]))
+ return false;
+ }
+ return true;
+}
+
+void ParamTraits<cc::DrawQuad::Resources>::Log(const param_type& p,
+ std::string* l) {
+ l->append("DrawQuad::Resources(");
+ LogParam(p.count, l);
+ l->append(", [");
+ if (p.count > cc::DrawQuad::Resources::kMaxResourceIdCount) {
+ l->append("])");
+ return;
+ }
+
+ for (size_t i = 0; i < p.count; ++i) {
+ LogParam(p.ids[i], l);
+ if (i < (p.count - 1))
+ l->append(", ");
+ }
+ l->append("])");
+}
+
} // namespace IPC
diff --git a/content/common/cc_messages.h b/content/common/cc_messages.h
index 0206044..70392f0 100644
--- a/content/common/cc_messages.h
+++ b/content/common/cc_messages.h
@@ -118,6 +118,14 @@ struct CONTENT_EXPORT ParamTraits<cc::SoftwareFrameData> {
static void Log(const param_type& p, std::string* l);
};
+template <>
+struct CONTENT_EXPORT ParamTraits<cc::DrawQuad::Resources> {
+ typedef cc::DrawQuad::Resources 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_
@@ -159,6 +167,7 @@ IPC_STRUCT_TRAITS_BEGIN(cc::DrawQuad)
IPC_STRUCT_TRAITS_MEMBER(opaque_rect)
IPC_STRUCT_TRAITS_MEMBER(visible_rect)
IPC_STRUCT_TRAITS_MEMBER(needs_blending)
+ IPC_STRUCT_TRAITS_MEMBER(resources)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::CheckerboardDrawQuad)
@@ -176,14 +185,12 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::IOSurfaceDrawQuad)
IPC_STRUCT_TRAITS_PARENT(cc::DrawQuad)
IPC_STRUCT_TRAITS_MEMBER(io_surface_size)
- IPC_STRUCT_TRAITS_MEMBER(io_surface_resource_id)
IPC_STRUCT_TRAITS_MEMBER(orientation)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::RenderPassDrawQuad)
IPC_STRUCT_TRAITS_PARENT(cc::DrawQuad)
IPC_STRUCT_TRAITS_MEMBER(render_pass_id)
- IPC_STRUCT_TRAITS_MEMBER(mask_resource_id)
IPC_STRUCT_TRAITS_MEMBER(mask_uv_scale)
IPC_STRUCT_TRAITS_MEMBER(mask_texture_size)
IPC_STRUCT_TRAITS_MEMBER(filters)
@@ -199,7 +206,6 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::StreamVideoDrawQuad)
IPC_STRUCT_TRAITS_PARENT(cc::DrawQuad)
- IPC_STRUCT_TRAITS_MEMBER(resource_id)
IPC_STRUCT_TRAITS_MEMBER(matrix)
IPC_STRUCT_TRAITS_END()
@@ -210,7 +216,6 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::TextureDrawQuad)
IPC_STRUCT_TRAITS_PARENT(cc::DrawQuad)
- IPC_STRUCT_TRAITS_MEMBER(resource_id)
IPC_STRUCT_TRAITS_MEMBER(premultiplied_alpha)
IPC_STRUCT_TRAITS_MEMBER(uv_top_left)
IPC_STRUCT_TRAITS_MEMBER(uv_bottom_right)
@@ -225,7 +230,6 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(cc::TileDrawQuad)
IPC_STRUCT_TRAITS_PARENT(cc::DrawQuad)
- IPC_STRUCT_TRAITS_MEMBER(resource_id)
IPC_STRUCT_TRAITS_MEMBER(tex_coord_rect)
IPC_STRUCT_TRAITS_MEMBER(texture_size)
IPC_STRUCT_TRAITS_MEMBER(swizzle_contents)
@@ -238,10 +242,6 @@ IPC_STRUCT_TRAITS_BEGIN(cc::YUVVideoDrawQuad)
IPC_STRUCT_TRAITS_MEMBER(uv_tex_coord_rect)
IPC_STRUCT_TRAITS_MEMBER(ya_tex_size)
IPC_STRUCT_TRAITS_MEMBER(uv_tex_size)
- IPC_STRUCT_TRAITS_MEMBER(y_plane_resource_id)
- IPC_STRUCT_TRAITS_MEMBER(u_plane_resource_id)
- IPC_STRUCT_TRAITS_MEMBER(v_plane_resource_id)
- IPC_STRUCT_TRAITS_MEMBER(a_plane_resource_id)
IPC_STRUCT_TRAITS_MEMBER(color_space)
IPC_STRUCT_TRAITS_END()
diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc
index 0398266..4ebaebb 100644
--- a/content/common/cc_messages_unittest.cc
+++ b/content/common/cc_messages_unittest.cc
@@ -139,13 +139,13 @@ class CCMessagesTest : public testing::Test {
void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
- EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id);
+ EXPECT_EQ(a->io_surface_resource_id(), b->io_surface_resource_id());
EXPECT_EQ(a->orientation, b->orientation);
}
void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
EXPECT_EQ(a->render_pass_id, b->render_pass_id);
- EXPECT_EQ(a->mask_resource_id, b->mask_resource_id);
+ EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id());
EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString());
EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString());
EXPECT_EQ(a->filters.size(), b->filters.size());
@@ -168,7 +168,7 @@ class CCMessagesTest : public testing::Test {
}
void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
- EXPECT_EQ(a->resource_id, b->resource_id);
+ EXPECT_EQ(a->resource_id(), b->resource_id());
EXPECT_EQ(a->matrix, b->matrix);
}
@@ -177,7 +177,7 @@ class CCMessagesTest : public testing::Test {
}
void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
- EXPECT_EQ(a->resource_id, b->resource_id);
+ EXPECT_EQ(a->resource_id(), b->resource_id());
EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
EXPECT_EQ(a->uv_top_left, b->uv_top_left);
EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
@@ -191,7 +191,7 @@ class CCMessagesTest : public testing::Test {
}
void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
- EXPECT_EQ(a->resource_id, b->resource_id);
+ EXPECT_EQ(a->resource_id(), b->resource_id());
EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
EXPECT_EQ(a->texture_size, b->texture_size);
EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
@@ -203,10 +203,10 @@ class CCMessagesTest : public testing::Test {
EXPECT_EQ(a->uv_tex_coord_rect, b->uv_tex_coord_rect);
EXPECT_EQ(a->ya_tex_size, b->ya_tex_size);
EXPECT_EQ(a->uv_tex_size, b->uv_tex_size);
- EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id);
- EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id);
- EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id);
- EXPECT_EQ(a->a_plane_resource_id, b->a_plane_resource_id);
+ EXPECT_EQ(a->y_plane_resource_id(), b->y_plane_resource_id());
+ EXPECT_EQ(a->u_plane_resource_id(), b->u_plane_resource_id());
+ EXPECT_EQ(a->v_plane_resource_id(), b->v_plane_resource_id());
+ EXPECT_EQ(a->a_plane_resource_id(), b->a_plane_resource_id());
EXPECT_EQ(a->color_space, b->color_space);
}