Index: cc/output/renderer_pixeltest.cc |
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc |
index c62ae058d00de3a93b6a68d2ecc1a2a8cbc5a1c1..8a8fe83431b229803d64b24e631613509f507842 100644 |
--- a/cc/output/renderer_pixeltest.cc |
+++ b/cc/output/renderer_pixeltest.cc |
@@ -285,6 +285,36 @@ void CreateTestYUVVideoDrawQuad_FromVideoFrame( |
bits_per_channel); |
} |
+void CreateTestY16VideoDrawQuad_FromVideoFrame( |
+ const SharedQuadState* shared_state, |
+ scoped_refptr<media::VideoFrame> video_frame, |
+ const gfx::RectF& tex_coord_rect, |
+ RenderPass* render_pass, |
+ VideoResourceUpdater* video_resource_updater, |
+ const gfx::Rect& rect, |
+ const gfx::Rect& visible_rect, |
+ ResourceProvider* resource_provider) { |
+ const gfx::Rect opaque_rect(0, 0, 0, 0); |
+ |
+ VideoFrameExternalResources resources = |
+ video_resource_updater->CreateExternalResourcesFromVideoFrame( |
+ video_frame); |
+ |
+ EXPECT_EQ(VideoFrameExternalResources::Y_RESOURCE, resources.type); |
+ EXPECT_EQ(1u, resources.mailboxes.size()); |
+ EXPECT_EQ(1u, resources.release_callbacks.size()); |
+ |
+ ResourceId y_resource = resource_provider->CreateResourceFromTextureMailbox( |
+ resources.mailboxes[0], |
+ SingleReleaseCallbackImpl::Create(resources.release_callbacks[0])); |
+ |
+ YVideoDrawQuad* y_video_quad = |
+ render_pass->CreateAndAppendDrawQuad<YVideoDrawQuad>(); |
+ y_video_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, |
+ y_resource, tex_coord_rect.origin(), |
+ tex_coord_rect.bottom_right()); |
+} |
+ |
// Upshift video frame to 10 bit. |
scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame( |
media::VideoFrame* video_frame) { |
@@ -539,6 +569,61 @@ void CreateTestYUVVideoDrawQuad_NV12(const SharedQuadState* shared_state, |
color_space, video_color_space, 0.0f, 1.0f, 8); |
} |
+void CreateTestY16VideoDrawQuad_TwoColor( |
+ const SharedQuadState* shared_state, |
+ const gfx::RectF& tex_coord_rect, |
+ uint8_t g_foreground, |
+ uint8_t g_background, |
+ RenderPass* render_pass, |
+ VideoResourceUpdater* video_resource_updater, |
+ const gfx::Rect& rect, |
+ const gfx::Rect& visible_rect, |
+ const gfx::Rect& foreground_rect, |
+ ResourceProvider* resource_provider) { |
+ std::unique_ptr<unsigned char, base::AlignedFreeDeleter> memory( |
+ static_cast<unsigned char*>( |
+ base::AlignedAlloc(rect.size().GetArea() * 2, |
+ media::VideoFrame::kFrameAddressAlignment))); |
+ scoped_refptr<media::VideoFrame> video_frame = |
+ media::VideoFrame::WrapExternalData( |
+ media::PIXEL_FORMAT_Y16, rect.size(), foreground_rect, |
+ foreground_rect.size(), memory.get(), rect.size().GetArea() * 2, |
+ base::TimeDelta()); |
+ DCHECK_EQ(video_frame->rows(0) % 2, 0); |
+ DCHECK_EQ(video_frame->stride(0) % 2, 0); |
+ |
+ for (int j = 0; j < video_frame->rows(0); ++j) { |
+ uint8_t* row = video_frame->data(0) + j * video_frame->stride(0); |
+ if (j < foreground_rect.y() || j >= foreground_rect.bottom()) { |
+ for (int i = 0; i < video_frame->stride(0) / 2; ++i) { |
+ *row++ = i & 0xFF; // Fill R with anything. It is not rendered. |
+ *row++ = g_background; |
+ } |
+ } else { |
+ for (int i = 0; |
+ i < std::min(video_frame->stride(0) / 2, foreground_rect.x()); ++i) { |
+ *row++ = i & 0xFF; |
+ *row++ = g_background; |
+ } |
+ for (int i = foreground_rect.x(); |
+ i < std::min(video_frame->stride(0) / 2, foreground_rect.right()); |
+ ++i) { |
+ *row++ = i & 0xFF; |
+ *row++ = g_foreground; |
+ } |
+ for (int i = foreground_rect.right(); i < video_frame->stride(0) / 2; |
+ ++i) { |
+ *row++ = i & 0xFF; |
+ *row++ = g_background; |
+ } |
+ } |
+ } |
+ |
+ CreateTestY16VideoDrawQuad_FromVideoFrame( |
+ shared_state, video_frame, tex_coord_rect, render_pass, |
+ video_resource_updater, rect, visible_rect, resource_provider); |
+} |
+ |
typedef ::testing::Types<GLRenderer, |
SoftwareRenderer, |
GLRendererWithExpandedViewport, |
@@ -723,6 +808,10 @@ template <> |
const base::FilePath::CharType* IntersectingQuadImage<YUVVideoDrawQuad>() { |
return FILE_PATH_LITERAL("intersecting_blue_green_squares_video.png"); |
} |
+template <> |
+const base::FilePath::CharType* IntersectingQuadImage<YVideoDrawQuad>() { |
+ return FILE_PATH_LITERAL("intersecting_light_dark_squares_video.png"); |
+} |
template <typename TypeParam> |
class IntersectingQuadPixelTest : public RendererPixelTest<TypeParam> { |
@@ -984,6 +1073,31 @@ TYPED_TEST(IntersectingQuadGLPixelTest, YUVVideoQuads) { |
FuzzyPixelOffByOneComparator(false)); |
} |
+TYPED_TEST(IntersectingQuadGLPixelTest, YVideoQuads) { |
+ this->SetupQuadStateAndRenderPass(); |
+ gfx::Rect inner_rect( |
+ ((this->quad_rect_.x() + (this->quad_rect_.width() / 4)) & ~0xF), |
+ ((this->quad_rect_.y() + (this->quad_rect_.height() / 4)) & ~0xF), |
+ (this->quad_rect_.width() / 2) & ~0xF, |
+ (this->quad_rect_.height() / 2) & ~0xF); |
+ |
+ CreateTestY16VideoDrawQuad_TwoColor( |
+ this->front_quad_state_, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 18, 0, |
+ this->render_pass_.get(), this->video_resource_updater_.get(), |
+ this->quad_rect_, this->quad_rect_, inner_rect, |
+ this->resource_provider_.get()); |
+ |
+ CreateTestY16VideoDrawQuad_TwoColor( |
+ this->back_quad_state_, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 0, 182, |
+ this->render_pass_.get(), this->video_resource_updater2_.get(), |
+ this->quad_rect_, this->quad_rect_, inner_rect, |
+ this->resource_provider_.get()); |
+ |
+ SCOPED_TRACE("IntersectingVideoQuads"); |
+ this->template AppendBackgroundAndRunTest<YVideoDrawQuad>( |
+ FuzzyPixelOffByOneComparator(false)); |
+} |
+ |
// TODO(skaslev): The software renderer does not support non-premultplied alpha. |
TEST_F(GLRendererPixelTest, NonPremultipliedTextureWithoutBackground) { |
gfx::Rect rect(this->device_viewport_size_); |
@@ -1345,6 +1459,30 @@ TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { |
ExactPixelComparator(true))); |
} |
+TEST_F(VideoGLRendererPixelTest, TwoColorY16Rect) { |
+ gfx::Rect rect(this->device_viewport_size_); |
+ |
+ RenderPassId id(1, 1); |
+ std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
+ |
+ SharedQuadState* shared_state = |
+ CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); |
+ |
+ gfx::Rect upper_rect(rect.x(), rect.y(), rect.width(), rect.height() / 2); |
+ CreateTestY16VideoDrawQuad_TwoColor( |
+ shared_state, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 68, 123, pass.get(), |
+ video_resource_updater_.get(), rect, rect, upper_rect, |
+ resource_provider_.get()); |
+ |
+ RenderPassList pass_list; |
+ pass_list.push_back(std::move(pass)); |
+ |
+ EXPECT_TRUE(this->RunPixelTest( |
+ &pass_list, |
+ base::FilePath(FILE_PATH_LITERAL("blue_yellow_filter_chain.png")), |
+ FuzzyPixelOffByOneComparator(true))); |
+} |
+ |
TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
gfx::Rect viewport_rect(this->device_viewport_size_); |