| Index: cc/output/program_binding.cc
|
| diff --git a/cc/output/program_binding.cc b/cc/output/program_binding.cc
|
| index 210dc76899ec361f4328d705ae16d6f26934b9e8..9152e5acd2c7e1992e6133f363d5318408d0cc3a 100644
|
| --- a/cc/output/program_binding.cc
|
| +++ b/cc/output/program_binding.cc
|
| @@ -6,11 +6,10 @@
|
|
|
| #include "base/debug/trace_event.h"
|
| #include "cc/output/geometry_binding.h"
|
| -#include "cc/output/gl_renderer.h" // For the GLC() macro.
|
| -#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
|
| +#include "gpu/command_buffer/client/gles2_interface.h"
|
| #include "third_party/khronos/GLES2/gl2.h"
|
|
|
| -using blink::WebGraphicsContext3D;
|
| +using gpu::gles2::GLES2Interface;
|
|
|
| namespace cc {
|
|
|
| @@ -28,7 +27,7 @@ ProgramBindingBase::~ProgramBindingBase() {
|
| DCHECK(!initialized_);
|
| }
|
|
|
| -bool ProgramBindingBase::Init(WebGraphicsContext3D* context,
|
| +bool ProgramBindingBase::Init(GLES2Interface* context,
|
| const std::string& vertex_shader,
|
| const std::string& fragment_shader) {
|
| TRACE_EVENT0("cc", "ProgramBindingBase::init");
|
| @@ -39,7 +38,7 @@ bool ProgramBindingBase::Init(WebGraphicsContext3D* context,
|
| fragment_shader_id_ =
|
| LoadShader(context, GL_FRAGMENT_SHADER, fragment_shader);
|
| if (!fragment_shader_id_) {
|
| - GLC(context, context->deleteShader(vertex_shader_id_));
|
| + context->DeleteShader(vertex_shader_id_);
|
| vertex_shader_id_ = 0;
|
| return false;
|
| }
|
| @@ -49,91 +48,84 @@ bool ProgramBindingBase::Init(WebGraphicsContext3D* context,
|
| return !!program_;
|
| }
|
|
|
| -bool ProgramBindingBase::Link(WebGraphicsContext3D* context) {
|
| - GLC(context, context->linkProgram(program_));
|
| +bool ProgramBindingBase::Link(GLES2Interface* context) {
|
| + context->LinkProgram(program_);
|
| CleanupShaders(context);
|
| if (!program_)
|
| return false;
|
| #ifndef NDEBUG
|
| int linked = 0;
|
| - GLC(context, context->getProgramiv(program_, GL_LINK_STATUS, &linked));
|
| - if (!linked) {
|
| - GLC(context, context->deleteProgram(program_));
|
| + context->GetProgramiv(program_, GL_LINK_STATUS, &linked);
|
| + if (!linked)
|
| return false;
|
| - }
|
| #endif
|
| return true;
|
| }
|
|
|
| -void ProgramBindingBase::Cleanup(WebGraphicsContext3D* context) {
|
| - if (!initialized_)
|
| - return;
|
| -
|
| +void ProgramBindingBase::Cleanup(GLES2Interface* context) {
|
| initialized_ = false;
|
| if (!program_)
|
| return;
|
|
|
| DCHECK(context);
|
| - GLC(context, context->deleteProgram(program_));
|
| + context->DeleteProgram(program_);
|
| program_ = 0;
|
|
|
| CleanupShaders(context);
|
| }
|
|
|
| -unsigned ProgramBindingBase::LoadShader(WebGraphicsContext3D* context,
|
| +unsigned ProgramBindingBase::LoadShader(GLES2Interface* context,
|
| unsigned type,
|
| const std::string& shader_source) {
|
| - unsigned shader = context->createShader(type);
|
| + unsigned shader = context->CreateShader(type);
|
| if (!shader)
|
| - return 0;
|
| - GLC(context, context->shaderSource(shader, shader_source.data()));
|
| - GLC(context, context->compileShader(shader));
|
| + return 0u;
|
| +
|
| + const char* shader_source_str[] = { shader_source.data() };
|
| + int shader_length[] = { static_cast<int>(shader_source.length()) };
|
| + context->ShaderSource(
|
| + shader, 1,
|
| + shader_source_str,
|
| + shader_length);
|
| + context->CompileShader(shader);
|
| #ifndef NDEBUG
|
| int compiled = 0;
|
| - GLC(context, context->getShaderiv(shader, GL_COMPILE_STATUS, &compiled));
|
| - if (!compiled) {
|
| - GLC(context, context->deleteShader(shader));
|
| - return 0;
|
| - }
|
| + context->GetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
|
| + if (!compiled)
|
| + return 0u;
|
| #endif
|
| return shader;
|
| }
|
|
|
| -unsigned ProgramBindingBase::CreateShaderProgram(WebGraphicsContext3D* context,
|
| +unsigned ProgramBindingBase::CreateShaderProgram(GLES2Interface* context,
|
| unsigned vertex_shader,
|
| unsigned fragment_shader) {
|
| - unsigned program_object = context->createProgram();
|
| + unsigned program_object = context->CreateProgram();
|
| if (!program_object)
|
| return 0;
|
|
|
| - GLC(context, context->attachShader(program_object, vertex_shader));
|
| - GLC(context, context->attachShader(program_object, fragment_shader));
|
| + context->AttachShader(program_object, vertex_shader);
|
| + context->AttachShader(program_object, fragment_shader);
|
|
|
| // Bind the common attrib locations.
|
| - GLC(context,
|
| - context->bindAttribLocation(program_object,
|
| - GeometryBinding::PositionAttribLocation(),
|
| - "a_position"));
|
| - GLC(context,
|
| - context->bindAttribLocation(program_object,
|
| - GeometryBinding::TexCoordAttribLocation(),
|
| - "a_texCoord"));
|
| - GLC(context,
|
| - context->bindAttribLocation(
|
| - program_object,
|
| - GeometryBinding::TriangleIndexAttribLocation(),
|
| - "a_index"));
|
| + context->BindAttribLocation(
|
| + program_object, GeometryBinding::PositionAttribLocation(), "a_position");
|
| + context->BindAttribLocation(
|
| + program_object, GeometryBinding::TexCoordAttribLocation(), "a_texCoord");
|
| + context->BindAttribLocation(program_object,
|
| + GeometryBinding::TriangleIndexAttribLocation(),
|
| + "a_index");
|
|
|
| return program_object;
|
| }
|
|
|
| -void ProgramBindingBase::CleanupShaders(WebGraphicsContext3D* context) {
|
| +void ProgramBindingBase::CleanupShaders(GLES2Interface* context) {
|
| if (vertex_shader_id_) {
|
| - GLC(context, context->deleteShader(vertex_shader_id_));
|
| + context->DeleteShader(vertex_shader_id_);
|
| vertex_shader_id_ = 0;
|
| }
|
| if (fragment_shader_id_) {
|
| - GLC(context, context->deleteShader(fragment_shader_id_));
|
| + context->DeleteShader(fragment_shader_id_);
|
| fragment_shader_id_ = 0;
|
| }
|
| }
|
|
|