chromium/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory_unittest.cc

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

#include "gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.h"

#include <thread>

#include "base/command_line.h"
#include "build/build_config.h"
#include "cc/test/pixel_comparator.h"
#include "cc/test/pixel_test_utils.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/service_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_factory.h"
#include "gpu/command_buffer/service/shared_image/shared_image_format_service_utils.h"
#include "gpu/command_buffer/service/shared_image/shared_image_manager.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "gpu/command_buffer/service/shared_image/shared_image_test_base.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_feature_info.h"
#include "gpu/config/gpu_preferences.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/private/chromium/GrPromiseImageTexture.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/progress_reporter.h"

AtLeast;

namespace gpu {
namespace {

class MockProgressReporter : public gl::ProgressReporter {};

class GLTextureImageBackingFactoryTestBase : public SharedImageTestBase {};

// Non-parameterized tests.
class GLTextureImageBackingFactoryTest
    : public GLTextureImageBackingFactoryTestBase {};

// SharedImageFormat parameterized tests.
class GLTextureImageBackingFactoryWithFormatTest
    : public GLTextureImageBackingFactoryTest,
      public testing::WithParamInterface<viz::SharedImageFormat> {};

// SharedImageFormat parameterized tests for initial data upload. Only a subset
// of formats support upload.
GLTextureImageBackingFactoryInitialDataTest;

// SharedImageFormat parameterized tests with a factory that supports pixel
// upload.
class GLTextureImageBackingFactoryWithUploadTest
    : public GLTextureImageBackingFactoryTestBase,
      public testing::WithParamInterface<viz::SharedImageFormat> {};

GLTextureImageBackingFactoryWithReadbackTest;

TEST_F(GLTextureImageBackingFactoryTest, InvalidFormat) {}

TEST_F(GLTextureImageBackingFactoryTest, InvalidUsageWithANGLEMetal) {}

// Tests that GLES2 usages, which would normally be disallowed with ANGLE-Metal
// due to WebGL potentially being on different GPU from raster, are allowed if
// the client specifies that the GLES2 usage is for raster only.
TEST_F(GLTextureImageBackingFactoryTest,
       GLES2UsageAllowedWithANGLEMetalIfRasterOnly) {}

// This test verifies that GLTextureImageBackingFactory using ANGLE-Metal allows
// creation of an I420 SI with usages that together specify that it will be used
// conceptually only for raster over GLES2. Regression test for
// crbug.com/328472684.
TEST_F(GLTextureImageBackingFactoryTest,
       I420SIUsedOnlyForRasterOverGLESAllowedWithANGLEMetal) {}

// Tests that GLTextureImageBackingFactory will not create SharedImages with
// Skia usages when Skia is using Graphite (as in that case Skia is not
// necessarily using GL).
TEST_F(GLTextureImageBackingFactoryTest, InvalidUsageWithGraphite) {}

// Tests that GLTextureImageBackingFactory will allow creation of SharedImages
// with Skia usages when Skia is using Graphite if the client specifies that
// raster usage is over the GLES2 interface only, as in that case Skia is by
// definition using GL.
TEST_F(GLTextureImageBackingFactoryTest,
       RasterUsageWithGraphiteAllowedWhenOverGLES2Only) {}

// This test verifies that GLTextureImageBackingFactory using Graphite allows
// creation of an I420 SI with usages that together specify that it will be used
// conceptually only for raster over GLES2. Regression test for
// crbug.com/328472684.
TEST_F(GLTextureImageBackingFactoryTest,
       I420SIUsedOnlyForRasterOverGLESAllowedWithGraphite) {}

// Ensures that GLTextureImageBacking registers it's estimated size
// with memory tracker.
TEST_F(GLTextureImageBackingFactoryTest, EstimatedSize) {}

// Ensures that the various conversion functions used w/ TexStorage2D match
// their TexImage2D equivalents, allowing us to minimize the amount of parallel
// data tracked in the GLTextureImageBackingFactory.
TEST_F(GLTextureImageBackingFactoryTest, TexImageTexStorageEquivalence) {}

TEST_P(GLTextureImageBackingFactoryWithFormatTest, IsSupported) {}

TEST_P(GLTextureImageBackingFactoryWithFormatTest, Basic) {}

TEST_P(GLTextureImageBackingFactoryWithFormatTest, InvalidSize) {}

TEST_P(GLTextureImageBackingFactoryInitialDataTest, InitialData) {}

TEST_P(GLTextureImageBackingFactoryInitialDataTest, InitialDataWrongSize) {}

TEST_F(GLTextureImageBackingFactoryWithUploadTest, InvalidUsageWithANGLEMetal) {}

TEST_P(GLTextureImageBackingFactoryWithUploadTest, UploadFromMemory) {}

TEST_P(GLTextureImageBackingFactoryWithReadbackTest, ReadbackToMemory) {}

std::string TestParamToString(
    const testing::TestParamInfo<viz::SharedImageFormat>& param_info) {}

const auto kInitialDataFormats =;

INSTANTIATE_TEST_SUITE_P();

const auto kSharedImageFormats =;

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

const auto kReadbackFormats =;

INSTANTIATE_TEST_SUITE_P();

}  // anonymous namespace
}  // namespace gpu