Commit 15b64d62 authored by Kramer Ge's avatar Kramer Ge Committed by Commit Bot

Change pixel_test setup to use gfx::SurfaceOrigin

Follow-up CL to crrev.com/c/2083573 to remove vague bool
flips_vertically.

Bug: 1051970
Change-Id: I7442d72396ae435521b9d9006202a4722c2a87eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091922Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Auto-Submit: Kramer Ge <fangzhoug@chromium.org>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747940}
parent 1d954620
...@@ -226,7 +226,8 @@ viz::ResourceId PixelTest::AllocateAndFillSoftwareResource( ...@@ -226,7 +226,8 @@ viz::ResourceId PixelTest::AllocateAndFillSoftwareResource(
viz::SingleReleaseCallback::Create(base::DoNothing())); viz::SingleReleaseCallback::Create(base::DoNothing()));
} }
void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) { void PixelTest::SetUpGLWithoutRenderer(
gfx::SurfaceOrigin output_surface_origin) {
enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>(); enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>();
auto context_provider = auto context_provider =
...@@ -235,9 +236,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) { ...@@ -235,9 +236,7 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
gpu::ContextResult result = context_provider->BindToCurrentThread(); gpu::ContextResult result = context_provider->BindToCurrentThread();
DCHECK_EQ(result, gpu::ContextResult::kSuccess); DCHECK_EQ(result, gpu::ContextResult::kSuccess);
output_surface_ = std::make_unique<PixelTestOutputSurface>( output_surface_ = std::make_unique<PixelTestOutputSurface>(
std::move(context_provider), flipped_output_surface std::move(context_provider), output_surface_origin);
? gfx::SurfaceOrigin::kTopLeft
: gfx::SurfaceOrigin::kBottomLeft);
output_surface_->BindToClient(output_surface_client_.get()); output_surface_->BindToClient(output_surface_client_.get());
shared_bitmap_manager_ = std::make_unique<viz::TestSharedBitmapManager>(); shared_bitmap_manager_ = std::make_unique<viz::TestSharedBitmapManager>();
...@@ -253,8 +252,8 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) { ...@@ -253,8 +252,8 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
child_resource_provider_ = std::make_unique<viz::ClientResourceProvider>(); child_resource_provider_ = std::make_unique<viz::ClientResourceProvider>();
} }
void PixelTest::SetUpGLRenderer(bool flipped_output_surface) { void PixelTest::SetUpGLRenderer(gfx::SurfaceOrigin output_surface_origin) {
SetUpGLWithoutRenderer(flipped_output_surface); SetUpGLWithoutRenderer(output_surface_origin);
renderer_ = std::make_unique<viz::GLRenderer>( renderer_ = std::make_unique<viz::GLRenderer>(
&renderer_settings_, output_surface_.get(), resource_provider_.get(), &renderer_settings_, output_surface_.get(), resource_provider_.get(),
nullptr, base::ThreadTaskRunnerHandle::Get()); nullptr, base::ThreadTaskRunnerHandle::Get());
...@@ -262,7 +261,7 @@ void PixelTest::SetUpGLRenderer(bool flipped_output_surface) { ...@@ -262,7 +261,7 @@ void PixelTest::SetUpGLRenderer(bool flipped_output_surface) {
renderer_->SetVisible(true); renderer_->SetVisible(true);
} }
void PixelTest::SetUpSkiaRenderer(bool flipped_output_surface) { void PixelTest::SetUpSkiaRenderer(gfx::SurfaceOrigin output_surface_origin) {
enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>(); enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>();
// Set up the GPU service. // Set up the GPU service.
gpu_service_holder_ = viz::TestGpuServiceHolder::GetInstance(); gpu_service_holder_ = viz::TestGpuServiceHolder::GetInstance();
...@@ -274,7 +273,7 @@ void PixelTest::SetUpSkiaRenderer(bool flipped_output_surface) { ...@@ -274,7 +273,7 @@ void PixelTest::SetUpSkiaRenderer(bool flipped_output_surface) {
renderer_settings_); renderer_settings_);
output_surface_->BindToClient(output_surface_client_.get()); output_surface_->BindToClient(output_surface_client_.get());
static_cast<viz::SkiaOutputSurfaceImpl*>(output_surface_.get()) static_cast<viz::SkiaOutputSurfaceImpl*>(output_surface_.get())
->SetCapabilitiesForTesting(flipped_output_surface); ->SetCapabilitiesForTesting(output_surface_origin);
resource_provider_ = std::make_unique<viz::DisplayResourceProvider>( resource_provider_ = std::make_unique<viz::DisplayResourceProvider>(
viz::DisplayResourceProvider::kGpu, viz::DisplayResourceProvider::kGpu,
/*compositor_context_provider=*/nullptr, /*compositor_context_provider=*/nullptr,
......
...@@ -116,9 +116,9 @@ class PixelTest : public testing::Test { ...@@ -116,9 +116,9 @@ class PixelTest : public testing::Test {
viz::SoftwareRenderer* software_renderer_ = nullptr; viz::SoftwareRenderer* software_renderer_ = nullptr;
std::unique_ptr<SkBitmap> result_bitmap_; std::unique_ptr<SkBitmap> result_bitmap_;
void SetUpGLWithoutRenderer(bool flipped_output_surface); void SetUpGLWithoutRenderer(gfx::SurfaceOrigin output_surface_origin);
void SetUpGLRenderer(bool flipped_output_surface); void SetUpGLRenderer(gfx::SurfaceOrigin output_surface_origin);
void SetUpSkiaRenderer(bool flipped_output_surface); void SetUpSkiaRenderer(gfx::SurfaceOrigin output_surface_origin);
void SetUpSoftwareRenderer(); void SetUpSoftwareRenderer();
void TearDown() override; void TearDown() override;
...@@ -174,12 +174,12 @@ class VulkanSkiaRendererWithFlippedSurface : public viz::SkiaRenderer {}; ...@@ -174,12 +174,12 @@ class VulkanSkiaRendererWithFlippedSurface : public viz::SkiaRenderer {};
template <> template <>
inline void RendererPixelTest<viz::GLRenderer>::SetUp() { inline void RendererPixelTest<viz::GLRenderer>::SetUp() {
SetUpGLRenderer(false); SetUpGLRenderer(gfx::SurfaceOrigin::kBottomLeft);
} }
template <> template <>
inline void RendererPixelTest<GLRendererWithFlippedSurface>::SetUp() { inline void RendererPixelTest<GLRendererWithFlippedSurface>::SetUp() {
SetUpGLRenderer(true); SetUpGLRenderer(gfx::SurfaceOrigin::kTopLeft);
} }
template <> template <>
...@@ -189,22 +189,22 @@ inline void RendererPixelTest<viz::SoftwareRenderer>::SetUp() { ...@@ -189,22 +189,22 @@ inline void RendererPixelTest<viz::SoftwareRenderer>::SetUp() {
template <> template <>
inline void RendererPixelTest<viz::SkiaRenderer>::SetUp() { inline void RendererPixelTest<viz::SkiaRenderer>::SetUp() {
SetUpSkiaRenderer(false); SetUpSkiaRenderer(gfx::SurfaceOrigin::kBottomLeft);
} }
template <> template <>
inline void RendererPixelTest<SkiaRendererWithFlippedSurface>::SetUp() { inline void RendererPixelTest<SkiaRendererWithFlippedSurface>::SetUp() {
SetUpSkiaRenderer(true); SetUpSkiaRenderer(gfx::SurfaceOrigin::kTopLeft);
} }
template <> template <>
inline void RendererPixelTest<VulkanSkiaRenderer>::SetUp() { inline void RendererPixelTest<VulkanSkiaRenderer>::SetUp() {
SetUpSkiaRenderer(false); SetUpSkiaRenderer(gfx::SurfaceOrigin::kBottomLeft);
} }
template <> template <>
inline void RendererPixelTest<VulkanSkiaRendererWithFlippedSurface>::SetUp() { inline void RendererPixelTest<VulkanSkiaRendererWithFlippedSurface>::SetUp() {
SetUpSkiaRenderer(true); SetUpSkiaRenderer(gfx::SurfaceOrigin::kTopLeft);
} }
typedef RendererPixelTest<viz::GLRenderer> GLRendererPixelTest; typedef RendererPixelTest<viz::GLRenderer> GLRendererPixelTest;
......
...@@ -34,7 +34,7 @@ class GLI420ConverterPixelTest : public cc::PixelTest, ...@@ -34,7 +34,7 @@ class GLI420ConverterPixelTest : public cc::PixelTest,
protected: protected:
void SetUp() final { void SetUp() final {
cc::PixelTest::SetUpGLWithoutRenderer(false); cc::PixelTest::SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
converter_.reset(new GLI420Converter(context_provider(), allow_mrt_path())); converter_.reset(new GLI420Converter(context_provider(), allow_mrt_path()));
texture_helper_ = std::make_unique<GLScalerTestTextureHelper>( texture_helper_ = std::make_unique<GLScalerTestTextureHelper>(
context_provider()->ContextGL()); context_provider()->ContextGL());
......
...@@ -168,7 +168,7 @@ class GLScalerOverscanPixelTest : public cc::PixelTest, ...@@ -168,7 +168,7 @@ class GLScalerOverscanPixelTest : public cc::PixelTest,
protected: protected:
void SetUp() final { void SetUp() final {
cc::PixelTest::SetUpGLWithoutRenderer(false); cc::PixelTest::SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
scaler_ = std::make_unique<GLScaler>(context_provider()); scaler_ = std::make_unique<GLScaler>(context_provider());
gl_ = context_provider()->ContextGL(); gl_ = context_provider()->ContextGL();
......
...@@ -88,7 +88,7 @@ class GLScalerPixelTest : public cc::PixelTest, public GLScalerTestUtil { ...@@ -88,7 +88,7 @@ class GLScalerPixelTest : public cc::PixelTest, public GLScalerTestUtil {
protected: protected:
void SetUp() final { void SetUp() final {
cc::PixelTest::SetUpGLWithoutRenderer(false); cc::PixelTest::SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
scaler_ = std::make_unique<GLScaler>(context_provider()); scaler_ = std::make_unique<GLScaler>(context_provider());
gl_ = context_provider()->ContextGL(); gl_ = context_provider()->ContextGL();
......
...@@ -102,7 +102,7 @@ class GLScalerShaderPixelTest ...@@ -102,7 +102,7 @@ class GLScalerShaderPixelTest
std::pair<GLuint, GLuint> RenderToNewTextures(GLuint src_texture, std::pair<GLuint, GLuint> RenderToNewTextures(GLuint src_texture,
const gfx::Size& size, const gfx::Size& size,
bool dual_outputs) { bool dual_outputs) {
auto dst_textures = std::make_pair<GLuint, GLuint>( std::pair<GLuint, GLuint> dst_textures(
CreateTexture(size), dual_outputs ? CreateTexture(size) : 0u); CreateTexture(size), dual_outputs ? CreateTexture(size) : 0u);
GLuint framebuffer = 0; GLuint framebuffer = 0;
gl_->GenFramebuffers(1, &framebuffer); gl_->GenFramebuffers(1, &framebuffer);
...@@ -309,7 +309,7 @@ class GLScalerShaderPixelTest ...@@ -309,7 +309,7 @@ class GLScalerShaderPixelTest
protected: protected:
void SetUp() final { void SetUp() final {
cc::PixelTest::SetUpGLWithoutRenderer(false); cc::PixelTest::SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
scaler_ = std::make_unique<GLScaler>(context_provider()); scaler_ = std::make_unique<GLScaler>(context_provider());
gl_ = context_provider()->ContextGL(); gl_ = context_provider()->ContextGL();
......
...@@ -83,7 +83,9 @@ class MockContextProvider : public ContextProvider { ...@@ -83,7 +83,9 @@ class MockContextProvider : public ContextProvider {
class GLScalerTest : public cc::PixelTest { class GLScalerTest : public cc::PixelTest {
protected: protected:
void SetUp() final { cc::PixelTest::SetUpGLWithoutRenderer(false); } void SetUp() final {
cc::PixelTest::SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
}
void TearDown() final { cc::PixelTest::TearDown(); } void TearDown() final { cc::PixelTest::TearDown(); }
}; };
......
...@@ -63,7 +63,7 @@ class GLRendererCopierPixelTest ...@@ -63,7 +63,7 @@ class GLRendererCopierPixelTest
std::tuple<GLenum, bool, CopyOutputResult::Format, bool, bool>> { std::tuple<GLenum, bool, CopyOutputResult::Format, bool, bool>> {
public: public:
void SetUp() override { void SetUp() override {
SetUpGLWithoutRenderer(false /* flipped_output_surface */); SetUpGLWithoutRenderer(gfx::SurfaceOrigin::kBottomLeft);
texture_deleter_ = texture_deleter_ =
std::make_unique<TextureDeleter>(base::ThreadTaskRunnerHandle::Get()); std::make_unique<TextureDeleter>(base::ThreadTaskRunnerHandle::Get());
......
...@@ -84,7 +84,7 @@ class SkiaReadbackPixelTest : public cc::PixelTest, ...@@ -84,7 +84,7 @@ class SkiaReadbackPixelTest : public cc::PixelTest,
bool ScaleByHalf() const { return GetParam(); } bool ScaleByHalf() const { return GetParam(); }
void SetUp() override { void SetUp() override {
SetUpSkiaRenderer(false); SetUpSkiaRenderer(gfx::SurfaceOrigin::kBottomLeft);
ASSERT_TRUE(cc::ReadPNGFile( ASSERT_TRUE(cc::ReadPNGFile(
GetTestFilePath(FILE_PATH_LITERAL("16_color_rects.png")), GetTestFilePath(FILE_PATH_LITERAL("16_color_rects.png")),
......
...@@ -678,12 +678,10 @@ void SkiaOutputSurfaceImpl::SetEnableDCLayers(bool enable) { ...@@ -678,12 +678,10 @@ void SkiaOutputSurfaceImpl::SetEnableDCLayers(bool enable) {
#endif #endif
void SkiaOutputSurfaceImpl::SetCapabilitiesForTesting( void SkiaOutputSurfaceImpl::SetCapabilitiesForTesting(
bool flipped_output_surface) { gfx::SurfaceOrigin output_surface_origin) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(impl_on_gpu_); DCHECK(impl_on_gpu_);
capabilities_.output_surface_origin = flipped_output_surface capabilities_.output_surface_origin = output_surface_origin;
? gfx::SurfaceOrigin::kTopLeft
: gfx::SurfaceOrigin::kBottomLeft;
auto callback = auto callback =
base::BindOnce(&SkiaOutputSurfaceImplOnGpu::SetCapabilitiesForTesting, base::BindOnce(&SkiaOutputSurfaceImplOnGpu::SetCapabilitiesForTesting,
base::Unretained(impl_on_gpu_.get()), capabilities_); base::Unretained(impl_on_gpu_.get()), capabilities_);
......
...@@ -147,7 +147,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface { ...@@ -147,7 +147,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface {
// Set the fields of |capabilities_| and propagates to |impl_on_gpu_|. Should // Set the fields of |capabilities_| and propagates to |impl_on_gpu_|. Should
// be called after BindToClient(). // be called after BindToClient().
void SetCapabilitiesForTesting(bool flipped_output_surface); void SetCapabilitiesForTesting(gfx::SurfaceOrigin output_surface_origin);
// Used in unit tests. // Used in unit tests.
void ScheduleGpuTaskForTesting( void ScheduleGpuTaskForTesting(
......
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