Commit db5fcdbc authored by Brian Osman's avatar Brian Osman Committed by Commit Bot

Use Mock GrContext (rather than Null GL interface) in media unit test

Skia's NullGL interface is deprecated, and soon to be removed.
For some unit tests in other modules, the Mock GrContext is a
drop-in replacement.

Here, we end up testing the same path in PaintCanvasVideoRenderer,
but with slightly different behavior inside Skia. Ultimately,
NewSkImageFromVideoFrameNative returns nullptr. Previously, this was
due to the context being abandoned. Now, it fails because the Mock
context doesn't support adopted textures at all. (The new code would
test the same code path even without the abandonContext call).

See also: https://cs.chromium.org/chromium/src/media/renderers/paint_canvas_video_renderer.cc?l=239

Change-Id: Ida0b22c7c60fc5217d5931b79f44a61cc80992b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1540357
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644771}
parent 8214311f
......@@ -24,7 +24,6 @@
#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"
using media::VideoFrame;
......@@ -637,11 +636,12 @@ class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
void MailboxHoldersReleased(const gpu::SyncToken& sync_token) {}
} // namespace
// Test that PaintCanvasVideoRendererTest::Paint doesn't crash when GrContext is
// abandoned.
// Test that PaintCanvasVideoRenderer::Paint doesn't crash when GrContext is
// unable to wrap a video frame texture (eg due to being abandoned). The mock
// GrContext will fail to wrap the texture even if it is not abandoned, but we
// leave the abandonContext call in place, in case that behavior changes.
TEST_F(PaintCanvasVideoRendererTest, ContextLost) {
sk_sp<const GrGLInterface> null_interface(GrGLCreateNullInterface());
sk_sp<GrContext> gr_context = GrContext::MakeGL(std::move(null_interface));
sk_sp<GrContext> gr_context = GrContext::MakeMock(nullptr);
gr_context->abandonContext();
cc::SkiaPaintCanvas canvas(AllocBitmap(kWidth, kHeight));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment