summaryrefslogtreecommitdiffstats
path: root/cc/quads
diff options
context:
space:
mode:
authorachaulk <achaulk@chromium.org>2015-06-10 10:01:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-10 17:02:07 +0000
commitf89f594219da597c20b749fee195977052c6f709 (patch)
treef66bfd03b24b36698dd800323e86a160bd20e051 /cc/quads
parent20a7d9f7cf570609d5314fbc6ab3b1514b9e3308 (diff)
downloadchromium_src-f89f594219da597c20b749fee195977052c6f709.zip
chromium_src-f89f594219da597c20b749fee195977052c6f709.tar.gz
chromium_src-f89f594219da597c20b749fee195977052c6f709.tar.bz2
cc: Rework overlays to not use the ResourceProvider and pass texture size
Instead of querying the ResourceProvider, the size & overlay flag are stored in the quads directly. This eliminates the lookups that were otherwise required CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel TBR=jam (approved interface change) Review URL: https://codereview.chromium.org/1142343008 Cr-Commit-Position: refs/heads/master@{#333748}
Diffstat (limited to 'cc/quads')
-rw-r--r--cc/quads/draw_quad_unittest.cc47
-rw-r--r--cc/quads/stream_video_draw_quad.cc13
-rw-r--r--cc/quads/stream_video_draw_quad.h18
-rw-r--r--cc/quads/texture_draw_quad.cc9
-rw-r--r--cc/quads/texture_draw_quad.h22
5 files changed, 95 insertions, 14 deletions
diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc
index 055b7d9..5bce42e 100644
--- a/cc/quads/draw_quad_unittest.cc
+++ b/cc/quads/draw_quad_unittest.cc
@@ -330,6 +330,15 @@ void CompareDrawQuad(DrawQuad* quad,
} \
SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
+#define CREATE_QUAD_10_ALL(Type, a, b, c, d, e, f, g, h, i, j) \
+ Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
+ { \
+ QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
+ quad_visible_rect, needs_blending, a, b, c, d, \
+ e, f, g, h, i, j); \
+ } \
+ SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
+
#define CREATE_QUAD_11_NEW(Type, a, b, c, d, e, f, g, h, i, j, k) \
Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
{ \
@@ -508,20 +517,27 @@ TEST(DrawQuadTest, CopyStreamVideoDrawQuad) {
gfx::Rect opaque_rect(33, 47, 10, 12);
gfx::Rect visible_rect(40, 50, 30, 20);
ResourceId resource_id = 64;
+ gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
+ bool allow_overlay = true;
gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
CREATE_SHARED_STATE();
- CREATE_QUAD_4_NEW(
- StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix);
+ CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
+ resource_size_in_pixels, allow_overlay, matrix);
EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
EXPECT_EQ(visible_rect, copy_quad->visible_rect);
EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
EXPECT_EQ(resource_id, copy_quad->resource_id());
+ EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
+ EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
EXPECT_EQ(matrix, copy_quad->matrix);
- CREATE_QUAD_2_ALL(StreamVideoDrawQuad, resource_id, matrix);
+ CREATE_QUAD_4_ALL(StreamVideoDrawQuad, resource_id, resource_size_in_pixels,
+ allow_overlay, matrix);
EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
EXPECT_EQ(resource_id, copy_quad->resource_id());
+ EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
+ EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
EXPECT_EQ(matrix, copy_quad->matrix);
}
@@ -545,6 +561,8 @@ TEST(DrawQuadTest, CopyTextureDrawQuad) {
gfx::Rect opaque_rect(33, 47, 10, 12);
gfx::Rect visible_rect(40, 50, 30, 20);
unsigned resource_id = 82;
+ gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
+ bool allow_overlay = true;
bool premultiplied_alpha = true;
gfx::PointF uv_top_left(0.5f, 224.f);
gfx::PointF uv_bottom_right(51.5f, 260.f);
@@ -575,17 +593,14 @@ TEST(DrawQuadTest, CopyTextureDrawQuad) {
EXPECT_EQ(y_flipped, copy_quad->y_flipped);
EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
- CREATE_QUAD_8_ALL(TextureDrawQuad,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- SK_ColorTRANSPARENT,
- vertex_opacity,
- y_flipped,
- nearest_neighbor);
+ CREATE_QUAD_10_ALL(TextureDrawQuad, resource_id, resource_size_in_pixels,
+ allow_overlay, premultiplied_alpha, uv_top_left,
+ uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
+ y_flipped, nearest_neighbor);
EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
EXPECT_EQ(resource_id, copy_quad->resource_id());
+ EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
+ EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
@@ -831,12 +846,16 @@ TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) {
gfx::Rect opaque_rect(33, 47, 10, 12);
gfx::Rect visible_rect(40, 50, 30, 20);
ResourceId resource_id = 64;
+ gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
+ bool allow_overlay = true;
gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
CREATE_SHARED_STATE();
- CREATE_QUAD_4_NEW(
- StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix);
+ CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
+ resource_size_in_pixels, allow_overlay, matrix);
EXPECT_EQ(resource_id, quad_new->resource_id());
+ EXPECT_EQ(allow_overlay, quad_new->allow_overlay());
+ EXPECT_EQ(resource_size_in_pixels, quad_new->resource_size_in_pixels());
EXPECT_EQ(1, IterateAndCount(quad_new));
EXPECT_EQ(resource_id + 1, quad_new->resource_id());
}
diff --git a/cc/quads/stream_video_draw_quad.cc b/cc/quads/stream_video_draw_quad.cc
index 3ab9928..c25e5d5 100644
--- a/cc/quads/stream_video_draw_quad.cc
+++ b/cc/quads/stream_video_draw_quad.cc
@@ -19,11 +19,15 @@ void StreamVideoDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
const gfx::Rect& opaque_rect,
const gfx::Rect& visible_rect,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
const gfx::Transform& matrix) {
bool needs_blending = false;
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
opaque_rect, visible_rect, needs_blending);
resources.ids[kResourceIdIndex] = resource_id;
+ overlay_resources.size_in_pixels[kResourceIdIndex] = resource_size_in_pixels;
+ overlay_resources.allow_overlay[kResourceIdIndex] = allow_overlay;
resources.count = 1;
this->matrix = matrix;
}
@@ -34,10 +38,14 @@ void StreamVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
const gfx::Rect& visible_rect,
bool needs_blending,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
const gfx::Transform& matrix) {
DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
opaque_rect, visible_rect, needs_blending);
resources.ids[kResourceIdIndex] = resource_id;
+ overlay_resources.size_in_pixels[kResourceIdIndex] = resource_size_in_pixels;
+ overlay_resources.allow_overlay[kResourceIdIndex] = allow_overlay;
resources.count = 1;
this->matrix = matrix;
}
@@ -54,4 +62,9 @@ void StreamVideoDrawQuad::ExtendValue(
MathUtil::AddToTracedValue("matrix", matrix, value);
}
+StreamVideoDrawQuad::OverlayResources::OverlayResources() {
+ for (size_t i = 0; i < Resources::kMaxResourceIdCount; ++i)
+ allow_overlay[i] = false;
+}
+
} // namespace cc
diff --git a/cc/quads/stream_video_draw_quad.h b/cc/quads/stream_video_draw_quad.h
index faffd20..519c353 100644
--- a/cc/quads/stream_video_draw_quad.h
+++ b/cc/quads/stream_video_draw_quad.h
@@ -21,6 +21,8 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
const gfx::Rect& opaque_rect,
const gfx::Rect& visible_rect,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
const gfx::Transform& matrix);
void SetAll(const SharedQuadState* shared_quad_state,
@@ -29,13 +31,29 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
const gfx::Rect& visible_rect,
bool needs_blending,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
const gfx::Transform& matrix);
gfx::Transform matrix;
+ struct OverlayResources {
+ OverlayResources();
+
+ gfx::Size size_in_pixels[Resources::kMaxResourceIdCount];
+ bool allow_overlay[Resources::kMaxResourceIdCount];
+ };
+ OverlayResources overlay_resources;
+
static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*);
ResourceId resource_id() const { return resources.ids[kResourceIdIndex]; }
+ const gfx::Size& resource_size_in_pixels() const {
+ return overlay_resources.size_in_pixels[kResourceIdIndex];
+ }
+ bool allow_overlay() const {
+ return overlay_resources.allow_overlay[kResourceIdIndex];
+ }
private:
static const size_t kResourceIdIndex = 0;
diff --git a/cc/quads/texture_draw_quad.cc b/cc/quads/texture_draw_quad.cc
index 7106af5e..c469c87 100644
--- a/cc/quads/texture_draw_quad.cc
+++ b/cc/quads/texture_draw_quad.cc
@@ -59,6 +59,8 @@ void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
const gfx::Rect& visible_rect,
bool needs_blending,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
bool premultiplied_alpha,
const gfx::PointF& uv_top_left,
const gfx::PointF& uv_bottom_right,
@@ -69,6 +71,8 @@ void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect,
opaque_rect, visible_rect, needs_blending);
resources.ids[kResourceIdIndex] = resource_id;
+ overlay_resources.size_in_pixels[kResourceIdIndex] = resource_size_in_pixels;
+ overlay_resources.allow_overlay[kResourceIdIndex] = allow_overlay;
resources.count = 1;
this->premultiplied_alpha = premultiplied_alpha;
this->uv_top_left = uv_top_left;
@@ -105,4 +109,9 @@ void TextureDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const {
value->SetBoolean("nearest_neighbor", nearest_neighbor);
}
+TextureDrawQuad::OverlayResources::OverlayResources() {
+ for (size_t i = 0; i < Resources::kMaxResourceIdCount; ++i)
+ allow_overlay[i] = false;
+}
+
} // namespace cc
diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h
index 3f85920..40c7623 100644
--- a/cc/quads/texture_draw_quad.h
+++ b/cc/quads/texture_draw_quad.h
@@ -35,6 +35,8 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad {
const gfx::Rect& visible_rect,
bool needs_blending,
unsigned resource_id,
+ gfx::Size resource_size_in_pixels,
+ bool allow_overlay,
bool premultiplied_alpha,
const gfx::PointF& uv_top_left,
const gfx::PointF& uv_bottom_right,
@@ -51,7 +53,27 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad {
bool y_flipped;
bool nearest_neighbor;
+ struct OverlayResources {
+ OverlayResources();
+
+ gfx::Size size_in_pixels[Resources::kMaxResourceIdCount];
+ bool allow_overlay[Resources::kMaxResourceIdCount];
+ };
+ OverlayResources overlay_resources;
+
ResourceId resource_id() const { return resources.ids[kResourceIdIndex]; }
+ const gfx::Size& resource_size_in_pixels() const {
+ return overlay_resources.size_in_pixels[kResourceIdIndex];
+ }
+ void set_resource_size_in_pixels(const gfx::Size& size_in_pixels) {
+ overlay_resources.size_in_pixels[kResourceIdIndex] = size_in_pixels;
+ }
+ bool allow_overlay() const {
+ return overlay_resources.allow_overlay[kResourceIdIndex];
+ }
+ void set_allow_overlay(bool allow_overlay) {
+ overlay_resources.allow_overlay[kResourceIdIndex] = allow_overlay;
+ }
static const TextureDrawQuad* MaterialCast(const DrawQuad*);