#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <GLES3/gl3.h>
#include <stdint.h>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/aligned_memory.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/byte_conversions.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/skia_paint_canvas.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_gpu_service_holder.h"
#include "components/viz/test/test_in_process_context_provider.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface_stub.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/config/gpu_feature_info.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "media/renderers/paint_canvas_video_renderer.h"
#include "media/renderers/shared_image_video_frame_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/libyuv/include/libyuv/scale.h"
#include "third_party/skia/include/core/SkColorPriv.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/GrDirectContext.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/test/gl_surface_test_support.h"
VideoFrame;
namespace media {
static const int kWidth = …;
static const int kHeight = …;
static const gfx::RectF kNaturalRect(kWidth, kHeight);
scoped_refptr<VideoFrame> CreateTestY16Frame(const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
void* external_memory,
base::TimeDelta timestamp) { … }
static std::unique_ptr<uint8_t[]> ReadbackTexture(
gpu::gles2::GLES2Interface* gl,
GLuint texture,
const gfx::Size& size) { … }
static auto ColorGetter(uint8_t* pixels, const gfx::Size& size) { … }
class PaintCanvasVideoRendererTest : public testing::Test { … };
static SkBitmap AllocBitmap(int width, int height) { … }
static scoped_refptr<VideoFrame> CreateCroppedFrame() { … }
PaintCanvasVideoRendererTest::PaintCanvasVideoRendererTest()
: … { … }
PaintCanvasVideoRendererTest::~PaintCanvasVideoRendererTest() = default;
void PaintCanvasVideoRendererTest::PaintWithoutFrame(cc::PaintCanvas* canvas) { … }
void PaintCanvasVideoRendererTest::Paint(scoped_refptr<VideoFrame> video_frame,
cc::PaintCanvas* canvas,
Color color) { … }
void PaintCanvasVideoRendererTest::PaintRotated(
scoped_refptr<VideoFrame> video_frame,
cc::PaintCanvas* canvas,
const gfx::RectF& dest_rect,
Color color,
SkBlendMode mode,
VideoTransformation video_transformation) { … }
void PaintCanvasVideoRendererTest::Copy(scoped_refptr<VideoFrame> video_frame,
cc::PaintCanvas* canvas) { … }
TEST_F(PaintCanvasVideoRendererTest, NoFrame) { … }
TEST_F(PaintCanvasVideoRendererTest, TransparentFrame) { … }
TEST_F(PaintCanvasVideoRendererTest, TransparentFrameSrcMode) { … }
TEST_F(PaintCanvasVideoRendererTest, TransparentFrameSrcMode1x1) { … }
TEST_F(PaintCanvasVideoRendererTest, CopyTransparentFrame) { … }
TEST_F(PaintCanvasVideoRendererTest, Natural) { … }
TEST_F(PaintCanvasVideoRendererTest, Larger) { … }
TEST_F(PaintCanvasVideoRendererTest, Smaller) { … }
TEST_F(PaintCanvasVideoRendererTest, NoTimestamp) { … }
TEST_F(PaintCanvasVideoRendererTest, CroppedFrame) { … }
uint32_t MaybeConvertABGRToARGB(uint32_t abgr) { … }
TEST_F(PaintCanvasVideoRendererTest, CroppedFrameToRGBParallel) { … }
TEST_F(PaintCanvasVideoRendererTest, CroppedFrame_NoScaling) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Rotation_90) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Rotation_180) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Rotation_270) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Translate) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Translate_Rotation_90) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Translate_Rotation_180) { … }
TEST_F(PaintCanvasVideoRendererTest, Video_Translate_Rotation_270) { … }
TEST_F(PaintCanvasVideoRendererTest, HighBitDepth) { … }
TEST_F(PaintCanvasVideoRendererTest, Y16) { … }
TEST_F(PaintCanvasVideoRendererTest, Yuv420P12OddWidth) { … }
TEST_F(PaintCanvasVideoRendererTest, I420WithFilters) { … }
namespace {
class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub { … };
#if !BUILDFLAG(IS_ANDROID)
void MailboxHoldersReleased(const gpu::SyncToken& sync_token) { … }
#endif
}
#if !BUILDFLAG(IS_ANDROID)
TEST_F(PaintCanvasVideoRendererTest, ContextLost) { … }
#endif
void EmptyCallback(const gpu::SyncToken& sync_token) { … }
TEST_F(PaintCanvasVideoRendererTest, CorrectFrameSizeToVisibleRect) { … }
TEST_F(PaintCanvasVideoRendererTest, TexImage2D_Y16_RGBA32F) { … }
TEST_F(PaintCanvasVideoRendererTest, TexSubImage2D_Y16_R32F) { … }
class PaintCanvasVideoRendererWithGLTest : public testing::Test { … };
TEST_F(PaintCanvasVideoRendererWithGLTest, CopyVideoFrameYUVDataToGLTexture) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest,
CopyVideoFrameYUVDataToGLTexture_FlipY) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest,
CopyVideoFrameTexturesToGLTextureRGBA) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest,
CopyVideoFrameTexturesToGLTextureRGBA_ReadLockFence) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest, PaintRGBA) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest,
CopyVideoFrameTexturesToGLTextureI420) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest, PaintI420) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest, PaintI420NotSubset) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest,
CopyVideoFrameTexturesToGLTextureNV12) { … }
TEST_F(PaintCanvasVideoRendererWithGLTest, PaintNV12) { … }
}