Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Unified Diff: media/renderers/skcanvas_video_renderer_unittest.cc

Issue 2369093002: Fixing repeated pixels when drawing HTML5 video to canvas. (Closed)
Patch Set: Minor corrections in unit test. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/renderers/skcanvas_video_renderer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/skcanvas_video_renderer_unittest.cc
diff --git a/media/renderers/skcanvas_video_renderer_unittest.cc b/media/renderers/skcanvas_video_renderer_unittest.cc
index 55ab3b1448fae3c2715bb5fe5e523846c8c473d8..fe4ceffc901ba918dc8155477d2c9f02cac65da0 100644
--- a/media/renderers/skcanvas_video_renderer_unittest.cc
+++ b/media/renderers/skcanvas_video_renderer_unittest.cc
@@ -15,7 +15,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkRefCnt.h"
+#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
#include "ui/gfx/geometry/rect_f.h"
@@ -546,4 +548,46 @@ TEST_F(SkCanvasVideoRendererTest, ContextLost) {
renderer_.Paint(video_frame, &canvas, kNaturalRect, paint, VIDEO_ROTATION_90,
context_3d);
}
+
+void EmptyCallback(const gpu::SyncToken& sync_token) {}
+
+TEST_F(SkCanvasVideoRendererTest, CorrectFrameSizeToVisibleRect) {
+ int fWidth{16}, fHeight{16};
+ SkImageInfo imInfo =
+ SkImageInfo::MakeN32(fWidth, fHeight, kOpaque_SkAlphaType);
+
+ sk_sp<const GrGLInterface> glInterface(GrGLCreateNullInterface());
+ sk_sp<GrContext> grContext(
+ GrContext::Create(kOpenGL_GrBackend,
+ reinterpret_cast<GrBackendContext>(glInterface.get())));
+
+ sk_sp<SkSurface> skSurface =
+ SkSurface::MakeRenderTarget(grContext.get(), SkBudgeted::kYes, imInfo);
+ SkCanvas* canvas = skSurface->getCanvas();
+
+ TestGLES2Interface gles2;
+ Context3D context_3d(&gles2, grContext.get());
+ gfx::Size coded_size(fWidth, fHeight);
+ gfx::Size visible_size(fWidth / 2, fHeight / 2);
+
+ gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
+ for (size_t i = 0; i < VideoFrame::kMaxPlanes; i++) {
+ mailbox_holders[i] = gpu::MailboxHolder(
+ gpu::Mailbox::Generate(), gpu::SyncToken(), GL_TEXTURE_RECTANGLE_ARB);
+ }
+
+ auto video_frame = VideoFrame::WrapNativeTextures(
+ PIXEL_FORMAT_I420, mailbox_holders, base::Bind(EmptyCallback), coded_size,
+ gfx::Rect(visible_size), visible_size,
+ base::TimeDelta::FromMilliseconds(4));
+
+ gfx::RectF visible_rect(visible_size.width(), visible_size.height());
+ SkPaint paint;
+ renderer_.Paint(video_frame, canvas, visible_rect, paint, VIDEO_ROTATION_0,
+ context_3d);
+
+ EXPECT_EQ(fWidth / 2, renderer_.LastImageDimensionsForTesting().width());
+ EXPECT_EQ(fWidth / 2, renderer_.LastImageDimensionsForTesting().height());
+}
+
} // namespace media
« no previous file with comments | « media/renderers/skcanvas_video_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698