summaryrefslogtreecommitdiffstats
path: root/cc/output
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:14:11 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:14:11 +0000
commita99d82fff6f153284981a7c44b2f9303de31e012 (patch)
treeca979dfb00ce009718da7f837b13a3cdc7eaf118 /cc/output
parent18aa701dea5ef746a52ef43ee7f209abedb78182 (diff)
downloadchromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.zip
chromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.tar.gz
chromium_src-a99d82fff6f153284981a7c44b2f9303de31e012.tar.bz2
Use GLES2Interface for shaders and programs
This uses the gpu::gles2::GLES2Interface type in the gl renderer's shader and program code instead of WebGraphicsContext3D. For production code, the GLES2Interface is a direct interface to the real command buffer in use. For cc_unittests, the GLES2Interface is a stub that wraps TestWebGraphicsContext3D so we can continue to use the same stubs/mocks for now. Once we port all of the production code over to using GLES2Interface we should port the test context classes over to the new base interface. BUG=181120 Review URL: https://codereview.chromium.org/93433004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output')
-rw-r--r--cc/output/context_provider.h1
-rw-r--r--cc/output/gl_renderer.cc70
-rw-r--r--cc/output/gl_renderer.h8
-rw-r--r--cc/output/program_binding.cc84
-rw-r--r--cc/output/program_binding.h26
-rw-r--r--cc/output/shader.cc68
-rw-r--r--cc/output/shader.h64
-rw-r--r--cc/output/shader_unittest.cc27
8 files changed, 180 insertions, 168 deletions
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
index 09b1835..d615d17 100644
--- a/cc/output/context_provider.h
+++ b/cc/output/context_provider.h
@@ -11,6 +11,7 @@
#include "gpu/command_buffer/common/capabilities.h"
class GrContext;
+
namespace blink { class WebGraphicsContext3D; }
namespace gpu {
class ContextSupport;
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 89b8c04..15cb3a2 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -38,6 +38,7 @@
#include "cc/trees/single_thread_proxy.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/context_support.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
@@ -170,6 +171,7 @@ GLRenderer::GLRenderer(RendererClient* client,
offscreen_framebuffer_id_(0),
shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)),
context_(output_surface->context_provider()->Context3d()),
+ gl_(output_surface->context_provider()->ContextGL()),
context_support_(output_surface->context_provider()->ContextSupport()),
texture_mailbox_deleter_(texture_mailbox_deleter),
is_backbuffer_discarded_(false),
@@ -956,7 +958,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
}
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
int shader_quad_location = -1;
@@ -1462,7 +1464,7 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->texture_size);
gfx::Transform device_transform =
@@ -1605,7 +1607,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
SetBlendEnabled(quad->ShouldDrawWithBlending());
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
bool use_alpha_plane = quad->a_plane_resource_id != 0;
@@ -1718,7 +1720,7 @@ void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
DCHECK(capabilities_.using_egl_image);
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
const VideoStreamTextureProgram* program =
@@ -1900,7 +1902,7 @@ void GLRenderer::FlushTextureQuadCache() {
void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
const TextureDrawQuad* quad) {
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
// Choose the correct texture program binding
@@ -1965,7 +1967,7 @@ void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
SetBlendEnabled(quad->ShouldDrawWithBlending());
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
TexTransformTextureProgramBinding binding;
@@ -2097,7 +2099,7 @@ void GLRenderer::SetBlendEnabled(bool enabled) {
void GLRenderer::SetUseProgram(unsigned program) {
if (program == program_shadow_)
return;
- GLC(context_, context_->useProgram(program));
+ gl_->UseProgram(program);
program_shadow_ = program;
}
@@ -2121,7 +2123,7 @@ void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
const gfx::Transform& draw_matrix,
bool flip_vertically) {
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- context_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
rect.bottom_right());
const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision);
@@ -3016,39 +3018,39 @@ void GLRenderer::CleanupSharedObjects() {
for (int i = 0; i < NumTexCoordPrecisions; ++i) {
for (int j = 0; j < NumSamplerTypes; ++j) {
- tile_program_[i][j].Cleanup(context_);
- tile_program_opaque_[i][j].Cleanup(context_);
- tile_program_swizzle_[i][j].Cleanup(context_);
- tile_program_swizzle_opaque_[i][j].Cleanup(context_);
- tile_program_aa_[i][j].Cleanup(context_);
- tile_program_swizzle_aa_[i][j].Cleanup(context_);
+ tile_program_[i][j].Cleanup(gl_);
+ tile_program_opaque_[i][j].Cleanup(gl_);
+ tile_program_swizzle_[i][j].Cleanup(gl_);
+ tile_program_swizzle_opaque_[i][j].Cleanup(gl_);
+ tile_program_aa_[i][j].Cleanup(gl_);
+ tile_program_swizzle_aa_[i][j].Cleanup(gl_);
}
- render_pass_mask_program_[i].Cleanup(context_);
- render_pass_program_[i].Cleanup(context_);
- render_pass_mask_program_aa_[i].Cleanup(context_);
- render_pass_program_aa_[i].Cleanup(context_);
- render_pass_color_matrix_program_[i].Cleanup(context_);
- render_pass_mask_color_matrix_program_aa_[i].Cleanup(context_);
- render_pass_color_matrix_program_aa_[i].Cleanup(context_);
- render_pass_mask_color_matrix_program_[i].Cleanup(context_);
+ render_pass_mask_program_[i].Cleanup(gl_);
+ render_pass_program_[i].Cleanup(gl_);
+ render_pass_mask_program_aa_[i].Cleanup(gl_);
+ render_pass_program_aa_[i].Cleanup(gl_);
+ render_pass_color_matrix_program_[i].Cleanup(gl_);
+ render_pass_mask_color_matrix_program_aa_[i].Cleanup(gl_);
+ render_pass_color_matrix_program_aa_[i].Cleanup(gl_);
+ render_pass_mask_color_matrix_program_[i].Cleanup(gl_);
- texture_program_[i].Cleanup(context_);
- nonpremultiplied_texture_program_[i].Cleanup(context_);
- texture_background_program_[i].Cleanup(context_);
- nonpremultiplied_texture_background_program_[i].Cleanup(context_);
- texture_io_surface_program_[i].Cleanup(context_);
+ texture_program_[i].Cleanup(gl_);
+ nonpremultiplied_texture_program_[i].Cleanup(gl_);
+ texture_background_program_[i].Cleanup(gl_);
+ nonpremultiplied_texture_background_program_[i].Cleanup(gl_);
+ texture_io_surface_program_[i].Cleanup(gl_);
- video_yuv_program_[i].Cleanup(context_);
- video_yuva_program_[i].Cleanup(context_);
- video_stream_texture_program_[i].Cleanup(context_);
+ video_yuv_program_[i].Cleanup(gl_);
+ video_yuva_program_[i].Cleanup(gl_);
+ video_stream_texture_program_[i].Cleanup(gl_);
}
- tile_checkerboard_program_.Cleanup(context_);
+ tile_checkerboard_program_.Cleanup(gl_);
- debug_border_program_.Cleanup(context_);
- solid_color_program_.Cleanup(context_);
- solid_color_program_aa_.Cleanup(context_);
+ debug_border_program_.Cleanup(gl_);
+ solid_color_program_.Cleanup(gl_);
+ solid_color_program_aa_.Cleanup(gl_);
if (offscreen_framebuffer_id_)
GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_));
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index 85c0fa1..decb7d0 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -25,9 +25,14 @@ class SkBitmap;
namespace blink { class WebGraphicsContext3D; }
+namespace gpu {
+namespace gles2 {
+class GLES2Interface;
+}
+}
+
namespace cc {
-class ContextProvider;
class GLRendererShaderTest;
class OutputSurface;
class PictureDrawQuad;
@@ -398,6 +403,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
SolidColorProgramAA solid_color_program_aa_;
blink::WebGraphicsContext3D* context_;
+ gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_;
skia::RefPtr<GrContext> gr_context_;
diff --git a/cc/output/program_binding.cc b/cc/output/program_binding.cc
index 210dc76..9152e5a 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;
}
}
diff --git a/cc/output/program_binding.h b/cc/output/program_binding.h
index 4a75a01..912329e 100644
--- a/cc/output/program_binding.h
+++ b/cc/output/program_binding.h
@@ -11,7 +11,11 @@
#include "cc/output/context_provider.h"
#include "cc/output/shader.h"
-namespace blink { class WebGraphicsContext3D; }
+namespace gpu {
+namespace gles2 {
+class GLES2Interface;
+}
+}
namespace cc {
@@ -20,23 +24,23 @@ class ProgramBindingBase {
ProgramBindingBase();
~ProgramBindingBase();
- bool Init(blink::WebGraphicsContext3D* context,
+ bool Init(gpu::gles2::GLES2Interface* context,
const std::string& vertex_shader,
const std::string& fragment_shader);
- bool Link(blink::WebGraphicsContext3D* context);
- void Cleanup(blink::WebGraphicsContext3D* context);
+ bool Link(gpu::gles2::GLES2Interface* context);
+ void Cleanup(gpu::gles2::GLES2Interface* context);
unsigned program() const { return program_; }
bool initialized() const { return initialized_; }
protected:
- unsigned LoadShader(blink::WebGraphicsContext3D* context,
+ unsigned LoadShader(gpu::gles2::GLES2Interface* context,
unsigned type,
const std::string& shader_source);
- unsigned CreateShaderProgram(blink::WebGraphicsContext3D* context,
+ unsigned CreateShaderProgram(gpu::gles2::GLES2Interface* context,
unsigned vertex_shader,
unsigned fragment_shader);
- void CleanupShaders(blink::WebGraphicsContext3D* context);
+ void CleanupShaders(gpu::gles2::GLES2Interface* context);
unsigned program_;
unsigned vertex_shader_id_;
@@ -62,7 +66,7 @@ class ProgramBinding : public ProgramBindingBase {
return;
if (!ProgramBindingBase::Init(
- context_provider->Context3d(),
+ context_provider->ContextGL(),
vertex_shader_.GetShaderString(),
fragment_shader_.GetShaderString(precision, sampler))) {
DCHECK(context_provider->IsContextLost());
@@ -70,13 +74,13 @@ class ProgramBinding : public ProgramBindingBase {
}
int base_uniform_index = 0;
- vertex_shader_.Init(context_provider->Context3d(),
+ vertex_shader_.Init(context_provider->ContextGL(),
program_, &base_uniform_index);
- fragment_shader_.Init(context_provider->Context3d(),
+ fragment_shader_.Init(context_provider->ContextGL(),
program_, &base_uniform_index);
// Link after binding uniforms
- if (!Link(context_provider->Context3d())) {
+ if (!Link(context_provider->ContextGL())) {
DCHECK(context_provider->IsContextLost());
return;
}
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index 501c00d..b752f46 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/logging.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"
#define SHADER0(Src) #Src
@@ -17,13 +17,13 @@
#define FRAGMENT_SHADER(Src) SetFragmentTexCoordPrecision( \
precision, SetFragmentSamplerType(sampler, SHADER0(Src)))
-using blink::WebGraphicsContext3D;
+using gpu::gles2::GLES2Interface;
namespace cc {
namespace {
-static void GetProgramUniformLocations(WebGraphicsContext3D* context,
+static void GetProgramUniformLocations(GLES2Interface* context,
unsigned program,
size_t count,
const char** uniforms,
@@ -31,7 +31,7 @@ static void GetProgramUniformLocations(WebGraphicsContext3D* context,
int* base_uniform_index) {
for (size_t i = 0; i < count; i++) {
locations[i] = (*base_uniform_index)++;
- context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]);
+ context->BindUniformLocationCHROMIUM(program, locations[i], uniforms[i]);
}
}
@@ -72,7 +72,7 @@ static std::string SetVertexTexCoordPrecision(const char* shader_string) {
std::string(shader_string);
}
-TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
+TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
int *highp_threshold_cache,
int highp_threshold_min,
int x, int y) {
@@ -83,7 +83,7 @@ TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
// everywhere.
GLint range[2] = { 14, 14 };
GLint precision = 10;
- GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER,
+ GLC(context, context->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER,
GL_MEDIUM_FLOAT,
range, &precision));
*highp_threshold_cache = 1 << precision;
@@ -134,7 +134,7 @@ static std::string SetFragmentSamplerType(
} // namespace
-TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
+TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
int *highp_threshold_cache,
int highp_threshold_min,
gfx::Point max_coordinate) {
@@ -143,7 +143,7 @@ TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
max_coordinate.x(), max_coordinate.y());
}
-TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
+TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
int *highp_threshold_cache,
int highp_threshold_min,
gfx::Size max_size) {
@@ -155,7 +155,7 @@ TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
VertexShaderPosTex::VertexShaderPosTex()
: matrix_location_(-1) {}
-void VertexShaderPosTex::Init(WebGraphicsContext3D* context,
+void VertexShaderPosTex::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -189,7 +189,7 @@ VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
: matrix_location_(-1),
tex_scale_location_(-1) {}
-void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context,
+void VertexShaderPosTexYUVStretch::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -226,7 +226,7 @@ std::string VertexShaderPosTexYUVStretch::GetShaderString() const {
VertexShaderPos::VertexShaderPos()
: matrix_location_(-1) {}
-void VertexShaderPos::Init(WebGraphicsContext3D* context,
+void VertexShaderPos::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -258,7 +258,7 @@ VertexShaderPosTexTransform::VertexShaderPosTexTransform()
tex_transform_location_(-1),
vertex_opacity_location_(-1) {}
-void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context,
+void VertexShaderPosTexTransform::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -314,7 +314,7 @@ VertexShaderQuad::VertexShaderQuad()
: matrix_location_(-1),
quad_location_(-1) {}
-void VertexShaderQuad::Init(WebGraphicsContext3D* context,
+void VertexShaderQuad::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -371,7 +371,7 @@ VertexShaderQuadAA::VertexShaderQuadAA()
quad_location_(-1),
edge_location_(-1) {}
-void VertexShaderQuadAA::Init(WebGraphicsContext3D* context,
+void VertexShaderQuadAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -428,7 +428,7 @@ VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA()
edge_location_(-1),
tex_transform_location_(-1) {}
-void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context,
+void VertexShaderQuadTexTransformAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -488,7 +488,7 @@ VertexShaderTile::VertexShaderTile()
quad_location_(-1),
vertex_tex_transform_location_(-1) {}
-void VertexShaderTile::Init(WebGraphicsContext3D* context,
+void VertexShaderTile::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -532,7 +532,7 @@ VertexShaderTileAA::VertexShaderTileAA()
edge_location_(-1),
vertex_tex_transform_location_(-1) {}
-void VertexShaderTileAA::Init(WebGraphicsContext3D* context,
+void VertexShaderTileAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -591,7 +591,7 @@ VertexShaderVideoTransform::VertexShaderVideoTransform()
: matrix_location_(-1),
tex_matrix_location_(-1) {}
-void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context,
+void VertexShaderVideoTransform::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -629,7 +629,7 @@ FragmentTexAlphaBinding::FragmentTexAlphaBinding()
: sampler_location_(-1),
alpha_location_(-1) {}
-void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context,
+void FragmentTexAlphaBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -654,7 +654,7 @@ FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding()
color_matrix_location_(-1),
color_offset_location_(-1) {}
-void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context,
+void FragmentTexColorMatrixAlphaBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -680,7 +680,7 @@ void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context,
FragmentTexOpaqueBinding::FragmentTexOpaqueBinding()
: sampler_location_(-1) {}
-void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context,
+void FragmentTexOpaqueBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -766,7 +766,7 @@ FragmentTexBackgroundBinding::FragmentTexBackgroundBinding()
sampler_location_(-1) {
}
-void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context,
+void FragmentTexBackgroundBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -879,7 +879,7 @@ FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA()
: sampler_location_(-1),
alpha_location_(-1) {}
-void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context,
+void FragmentShaderRGBATexAlphaAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -922,7 +922,7 @@ FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding()
alpha_location_(-1),
fragment_tex_transform_location_(-1) {}
-void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context,
+void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -996,7 +996,7 @@ FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask()
alpha_location_(-1),
mask_tex_coord_scale_location_(-1) {}
-void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context,
+void FragmentShaderRGBATexAlphaMask::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1049,7 +1049,7 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
mask_tex_coord_scale_location_(-1),
mask_tex_coord_offset_location_(-1) {}
-void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context,
+void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1110,7 +1110,7 @@ FragmentShaderRGBATexAlphaMaskColorMatrixAA::
color_offset_location_(-1) {}
void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init(
- WebGraphicsContext3D* context,
+ GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1180,7 +1180,7 @@ FragmentShaderRGBATexAlphaColorMatrixAA::
color_offset_location_(-1) {}
void FragmentShaderRGBATexAlphaColorMatrixAA::Init(
- WebGraphicsContext3D* context,
+ GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1237,7 +1237,7 @@ FragmentShaderRGBATexAlphaMaskColorMatrix::
mask_tex_coord_scale_location_(-1) {}
void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(
- WebGraphicsContext3D* context,
+ GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1302,7 +1302,7 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo()
yuv_matrix_location_(-1),
yuv_adj_location_(-1) {}
-void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context,
+void FragmentShaderYUVVideo::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1362,7 +1362,7 @@ FragmentShaderYUVAVideo::FragmentShaderYUVAVideo()
yuv_adj_location_(-1) {
}
-void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context,
+void FragmentShaderYUVAVideo::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1419,7 +1419,7 @@ std::string FragmentShaderYUVAVideo::GetShaderString(
FragmentShaderColor::FragmentShaderColor()
: color_location_(-1) {}
-void FragmentShaderColor::Init(WebGraphicsContext3D* context,
+void FragmentShaderColor::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1450,7 +1450,7 @@ std::string FragmentShaderColor::GetShaderString(
FragmentShaderColorAA::FragmentShaderColorAA()
: color_location_(-1) {}
-void FragmentShaderColorAA::Init(WebGraphicsContext3D* context,
+void FragmentShaderColorAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
@@ -1488,7 +1488,7 @@ FragmentShaderCheckerboard::FragmentShaderCheckerboard()
tex_transform_location_(-1),
frequency_location_(-1) {}
-void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context,
+void FragmentShaderCheckerboard::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
diff --git a/cc/output/shader.h b/cc/output/shader.h
index 986e6d9..9473ce8 100644
--- a/cc/output/shader.h
+++ b/cc/output/shader.h
@@ -16,7 +16,11 @@ class Point;
class Size;
}
-namespace blink { class WebGraphicsContext3D; }
+namespace gpu {
+namespace gles2 {
+class GLES2Interface;
+}
+}
namespace cc {
@@ -40,13 +44,13 @@ enum SamplerType {
// The caller must make sure to clear highp_threshold_cache to 0, so it can be
// reinitialized, if a new or different context is used.
CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired(
- blink::WebGraphicsContext3D* context,
+ gpu::gles2::GLES2Interface* context,
int *highp_threshold_cache,
int highp_threshold_min,
gfx::Point max_coordinate);
CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired(
- blink::WebGraphicsContext3D* context,
+ gpu::gles2::GLES2Interface* context,
int *highp_threshold_cache,
int highp_threshold_min,
gfx::Size max_size);
@@ -55,7 +59,7 @@ class VertexShaderPosTex {
public:
VertexShaderPosTex();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -72,7 +76,7 @@ class VertexShaderPosTexYUVStretch {
public:
VertexShaderPosTexYUVStretch();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -91,7 +95,7 @@ class VertexShaderPos {
public:
VertexShaderPos();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -106,7 +110,7 @@ class VertexShaderPos {
class VertexShaderPosTexIdentity {
public:
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index) {}
std::string GetShaderString() const;
@@ -116,7 +120,7 @@ class VertexShaderPosTexTransform {
public:
VertexShaderPosTexTransform();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -137,7 +141,7 @@ class VertexShaderQuad {
public:
VertexShaderQuad();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -158,7 +162,7 @@ class VertexShaderQuadAA {
public:
VertexShaderQuadAA();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -182,7 +186,7 @@ class VertexShaderQuadTexTransformAA {
public:
VertexShaderQuadTexTransformAA();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -207,7 +211,7 @@ class VertexShaderTile {
public:
VertexShaderTile();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -232,7 +236,7 @@ class VertexShaderTileAA {
public:
VertexShaderTileAA();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -259,7 +263,7 @@ class VertexShaderVideoTransform {
public:
VertexShaderVideoTransform();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString() const;
@@ -278,7 +282,7 @@ class FragmentTexAlphaBinding {
public:
FragmentTexAlphaBinding();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -296,7 +300,7 @@ class FragmentTexColorMatrixAlphaBinding {
public:
FragmentTexColorMatrixAlphaBinding();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -316,7 +320,7 @@ class FragmentTexOpaqueBinding {
public:
FragmentTexOpaqueBinding();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return -1; }
@@ -334,7 +338,7 @@ class FragmentTexBackgroundBinding {
public:
FragmentTexBackgroundBinding();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int background_color_location() const { return background_color_location_; }
@@ -416,7 +420,7 @@ class FragmentShaderRGBATexAlphaAA {
public:
FragmentShaderRGBATexAlphaAA();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
std::string GetShaderString(
@@ -436,7 +440,7 @@ class FragmentTexClampAlphaAABinding {
public:
FragmentTexClampAlphaAABinding();
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -474,7 +478,7 @@ class FragmentShaderRGBATexAlphaMask {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -503,7 +507,7 @@ class FragmentShaderRGBATexAlphaMaskAA {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -532,7 +536,7 @@ class FragmentShaderRGBATexAlphaMaskColorMatrixAA {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -563,7 +567,7 @@ class FragmentShaderRGBATexAlphaColorMatrixAA {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -584,7 +588,7 @@ class FragmentShaderRGBATexAlphaMaskColorMatrix {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
@@ -615,7 +619,7 @@ class FragmentShaderYUVVideo {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int y_texture_location() const { return y_texture_location_; }
@@ -643,7 +647,7 @@ class FragmentShaderYUVAVideo {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
@@ -673,7 +677,7 @@ class FragmentShaderColor {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int color_location() const { return color_location_; }
@@ -690,7 +694,7 @@ class FragmentShaderColorAA {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int color_location() const { return color_location_; }
@@ -707,7 +711,7 @@ class FragmentShaderCheckerboard {
std::string GetShaderString(
TexCoordPrecision precision, SamplerType sampler) const;
- void Init(blink::WebGraphicsContext3D* context,
+ void Init(gpu::gles2::GLES2Interface* context,
unsigned program,
int* base_uniform_index);
int alpha_location() const { return alpha_location_; }
diff --git a/cc/output/shader_unittest.cc b/cc/output/shader_unittest.cc
index a608d93..4aacbf7 100644
--- a/cc/output/shader_unittest.cc
+++ b/cc/output/shader_unittest.cc
@@ -4,7 +4,8 @@
#include "cc/output/shader.h"
-#include "cc/test/fake_web_graphics_context_3d.h"
+#include "cc/test/test_gles2_interface.h"
+#include "cc/test/test_web_graphics_context_3d.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/point.h"
#include "ui/gfx/size.h"
@@ -12,9 +13,11 @@
namespace cc {
TEST(ShaderTest, HighpThresholds) {
- // The FakeWebGraphicsContext3D always uses a mediump precision of 10 bits
- // which corresponds to a native highp threshold of 2^10 = 1024
- FakeWebGraphicsContext3D context;
+ // The test context always uses a mediump precision of 10 bits which
+ // corresponds to a native highp threshold of 2^10 = 1024
+ scoped_ptr<TestWebGraphicsContext3D> stub_context =
+ TestWebGraphicsContext3D::Create();
+ TestGLES2Interface stub_gl(stub_context.get());
int threshold_cache = 0;
int threshold_min;
@@ -25,23 +28,23 @@ TEST(ShaderTest, HighpThresholds) {
threshold_min = 0;
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, closePoint));
+ &stub_gl, &threshold_cache, threshold_min, closePoint));
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, smallSize));
+ &stub_gl, &threshold_cache, threshold_min, smallSize));
EXPECT_EQ(TexCoordPrecisionHigh, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, farPoint));
+ &stub_gl, &threshold_cache, threshold_min, farPoint));
EXPECT_EQ(TexCoordPrecisionHigh, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, bigSize));
+ &stub_gl, &threshold_cache, threshold_min, bigSize));
threshold_min = 3000;
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, closePoint));
+ &stub_gl, &threshold_cache, threshold_min, closePoint));
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, smallSize));
+ &stub_gl, &threshold_cache, threshold_min, smallSize));
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, farPoint));
+ &stub_gl, &threshold_cache, threshold_min, farPoint));
EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired(
- &context, &threshold_cache, threshold_min, bigSize));
+ &stub_gl, &threshold_cache, threshold_min, bigSize));
}
} // namespace cc