chromium/gpu/command_buffer/service/texture_manager_unittest.cc

// Copyright 2012 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/texture_manager.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "base/command_line.h"
#include "build/build_config.h"
#include "gpu/command_buffer/client/client_test_helper.h"
#include "gpu/command_buffer/service/error_state_mock.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/framebuffer_manager.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
#include "gpu/command_buffer/service/gpu_service_test.h"
#include "gpu/command_buffer/service/gpu_tracer.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/mocks.h"
#include "gpu/command_buffer/service/service_discardable_manager.h"
#include "gpu/command_buffer/service/test_helper.h"
#include "gpu/command_buffer/service/test_memory_tracker.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_mock.h"
#include "ui/gl/gl_switches.h"

AtLeast;
Pointee;
Return;
SetArgPointee;
StrictMock;
_;

namespace gpu {
namespace gles2 {

class TextureTestHelper {};

class TextureManagerTestBase : public GpuServiceTest {};

class TextureManagerTest : public TextureManagerTestBase {};

class TextureManagerES3Test : public TextureManagerTestBase {};

// GCC requires these declarations, but MSVC requires they not be present
#ifndef COMPILER_MSVC
const GLint TextureManagerTestBase::kMaxTextureSize;
const GLint TextureManagerTestBase::kMaxCubeMapTextureSize;
const GLint TextureManagerTestBase::kMaxRectangleTextureSize;
const GLint TextureManagerTestBase::kMaxExternalTextureSize;
const GLint TextureManagerTestBase::kMax3DTextureSize;
const GLint TextureManagerTestBase::kMaxArrayTextureLayers;
const GLint TextureManagerTestBase::kMax2dLevels;
const GLint TextureManagerTestBase::kMaxCubeMapLevels;
const GLint TextureManagerTestBase::kMaxExternalLevels;
const GLint TextureManagerTestBase::kMax3dLevels;
#endif

TEST_F(TextureManagerTest, Basic) {}

TEST_F(TextureManagerTest, SetParameter) {}

TEST_F(TextureManagerTest, UseDefaultTexturesTrue) {}

TEST_F(TextureManagerTest, UseDefaultTexturesFalse) {}

TEST_F(TextureManagerES3Test, UseDefaultTexturesTrueES3) {}

TEST_F(TextureManagerES3Test, UseDefaultTexturesFalseES3) {}

TEST_F(TextureManagerTest, TextureUsageExt) {}

TEST_F(TextureManagerTest, Destroy) {}

TEST_F(TextureManagerTest, MaxValues) {}

TEST_F(TextureManagerTest, ValidForTarget) {}

TEST_F(TextureManagerTest, ValidForTargetNPOT) {}

class TextureTestBase : public GpuServiceTest {};

class TextureTest : public TextureTestBase {};

class TextureMemoryTrackerTest : public TextureTestBase {};

#define EXPECT_MEMORY_ALLOCATION_CHANGE(old_size, new_size)

TEST_F(TextureTest, Basic) {}

TEST_F(TextureTest, SetTargetTexture2D) {}

TEST_F(TextureTest, SetTargetTextureExternalOES) {}

TEST_F(TextureTest, ZeroSizeCanNotRender2D) {}

TEST_F(TextureTest, ZeroSizeCanNotRenderExternalOES) {}

TEST_F(TextureTest, CanRenderTo) {}

TEST_F(TextureTest, CanNotRenderTo) {}

TEST_F(TextureTest, EstimatedSize) {}

TEST_F(TextureMemoryTrackerTest, EstimatedSize) {}

TEST_F(TextureMemoryTrackerTest, LightweightRef) {}

TEST_F(TextureTest, POT2D) {}

TEST_F(TextureTest, BaseLevel) {}

TEST_F(TextureTest, BaseLevelMaxLevel) {}

TEST_F(TextureMemoryTrackerTest, MarkMipmapsGenerated) {}

TEST_F(TextureTest, UnusedMips) {}

TEST_F(TextureTest, NPOT2D) {}

TEST_F(TextureTest, NPOT2DNPOTOK) {}

TEST_F(TextureTest, POTCubeMap) {}

TEST_F(TextureTest, POTCubeMapWithoutMipmap) {}

TEST_F(TextureTest, GetLevelSize) {}

TEST_F(TextureTest, GetLevelSizeTexture2DArray) {}

TEST_F(TextureTest, GetLevelType) {}

TEST_F(TextureTest, ValidForTexture) {}

TEST_F(TextureTest, FloatNotLinear) {}

TEST_F(TextureTest, FloatLinear) {}

TEST_F(TextureTest, HalfFloatNotLinear) {}

TEST_F(TextureTest, HalfFloatLinear) {}

TEST_F(TextureTest, EGLImageExternal) {}

TEST_F(TextureTest, DepthTexture) {}

TEST_F(TextureTest, SafeUnsafe) {}

TEST_F(TextureTest, ClearTexture) {}

TEST_F(TextureTest, UseDeletedTexture) {}

#if BUILDFLAG(IS_ANDROID)
TEST_F(TextureTest, SetStreamTextureImageServiceID) {
  manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
  manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES, 0,
                         GL_RGBA, 2, 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
                         gfx::Rect(2, 2));
  Texture* texture = texture_ref_->texture();

