#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
#include <stddef.h>
#include <unordered_map>
#include "base/containers/heap_array.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/gles2_cmd_copy_texture_chromium_utils.h"
#include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/decoder_context.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h"
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_enums.h"
#include "ui/gl/gl_version_info.h"
namespace gpu {
namespace gles2 {
namespace {
enum { … };
enum { … };
enum { … };
enum { … };
const unsigned kAlphaSize = …;
const unsigned kNumVertexShaders = …;
static_assert …;
const unsigned kNumFragmentShaders = …;
ShaderId;
ShaderId GetVertexShaderId(unsigned glslVersion) { … }
ShaderId GetFragmentShaderId(unsigned glslVersion,
bool premultiply_alpha,
bool unpremultiply_alpha,
GLenum target,
GLenum source_format,
GLenum dest_format) { … }
const char* kShaderPrecisionPreamble = …;
void InsertVersionDirective(std::string* source, unsigned glslVersion) { … }
unsigned ChooseGLSLVersion(const gl::GLVersionInfo& gl_version_info,
GLenum dest_format) { … }
std::string GetVertexShaderSource(unsigned glslVersion) { … }
std::string GetFragmentShaderSource(unsigned glslVersion,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool nv_egl_stream_consumer_external,
GLenum target,
GLenum source_format,
GLenum dest_format) { … }
GLenum getIntermediateFormat(GLenum format) { … }
void DeleteShader(GLuint shader) { … }
bool BindFramebufferTexture2D(GLenum target,
GLuint texture_id,
GLint level,
GLuint framebuffer) { … }
void DoCopyTexImage2D(
gpu::DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLsizei width,
GLsizei height,
GLuint framebuffer,
gpu::gles2::CopyTexImageResourceManager* luma_emulation_blitter) { … }
void DoCopyTexSubImage2D(
gpu::DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLint xoffset,
GLint yoffset,
GLint source_x,
GLint source_y,
GLsizei source_width,
GLsizei source_height,
GLuint framebuffer,
gpu::gles2::CopyTexImageResourceManager* luma_emulation_blitter) { … }
void convertToRGB(const uint8_t* source,
uint8_t* destination,
unsigned length) { … }
void convertToRGBFloat(const uint8_t* source,
float* destination,
unsigned length) { … }
void PrepareUnpackBuffer(GLuint buffer[2],
GLenum format,
GLenum type,
GLsizei width,
GLsizei height) { … }
enum TexImageCommandType { … };
void DoReadbackAndTexImage(TexImageCommandType command_type,
gpu::DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLuint framebuffer) { … }
class CopyTextureResourceManagerImpl
: public CopyTextureCHROMIUMResourceManager { … };
CopyTextureResourceManagerImpl::CopyTextureResourceManagerImpl()
: … { … }
CopyTextureResourceManagerImpl::~CopyTextureResourceManagerImpl() { … }
void CopyTextureResourceManagerImpl::Initialize(
const DecoderContext* decoder,
const gles2::FeatureInfo::FeatureFlags& feature_flags) { … }
void CopyTextureResourceManagerImpl::Destroy() { … }
void CopyTextureResourceManagerImpl::DoCopySubTexture(
DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLsizei dest_width,
GLsizei dest_height,
GLsizei source_width,
GLsizei source_height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
CopyTextureMethod method,
gpu::gles2::CopyTexImageResourceManager* luma_emulation_blitter) { … }
void CopyTextureResourceManagerImpl::DoCopyTexture(
DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLsizei width,
GLsizei height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
CopyTextureMethod method,
gpu::gles2::CopyTexImageResourceManager* luma_emulation_blitter) { … }
void CopyTextureResourceManagerImpl::DoCopyTextureInternal(
DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_format,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLsizei dest_width,
GLsizei dest_height,
GLsizei source_width,
GLsizei source_height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
gpu::gles2::CopyTexImageResourceManager* luma_emulation_blitter) { … }
}
CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() =
default;
CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() =
default;
CopyTextureCHROMIUMResourceManager*
CopyTextureCHROMIUMResourceManager::Create() { … }
}
}