chromium/gpu/command_buffer/tests/gl_helper_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "gpu/command_buffer/client/gl_helper.h"

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES2/gl2extchromium.h>

#include <algorithm>
#include <cmath>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/viz/test/test_gpu_service_holder.h"
#include "gpu/command_buffer/client/gl_helper_scaling.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
#include "gpu/ipc/gl_in_process_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"

#if !BUILDFLAG(IS_ANDROID)

namespace gpu {

namespace {

GLHelper::ScalerQuality kQualities[] =;

const char* kQualityNames[] =;

}  // namespace

class GLHelperTest : public testing::Test {};

class GLHelperPixelTest : public GLHelperTest {};

// TODO(crbug.com/40246425): Re-enable this test
TEST_F(GLHelperTest, DISABLED_RGBAASyncReadbackTest) {}

TEST_F(GLHelperTest, BGRAASyncReadbackTest) {}

int kRGBReadBackSizes[] =;

class GLHelperPixelReadbackTest
    : public GLHelperPixelTest,
      public ::testing::WithParamInterface<std::tuple<unsigned int,
                                                      unsigned int,
                                                      unsigned int,
                                                      unsigned int,
                                                      unsigned int>> {};

// Per pixel tests, all sizes are small so that we can print
// out the generated bitmaps.
// TODO(crbug.com/40867694): Very flaky on Linux ASAN.
#if BUILDFLAG(IS_LINUX) && defined(ADDRESS_SANITIZER)
#define MAYBE_ScaleTest
#else
#define MAYBE_ScaleTest
#endif
TEST_P(GLHelperPixelReadbackTest, MAYBE_ScaleTest) {}

// FLAKY: https://crbug.com/871799
TEST_P(GLHelperPixelReadbackTest, DISABLED_ScalePatching) {}

INSTANTIATE_TEST_SUITE_P();

// Validate that all scaling generates valid pipelines.
TEST_F(GLHelperTest, ValidateScalerPipelines) {}

// Make sure we don't create overly complicated pipelines
// for a few common use cases.
TEST_F(GLHelperTest, CheckSpecificPipelines) {}

TEST_F(GLHelperTest, ScalerOpTest) {}

TEST_F(GLHelperTest, CheckOptimizations) {}

}  // namespace gpu

#endif  // BUILDFLAG(IS_ANDROID)