  GLuint owned_service_id = TextureTestHelper::owned_service_id(texture);
  GLuint service_id = texture->service_id();
  // Initially, the texture should use the same service id that it owns.
  EXPECT_EQ(owned_service_id, service_id);

  // Override the service_id.
  GLuint stream_texture_service_id = service_id + 1;
  texture->BindToServiceId(stream_texture_service_id);

  // Make sure that service_id() changed but owned_service_id() didn't.
  EXPECT_EQ(stream_texture_service_id, texture->service_id());
  EXPECT_EQ(owned_service_id, TextureTestHelper::owned_service_id(texture));

  // Undo the override.
  texture->BindToServiceId(0);

  // The service IDs should be back as they were.
  EXPECT_EQ(service_id, texture->service_id());
  EXPECT_EQ(owned_service_id, TextureTestHelper::owned_service_id(texture));

  // Override again, so that we can check delete behavior.
  texture->BindToServiceId(stream_texture_service_id);

  // Remove the Texture.  It should delete the texture id that it owns, even
  // though it is overridden.
  EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(owned_service_id)))
      .Times(1)
      .RetiresOnSaturation();
  manager_->RemoveTexture(kClient1Id);
  texture_ref_ = nullptr;
}
#endif

namespace {

bool InSet(std::set<std::string>* string_set, const std::string& str) {}

}  // anonymous namespace

TEST_F(TextureTest, AddToSignature) {}

class ProduceConsumeTextureTest : public TextureTest,
                                  public ::testing::WithParamInterface<GLenum> {};

const GLuint ProduceConsumeTextureTest::kClient2Id =;
const GLuint ProduceConsumeTextureTest::kService2Id =;

TEST_F(ProduceConsumeTextureTest, ProduceConsume2D) {}

TEST_F(ProduceConsumeTextureTest, ProduceConsumeClearRectangle) {}

TEST_F(ProduceConsumeTextureTest, ProduceConsumeExternal) {}

TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) {}

static const GLenum kTextureTargets[] =;

INSTANTIATE_TEST_SUITE_P();

TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {}

class SharedTextureTest : public GpuServiceTest {};

TEST_F(SharedTextureTest, DeleteTextures) {}

TEST_F(SharedTextureTest, TextureSafetyAccounting) {}

TEST_F(SharedTextureTest, FBOCompletenessCheck) {}

TEST_F(SharedTextureTest, Memory) {}

class TextureFormatTypeValidationTest : public TextureManagerTest {};

TEST_F(TextureFormatTypeValidationTest, ES2Basic) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithExtTextureFormatBGRA8888) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithAppleTextureFormatBGRA8888) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithOesDepth) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithAngleDepth) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithExtPackedDepthStencil) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithRGWithFloat) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithRGNoFloat) {}

TEST_F(TextureFormatTypeValidationTest, ES2OnTopOfES3) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithOesTextureFloat) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithOesTextureFloatLinear) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithOesTextureHalfFloat) {}

TEST_F(TextureFormatTypeValidationTest, ES2WithOesTextureHalfFloatLinear) {}

TEST_F(TextureFormatTypeValidationTest, ES3Basic) {}

TEST_F(TextureFormatTypeValidationTest, ES3WithTextureNorm16) {}

}  // namespace gles2
}  // namespace gpu