blob: 1442d886bd0dfd79fd02b3aba173ba789ef4513d [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <array>
#include <string>
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gl/gl_bindings.h"
#define SHADER(Src) "#version 100\n" #Src
#define OEIE_SHADER(Src) \
"#version 100\n#extension GL_OES_EGL_image_external : require\n" #Src
#define VOID_OFFSET(x) reinterpret_cast<void*>(x)
namespace gfx {
class RectF;
class Size;
class SizeF;
class Transform;
} // namespace gfx
namespace vr {
std::array<float, 16> MatrixToGLArray(const gfx::Transform& matrix);
gfx::Rect CalculatePixelSpaceRect(const gfx::Size& texture_size,
const gfx::RectF& texture_rect);
// Compile a shader.
GLuint CompileShader(GLenum shader_type,
const GLchar* shader_source,
std::string& error);
// Compile and link a program.
GLuint CreateAndLinkProgram(GLuint vertex_shader_handle,
GLuint fragment_shader_handle,
std::string& error);
// Returns the normalized size of the element projected into screen space.
// If (1, 1) the element fills the entire buffer.
gfx::SizeF CalculateScreenSize(const gfx::Transform& proj_matrix,
const gfx::Transform& model_matrix,
const gfx::SizeF& size);
// Sets default texture parameters given a texture type.
void SetTexParameters(GLenum texture_type);
// Sets color uniforms given an SkColor.
void SetColorUniform(GLuint handle, SkColor c);
} // namespace vr