summaryrefslogtreecommitdiffstats
path: root/cc/quads
diff options
context:
space:
mode:
authorjackhou <jackhou@chromium.org>2014-12-13 15:41:00 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-13 23:41:32 +0000
commit2422961898e84e420c0e12031ebb5147748ab490 (patch)
treefe767314b65e808575a9e12fe32f1bd255d3b6b4 /cc/quads
parent9d04deed4364293a7f662d69cbbc23c4cab355f6 (diff)
downloadchromium_src-2422961898e84e420c0e12031ebb5147748ab490.zip
chromium_src-2422961898e84e420c0e12031ebb5147748ab490.tar.gz
chromium_src-2422961898e84e420c0e12031ebb5147748ab490.tar.bz2
[cc] Add nearest neighbor filtering for PictureLayer.
Blink side here (depends on this CL): https://codereview.chromium.org/782693003/ BUG=317991 Review URL: https://codereview.chromium.org/789433003 Cr-Commit-Position: refs/heads/master@{#308289}
Diffstat (limited to 'cc/quads')
-rw-r--r--cc/quads/content_draw_quad_base.cc9
-rw-r--r--cc/quads/content_draw_quad_base.h7
-rw-r--r--cc/quads/draw_quad_unittest.cc41
-rw-r--r--cc/quads/picture_draw_quad.cc8
-rw-r--r--cc/quads/picture_draw_quad.h2
-rw-r--r--cc/quads/tile_draw_quad.cc12
-rw-r--r--cc/quads/tile_draw_quad.h6
7 files changed, 58 insertions, 27 deletions
diff --git a/cc/quads/content_draw_quad_base.cc b/cc/quads/content_draw_quad_base.cc
index fd6e91b..7304498 100644
--- a/cc/quads/content_draw_quad_base.cc
+++ b/cc/quads/content_draw_quad_base.cc
@@ -25,13 +25,15 @@ void ContentDrawQuadBase::SetNew(const SharedQuadState* shared_quad_state,
const gfx::Rect& visible_rect,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents) {
+ bool swizzle_contents,
+ bool nearest_neighbor) {
bool needs_blending = false;
DrawQuad::SetAll(shared_quad_state, material, rect, opaque_rect,
visible_rect, needs_blending);
this->tex_coord_rect = tex_coord_rect;
this->texture_size = texture_size;
this->swizzle_contents = swizzle_contents;
+ this->nearest_neighbor = nearest_neighbor;
}
void ContentDrawQuadBase::SetAll(const SharedQuadState* shared_quad_state,
@@ -42,12 +44,14 @@ void ContentDrawQuadBase::SetAll(const SharedQuadState* shared_quad_state,
bool needs_blending,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents) {
+ bool swizzle_contents,
+ bool nearest_neighbor) {
DrawQuad::SetAll(shared_quad_state, material, rect, opaque_rect,
visible_rect, needs_blending);
this->tex_coord_rect = tex_coord_rect;
this->texture_size = texture_size;
this->swizzle_contents = swizzle_contents;
+ this->nearest_neighbor = nearest_neighbor;
}
void ContentDrawQuadBase::ExtendValue(base::debug::TracedValue* value) const {
@@ -60,6 +64,7 @@ void ContentDrawQuadBase::ExtendValue(base::debug::TracedValue* value) const {
value->EndDictionary();
value->SetBoolean("swizzle_contents", swizzle_contents);
+ value->SetBoolean("nearest_neighbor", nearest_neighbor);
}
} // namespace cc
diff --git a/cc/quads/content_draw_quad_base.h b/cc/quads/content_draw_quad_base.h
index b0e53dc..58aa727 100644
--- a/cc/quads/content_draw_quad_base.h
+++ b/cc/quads/content_draw_quad_base.h
@@ -23,7 +23,8 @@ class CC_EXPORT ContentDrawQuadBase : public DrawQuad {
const gfx::Rect& visible_rect,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents);
+ bool swizzle_contents,
+ bool nearest_neighbor);
void SetAll(const SharedQuadState* shared_quad_state,
DrawQuad::Material material,
@@ -33,11 +34,13 @@ class CC_EXPORT ContentDrawQuadBase : public DrawQuad {
bool needs_blending,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents);
+ bool swizzle_contents,
+ bool nearest_neighbor);
gfx::RectF tex_coord_rect;
gfx::Size texture_size;
bool swizzle_contents;
+ bool nearest_neighbor;
protected:
ContentDrawQuadBase();
diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc
index e65b326..97fea32 100644
--- a/cc/quads/draw_quad_unittest.cc
+++ b/cc/quads/draw_quad_unittest.cc
@@ -600,15 +600,17 @@ TEST(DrawQuadTest, CopyTileDrawQuad) {
gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
gfx::Size texture_size(85, 32);
bool swizzle_contents = true;
+ bool nearest_neighbor = true;
CREATE_SHARED_STATE();
- CREATE_QUAD_6_NEW(TileDrawQuad,
+ CREATE_QUAD_7_NEW(TileDrawQuad,
opaque_rect,
visible_rect,
resource_id,
tex_coord_rect,
texture_size,
- swizzle_contents);
+ swizzle_contents,
+ nearest_neighbor);
EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
EXPECT_EQ(visible_rect, copy_quad->visible_rect);
@@ -616,17 +618,20 @@ TEST(DrawQuadTest, CopyTileDrawQuad) {
EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
EXPECT_EQ(texture_size, copy_quad->texture_size);
EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
+ EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
- CREATE_QUAD_4_ALL(TileDrawQuad,
+ CREATE_QUAD_5_ALL(TileDrawQuad,
resource_id,
tex_coord_rect,
texture_size,
- swizzle_contents);
+ swizzle_contents,
+ nearest_neighbor);
EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
EXPECT_EQ(resource_id, copy_quad->resource_id);
EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
EXPECT_EQ(texture_size, copy_quad->texture_size);
EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
+ EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
}
TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
@@ -680,31 +685,34 @@ TEST(DrawQuadTest, CopyPictureDrawQuad) {
gfx::Rect visible_rect(40, 50, 30, 20);
gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
gfx::Size texture_size(85, 32);
+ bool nearest_neighbor = true;
ResourceFormat texture_format = RGBA_8888;
gfx::Rect content_rect(30, 40, 20, 30);
float contents_scale = 3.141592f;
scoped_refptr<RasterSource> raster_source = PicturePileImpl::Create();
CREATE_SHARED_STATE();
- CREATE_QUAD_8_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
- texture_size, texture_format, content_rect, contents_scale,
- raster_source);
+ CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
+ texture_size, nearest_neighbor, texture_format,
+ content_rect, contents_scale, raster_source);
EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
EXPECT_EQ(visible_rect, copy_quad->visible_rect);
EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
EXPECT_EQ(texture_size, copy_quad->texture_size);
+ EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
EXPECT_EQ(texture_format, copy_quad->texture_format);
EXPECT_EQ(content_rect, copy_quad->content_rect);
EXPECT_EQ(contents_scale, copy_quad->contents_scale);
EXPECT_EQ(raster_source, copy_quad->raster_source);
- CREATE_QUAD_6_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
- texture_format, content_rect, contents_scale,
- raster_source);
+ CREATE_QUAD_7_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
+ nearest_neighbor, texture_format, content_rect,
+ contents_scale, raster_source);
EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
EXPECT_EQ(texture_size, copy_quad->texture_size);
+ EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
EXPECT_EQ(texture_format, copy_quad->texture_format);
EXPECT_EQ(content_rect, copy_quad->content_rect);
EXPECT_EQ(contents_scale, copy_quad->contents_scale);
@@ -871,15 +879,17 @@ TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
gfx::Size texture_size(85, 32);
bool swizzle_contents = true;
+ bool nearest_neighbor = true;
CREATE_SHARED_STATE();
- CREATE_QUAD_6_NEW(TileDrawQuad,
+ CREATE_QUAD_7_NEW(TileDrawQuad,
opaque_rect,
visible_rect,
resource_id,
tex_coord_rect,
texture_size,
- swizzle_contents);
+ swizzle_contents,
+ nearest_neighbor);
EXPECT_EQ(resource_id, quad_new->resource_id);
EXPECT_EQ(1, IterateAndCount(quad_new));
EXPECT_EQ(resource_id + 1, quad_new->resource_id);
@@ -924,15 +934,16 @@ TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) {
gfx::Rect visible_rect(40, 50, 30, 20);
gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
gfx::Size texture_size(85, 32);
+ bool nearest_neighbor = true;
ResourceFormat texture_format = RGBA_8888;
gfx::Rect content_rect(30, 40, 20, 30);
float contents_scale = 3.141592f;
scoped_refptr<PicturePileImpl> raster_source = PicturePileImpl::Create();
CREATE_SHARED_STATE();
- CREATE_QUAD_8_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
- texture_size, texture_format, content_rect, contents_scale,
- raster_source);
+ CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
+ texture_size, nearest_neighbor, texture_format,
+ content_rect, contents_scale, raster_source);
EXPECT_EQ(0, IterateAndCount(quad_new));
}
diff --git a/cc/quads/picture_draw_quad.cc b/cc/quads/picture_draw_quad.cc
index bf329c2..2171542 100644
--- a/cc/quads/picture_draw_quad.cc
+++ b/cc/quads/picture_draw_quad.cc
@@ -23,6 +23,7 @@ void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
const gfx::Rect& visible_rect,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
+ bool nearest_neighbor,
ResourceFormat texture_format,
const gfx::Rect& content_rect,
float contents_scale,
@@ -35,7 +36,8 @@ void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
visible_rect,
tex_coord_rect,
texture_size,
- !PlatformColor::SameComponentOrder(texture_format));
+ !PlatformColor::SameComponentOrder(texture_format),
+ nearest_neighbor);
this->content_rect = content_rect;
this->contents_scale = contents_scale;
this->raster_source = raster_source;
@@ -49,6 +51,7 @@ void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
bool needs_blending,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
+ bool nearest_neighbor,
ResourceFormat texture_format,
const gfx::Rect& content_rect,
float contents_scale,
@@ -62,7 +65,8 @@ void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
tex_coord_rect,
texture_size,
!PlatformColor::SameComponentOrder(
- texture_format));
+ texture_format),
+ nearest_neighbor);
this->content_rect = content_rect;
this->contents_scale = contents_scale;
this->raster_source = raster_source;
diff --git a/cc/quads/picture_draw_quad.h b/cc/quads/picture_draw_quad.h
index 62c9f18..624b69c 100644
--- a/cc/quads/picture_draw_quad.h
+++ b/cc/quads/picture_draw_quad.h
@@ -28,6 +28,7 @@ class CC_EXPORT PictureDrawQuad : public ContentDrawQuadBase {
const gfx::Rect& visible_rect,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
+ bool nearest_neighbor,
ResourceFormat texture_format,
const gfx::Rect& content_rect,
float contents_scale,
@@ -40,6 +41,7 @@ class CC_EXPORT PictureDrawQuad : public ContentDrawQuadBase {
bool needs_blending,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
+ bool nearest_neighbor,
ResourceFormat texture_format,
const gfx::Rect& content_rect,
float contents_scale,
diff --git a/cc/quads/tile_draw_quad.cc b/cc/quads/tile_draw_quad.cc
index ea3a14a..88a4b3af 100644
--- a/cc/quads/tile_draw_quad.cc
+++ b/cc/quads/tile_draw_quad.cc
@@ -25,7 +25,8 @@ void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
unsigned resource_id,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents) {
+ bool swizzle_contents,
+ bool nearest_neighbor) {
ContentDrawQuadBase::SetNew(shared_quad_state,
DrawQuad::TILED_CONTENT,
rect,
@@ -33,7 +34,8 @@ void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
visible_rect,
tex_coord_rect,
texture_size,
- swizzle_contents);
+ swizzle_contents,
+ nearest_neighbor);
this->resource_id = resource_id;
}
@@ -45,10 +47,12 @@ void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
unsigned resource_id,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents) {
+ bool swizzle_contents,
+ bool nearest_neighbor) {
ContentDrawQuadBase::SetAll(shared_quad_state, DrawQuad::TILED_CONTENT, rect,
opaque_rect, visible_rect, needs_blending,
- tex_coord_rect, texture_size, swizzle_contents);
+ tex_coord_rect, texture_size, swizzle_contents,
+ nearest_neighbor);
this->resource_id = resource_id;
}
diff --git a/cc/quads/tile_draw_quad.h b/cc/quads/tile_draw_quad.h
index d776057..e668ddb 100644
--- a/cc/quads/tile_draw_quad.h
+++ b/cc/quads/tile_draw_quad.h
@@ -21,7 +21,8 @@ class CC_EXPORT TileDrawQuad : public ContentDrawQuadBase {
unsigned resource_id,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents);
+ bool swizzle_contents,
+ bool nearest_neighbor);
void SetAll(const SharedQuadState* shared_quad_state,
const gfx::Rect& rect,
@@ -31,7 +32,8 @@ class CC_EXPORT TileDrawQuad : public ContentDrawQuadBase {
unsigned resource_id,
const gfx::RectF& tex_coord_rect,
const gfx::Size& texture_size,
- bool swizzle_contents);
+ bool swizzle_contents,
+ bool nearest_neighbor);
unsigned resource_id;