#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/client/gl_helper_scaling.h"
#include <stddef.h>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/circular_deque.h"
#include "base/containers/heap_array.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d_f.h"
namespace gpu {
GLES2Interface;
namespace {
const GLfloat kRGBtoGrayscaleColorWeights[4] = …;
const GLfloat kRGBtoYColorWeights[4] = …;
const GLfloat kRGBtoUColorWeights[4] = …;
const GLfloat kRGBtoVColorWeights[4] = …;
bool AreRatiosEqual(int32_t a_num,
int32_t a_denom,
int32_t b_num,
int32_t b_denom) { … }
}
GLHelperScaling::GLHelperScaling(GLES2Interface* gl, GLHelper* helper)
: … { … }
GLHelperScaling::~GLHelperScaling() { … }
class ShaderProgram : public base::RefCounted<ShaderProgram> { … };
class ScalerImpl : public GLHelper::ScalerInterface { … };
void GLHelperScaling::ConvertScalerOpsToScalerStages(
GLHelper::ScalerQuality quality,
gfx::Vector2d scale_from,
base::circular_deque<GLHelperScaling::ScaleOp>* x_ops,
base::circular_deque<GLHelperScaling::ScaleOp>* y_ops,
std::vector<ScalerStage>* scaler_stages) { … }
void GLHelperScaling::ComputeScalerStages(
GLHelper::ScalerQuality quality,
const gfx::Vector2d& scale_from,
const gfx::Vector2d& scale_to,
bool flipped_source,
bool flip_output,
bool swizzle,
std::vector<ScalerStage>* scaler_stages) { … }
std::unique_ptr<GLHelper::ScalerInterface> GLHelperScaling::CreateScaler(
GLHelper::ScalerQuality quality,
const gfx::Vector2d& scale_from,
const gfx::Vector2d& scale_to,
bool flipped_source,
bool flip_output,
bool swizzle) { … }
std::unique_ptr<GLHelper::ScalerInterface>
GLHelperScaling::CreateGrayscalePlanerizer(bool flipped_source,
bool flip_output,
bool swizzle) { … }
std::unique_ptr<GLHelper::ScalerInterface>
GLHelperScaling::CreateI420Planerizer(int plane,
bool flipped_source,
bool flip_output,
bool swizzle) { … }
std::unique_ptr<GLHelper::ScalerInterface>
GLHelperScaling::CreateI420MrtPass1Planerizer(bool flipped_source,
bool flip_output,
bool swizzle) { … }
std::unique_ptr<GLHelper::ScalerInterface>
GLHelperScaling::CreateI420MrtPass2Planerizer(bool swizzle) { … }
const GLfloat GLHelperScaling::kVertexAttributes[] = …;
void GLHelperScaling::InitBuffer() { … }
scoped_refptr<ShaderProgram> GLHelperScaling::GetShaderProgram(ShaderType type,
bool swizzle) { … }
namespace {
GLuint CompileShaderFromSource(GLES2Interface* gl,
const GLchar* source,
GLenum type) { … }
}
void ShaderProgram::Setup(const GLchar* vertex_shader_text,
const GLchar* fragment_shader_text) { … }
void ShaderProgram::UseProgram(const gfx::Size& src_texture_size,
const gfx::RectF& src_rect,
const gfx::Size& dst_size,
bool scale_x,
bool flip_y,
const GLfloat color_weights[3][4]) { … }
}