Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: cc/output/gl_renderer.cc

Issue 105553003: Use GLES2Interface in GLRenderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/test/test_gles2_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 51141daac63e5939d80b179eaef86b197faa6dae..473df993104d4d4dc71cdb511dea86dc285ee041 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -56,6 +56,7 @@
#include "ui/gfx/rect_conversions.h"
using blink::WebGraphicsContext3D;
+using gpu::gles2::GLES2Interface;
namespace cc {
@@ -73,6 +74,7 @@ class SimpleSwapFence : public ResourceProvider::Fence {
SimpleSwapFence() : has_passed_(false) {}
virtual bool HasPassed() OVERRIDE { return has_passed_; }
void SetHasPassed() { has_passed_ = true; }
+
private:
virtual ~SimpleSwapFence() {}
bool has_passed_;
@@ -91,7 +93,7 @@ bool NeedsIOSurfaceReadbackWorkaround() {
Float4 UVTransform(const TextureDrawQuad* quad) {
gfx::PointF uv0 = quad->uv_top_left;
gfx::PointF uv1 = quad->uv_bottom_right;
- Float4 xform = { { uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y() } };
+ Float4 xform = {{uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}};
if (quad->flipped) {
xform.data[1] = 1.0f - xform.data[1];
xform.data[3] = -xform.data[3];
@@ -103,12 +105,9 @@ Float4 PremultipliedColor(SkColor color) {
const float factor = 1.0f / 255.0f;
const float alpha = SkColorGetA(color) * factor;
- Float4 result = { {
- SkColorGetR(color) * factor * alpha,
- SkColorGetG(color) * factor * alpha,
- SkColorGetB(color) * factor * alpha,
- alpha
- } };
+ Float4 result = {
+ {SkColorGetR(color) * factor * alpha, SkColorGetG(color) * factor * alpha,
+ SkColorGetB(color) * factor * alpha, alpha}};
return result;
}
@@ -184,7 +183,7 @@ GLRenderer::GLRenderer(RendererClient* client,
DCHECK(context_support_);
ContextProvider::Capabilities context_caps =
- output_surface_->context_provider()->ContextCapabilities();
+ output_surface_->context_provider()->ContextCapabilities();
capabilities_.using_partial_swap =
settings_->partial_swap_enabled && context_caps.post_sub_buffer;
@@ -208,8 +207,7 @@ GLRenderer::GLRenderer(RendererClient* client,
capabilities_.using_map_image =
settings_->use_map_image && context_caps.map_image;
- capabilities_.using_discard_framebuffer =
- context_caps.discard_framebuffer;
+ capabilities_.using_discard_framebuffer = context_caps.discard_framebuffer;
InitializeSharedObjects();
}
@@ -230,11 +228,11 @@ const RendererCapabilities& GLRenderer::Capabilities() const {
WebGraphicsContext3D* GLRenderer::Context() { return context_; }
-void GLRenderer::DebugGLCall(WebGraphicsContext3D* context,
+void GLRenderer::DebugGLCall(GLES2Interface* gl,
const char* command,
const char* file,
int line) {
- unsigned error = context->getError();
+ GLuint error = gl->GetError();
if (error != GL_NO_ERROR)
LOG(ERROR) << "GL command failed: File: " << file << "\n\tLine " << line
<< "\n\tcommand: " << command << ", error "
@@ -274,7 +272,7 @@ void GLRenderer::DiscardPixels(bool has_external_stencil_test,
output_surface_->capabilities().uses_default_gl_framebuffer;
GLenum attachments[] = {static_cast<GLenum>(
using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)};
- context_->discardFramebufferEXT(
+ gl_->DiscardFramebufferEXT(
GL_FRAMEBUFFER, arraysize(attachments), attachments);
}
@@ -290,9 +288,9 @@ void GLRenderer::ClearFramebuffer(DrawingFrame* frame,
// On DEBUG builds, opaque render passes are cleared to blue to easily see
// regions that were not drawn on the screen.
if (frame->current_render_pass->has_transparent_background)
- GLC(context_, context_->clearColor(0, 0, 0, 0));
+ GLC(gl_, gl_->ClearColor(0, 0, 0, 0));
else
- GLC(context_, context_->clearColor(0, 0, 1, 1));
+ GLC(gl_, gl_->ClearColor(0, 0, 1, 1));
bool always_clear = false;
#ifndef NDEBUG
@@ -302,7 +300,7 @@ void GLRenderer::ClearFramebuffer(DrawingFrame* frame,
GLbitfield clear_bits = GL_COLOR_BUFFER_BIT;
if (always_clear)
clear_bits |= GL_STENCIL_BUFFER_BIT;
- context_->clear(clear_bits);
+ gl_->Clear(clear_bits);
}
}
@@ -316,8 +314,8 @@ void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) {
}
void GLRenderer::DoNoOp() {
- GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0));
- GLC(context_, context_->flush());
+ GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
+ GLC(gl_, gl_->Flush());
}
void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) {
@@ -372,12 +370,12 @@ void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
SetUseProgram(program->program());
SkColor color = quad->color;
- GLC(Context(),
- Context()->uniform4f(program->fragment_shader().color_location(),
- SkColorGetR(color) * (1.0f / 255.0f),
- SkColorGetG(color) * (1.0f / 255.0f),
- SkColorGetB(color) * (1.0f / 255.0f),
- 1));
+ GLC(gl_,
+ gl_->Uniform4f(program->fragment_shader().color_location(),
+ SkColorGetR(color) * (1.0f / 255.0f),
+ SkColorGetG(color) * (1.0f / 255.0f),
+ SkColorGetB(color) * (1.0f / 255.0f),
+ 1));
const int checkerboard_width = 16;
float frequency = 1.0f / checkerboard_width;
@@ -387,16 +385,16 @@ void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
float tex_offset_y = tile_rect.y() % checkerboard_width;
float tex_scale_x = tile_rect.width();
float tex_scale_y = tile_rect.height();
- GLC(Context(),
- Context()->uniform4f(program->fragment_shader().tex_transform_location(),
- tex_offset_x,
- tex_offset_y,
- tex_scale_x,
- tex_scale_y));
+ GLC(gl_,
+ gl_->Uniform4f(program->fragment_shader().tex_transform_location(),
+ tex_offset_x,
+ tex_offset_y,
+ tex_scale_x,
+ tex_scale_y));
- GLC(Context(),
- Context()->uniform1f(program->fragment_shader().frequency_location(),
- frequency));
+ GLC(gl_,
+ gl_->Uniform1f(program->fragment_shader().frequency_location(),
+ frequency));
SetShaderOpacity(quad->opacity(),
program->fragment_shader().alpha_location());
@@ -424,26 +422,25 @@ void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
render_matrix.Scale(layer_rect.width(), layer_rect.height());
GLRenderer::ToGLMatrix(&gl_matrix[0],
frame->projection_matrix * render_matrix);
- GLC(Context(),
- Context()->uniformMatrix4fv(
+ GLC(gl_,
+ gl_->UniformMatrix4fv(
program->vertex_shader().matrix_location(), 1, false, &gl_matrix[0]));
SkColor color = quad->color;
float alpha = SkColorGetA(color) * (1.0f / 255.0f);
- GLC(Context(),
- Context()->uniform4f(program->fragment_shader().color_location(),
- (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
- (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
- (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
- alpha));
+ GLC(gl_,
+ gl_->Uniform4f(program->fragment_shader().color_location(),
+ (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
+ (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
+ (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
+ alpha));
- GLC(Context(), Context()->lineWidth(quad->width));
+ GLC(gl_, gl_->LineWidth(quad->width));
// The indices for the line are stored in the same array as the triangle
// indices.
- GLC(Context(),
- Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
+ GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
}
static SkBitmap ApplyImageFilter(GLRenderer* renderer,
@@ -720,9 +717,8 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
{
ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
device_background_texture->id());
- GetFramebufferTexture(lock.texture_id(),
- device_background_texture->format(),
- window_rect);
+ GetFramebufferTexture(
+ lock.texture_id(), device_background_texture->format(), window_rect);
}
skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
@@ -773,8 +769,8 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
contents_device_transform_inverse);
#ifndef NDEBUG
- GLC(Context(), Context()->clearColor(0, 0, 1, 1));
- Context()->clear(GL_COLOR_BUFFER_BIT);
+ GLC(gl_, gl_->ClearColor(0, 0, 1, 1));
+ gl_->Clear(GL_COLOR_BUFFER_BIT);
#endif
// The filtered_deveice_background_texture is oriented the same as the frame
@@ -910,10 +906,10 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
LayerQuad device_layer_edges(device_quad);
// Use anti-aliasing programs only when necessary.
- bool use_aa = !clipped &&
- (!device_quad.IsRectilinear() ||
- !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
- kAntiAliasingEpsilon));
+ bool use_aa =
+ !clipped && (!device_quad.IsRectilinear() ||
+ !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
+ kAntiAliasingEpsilon));
if (use_aa) {
device_layer_bounds.InflateAntiAliasingDistance();
device_layer_edges.InflateAntiAliasingDistance();
@@ -935,18 +931,19 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GrTexture* texture =
reinterpret_cast<GrTexture*>(filter_bitmap.getTexture());
DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
- Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
+ gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
} else {
- contents_resource_lock = make_scoped_ptr(
- new ResourceProvider::ScopedSamplerGL(resource_provider_,
- contents_texture->id(),
- GL_LINEAR));
+ contents_resource_lock =
+ make_scoped_ptr(new ResourceProvider::ScopedSamplerGL(
+ resource_provider_, contents_texture->id(), GL_LINEAR));
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
contents_resource_lock->target());
}
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &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;
@@ -965,8 +962,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassMaskProgramAA* program =
GetRenderPassMaskProgramAA(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_quad_location = program->vertex_shader().quad_location();
shader_edge_location = program->vertex_shader().edge_location();
@@ -985,8 +981,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassMaskProgram* program =
GetRenderPassMaskProgram(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_mask_sampler_location =
program->fragment_shader().mask_sampler_location();
@@ -1002,8 +997,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassProgramAA* program =
GetRenderPassProgramAA(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_quad_location = program->vertex_shader().quad_location();
shader_edge_location = program->vertex_shader().edge_location();
@@ -1016,8 +1010,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassMaskColorMatrixProgramAA* program =
GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_matrix_location = program->vertex_shader().matrix_location();
shader_quad_location = program->vertex_shader().quad_location();
@@ -1040,8 +1033,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassColorMatrixProgramAA* program =
GetRenderPassColorMatrixProgramAA(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_matrix_location = program->vertex_shader().matrix_location();
shader_quad_location = program->vertex_shader().quad_location();
@@ -1058,8 +1050,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassMaskColorMatrixProgram* program =
GetRenderPassMaskColorMatrixProgram(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_matrix_location = program->vertex_shader().matrix_location();
shader_tex_transform_location =
@@ -1079,8 +1070,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassColorMatrixProgram* program =
GetRenderPassColorMatrixProgram(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_matrix_location = program->vertex_shader().matrix_location();
shader_tex_transform_location =
@@ -1094,8 +1084,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
const RenderPassProgram* program =
GetRenderPassProgram(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
shader_matrix_location = program->vertex_shader().matrix_location();
shader_alpha_location = program->fragment_shader().alpha_location();
@@ -1113,17 +1102,18 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
// Flip the content vertically in the shader, as the RenderPass input
// texture is already oriented the same way as the framebuffer, but the
// projection transform does a flip.
- GLC(Context(), Context()->uniform4f(shader_tex_transform_location,
- 0.0f,
- tex_scale_y,
- tex_scale_x,
- -tex_scale_y));
+ GLC(gl_,
+ gl_->Uniform4f(shader_tex_transform_location,
+ 0.0f,
+ tex_scale_y,
+ tex_scale_x,
+ -tex_scale_y));
scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock;
if (shader_mask_sampler_location != -1) {
DCHECK_NE(shader_mask_tex_coord_scale_location, 1);
DCHECK_NE(shader_mask_tex_coord_offset_location, 1);
- GLC(Context(), Context()->uniform1i(shader_mask_sampler_location, 1));
+ GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1));
float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x;
float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y;
@@ -1131,15 +1121,14 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
// Mask textures are oriented vertically flipped relative to the framebuffer
// and the RenderPass contents texture, so we flip the tex coords from the
// RenderPass texture to find the mask texture coords.
- GLC(Context(),
- Context()->uniform2f(
- shader_mask_tex_coord_offset_location,
- quad->mask_uv_rect.x(),
- quad->mask_uv_rect.y() + quad->mask_uv_rect.height()));
- GLC(Context(),
- Context()->uniform2f(shader_mask_tex_coord_scale_location,
- mask_tex_scale_x,
- -mask_tex_scale_y));
+ GLC(gl_,
+ gl_->Uniform2f(shader_mask_tex_coord_offset_location,
+ quad->mask_uv_rect.x(),
+ quad->mask_uv_rect.y() + quad->mask_uv_rect.height()));
+ GLC(gl_,
+ gl_->Uniform2f(shader_mask_tex_coord_scale_location,
+ mask_tex_scale_x,
+ -mask_tex_scale_y));
shader_mask_sampler_lock = make_scoped_ptr(
new ResourceProvider::ScopedSamplerGL(resource_provider_,
quad->mask_resource_id,
@@ -1153,18 +1142,15 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
float edge[24];
device_layer_edges.ToFloatArray(edge);
device_layer_bounds.ToFloatArray(&edge[12]);
- GLC(Context(), Context()->uniform3fv(shader_edge_location, 8, edge));
+ GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge));
}
if (shader_viewport_location != -1) {
- float viewport[4] = {
- static_cast<float>(viewport_.x()),
- static_cast<float>(viewport_.y()),
- static_cast<float>(viewport_.width()),
- static_cast<float>(viewport_.height()),
- };
- GLC(Context(),
- Context()->uniform4fv(shader_viewport_location, 1, viewport));
+ float viewport[4] = {static_cast<float>(viewport_.x()),
+ static_cast<float>(viewport_.y()),
+ static_cast<float>(viewport_.width()),
+ static_cast<float>(viewport_.height()), };
+ GLC(gl_, gl_->Uniform4fv(shader_viewport_location, 1, viewport));
}
if (shader_color_matrix_location != -1) {
@@ -1173,9 +1159,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
for (int j = 0; j < 4; ++j)
matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]);
}
- GLC(Context(),
- Context()->uniformMatrix4fv(
- shader_color_matrix_location, 1, false, matrix));
+ GLC(gl_,
+ gl_->UniformMatrix4fv(shader_color_matrix_location, 1, false, matrix));
}
static const float kScale = 1.0f / 255.0f;
if (shader_color_offset_location != -1) {
@@ -1183,8 +1168,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
for (int i = 0; i < 4; ++i)
offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale;
- GLC(Context(),
- Context()->uniform4fv(shader_color_offset_location, 1, offset));
+ GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset));
}
// Map device space quad to surface space. contents_device_transform has no 3d
@@ -1201,7 +1185,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
// Flush the compositor context before the filter bitmap goes out of
// scope, so the draw gets processed before the filter texture gets deleted.
if (filter_bitmap.getTexture())
- GLC(context_, context_->flush());
+ GLC(gl_, gl_->Flush());
}
struct SolidColorProgramUniforms {
@@ -1213,7 +1197,7 @@ struct SolidColorProgramUniforms {
unsigned color_location;
};
-template<class T>
+template <class T>
static void SolidColorUniformLocation(T program,
SolidColorProgramUniforms* uniforms) {
uniforms->program = program->program();
@@ -1237,7 +1221,8 @@ bool GLRenderer::SetupQuadForAntialiasing(
device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped);
bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear();
- bool is_nearest_rect_within_epsilon = is_axis_aligned_in_target &&
+ bool is_nearest_rect_within_epsilon =
+ is_axis_aligned_in_target &&
gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(),
kAntiAliasingEpsilon);
// AAing clipped quads is not supported by the code yet.
@@ -1296,8 +1281,7 @@ bool GLRenderer::SetupQuadForAntialiasing(
// Map device space quad to local space. device_transform has no 3d
// component since it was flattened, so we don't need to project. We should
// have already checked that the transform was uninvertible above.
- gfx::Transform inverse_device_transform(
- gfx::Transform::kSkipInitialization);
+ gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization);
bool did_invert = device_transform.GetInverse(&inverse_device_transform);
DCHECK(did_invert);
*local_quad = MathUtil::MapQuad(
@@ -1341,22 +1325,19 @@ void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
SetUseProgram(uniforms.program);
- GLC(Context(),
- Context()->uniform4f(uniforms.color_location,
- (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
- (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
- (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
- alpha));
+ GLC(gl_,
+ gl_->Uniform4f(uniforms.color_location,
+ (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
+ (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
+ (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
+ alpha));
if (use_aa) {
- float viewport[4] = {
- static_cast<float>(viewport_.x()),
- static_cast<float>(viewport_.y()),
- static_cast<float>(viewport_.width()),
- static_cast<float>(viewport_.height()),
- };
- GLC(Context(),
- Context()->uniform4fv(uniforms.viewport_location, 1, viewport));
- GLC(Context(), Context()->uniform3fv(uniforms.edge_location, 8, edge));
+ float viewport[4] = {static_cast<float>(viewport_.x()),
+ static_cast<float>(viewport_.y()),
+ static_cast<float>(viewport_.width()),
+ static_cast<float>(viewport_.height()), };
+ GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
+ GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
}
// Enable blending when the quad properties require it or if we decided
@@ -1372,11 +1353,11 @@ void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
// un-antialiased quad should have and which vertex this is and the float
// quad passed in via uniform is the actual geometry that gets used to draw
// it. This is why this centered rect is used and not the original quad_rect.
- gfx::RectF centered_rect(gfx::PointF(-0.5f * tile_rect.width(),
- -0.5f * tile_rect.height()),
- tile_rect.size());
- DrawQuadGeometry(frame, quad->quadTransform(),
- centered_rect, uniforms.matrix_location);
+ gfx::RectF centered_rect(
+ gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
+ tile_rect.size());
+ DrawQuadGeometry(
+ frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
}
struct TileProgramUniforms {
@@ -1431,16 +1412,16 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
// is mapped to the unit square by the vertex shader and mapped
// back to normalized texture coordinates by the fragment shader
// after being clamped to 0-1 range.
- float tex_clamp_x = std::min(
- 0.5f, 0.5f * clamp_tex_rect.width() - kAntiAliasingEpsilon);
- float tex_clamp_y = std::min(
- 0.5f, 0.5f * clamp_tex_rect.height() - kAntiAliasingEpsilon);
- float geom_clamp_x = std::min(
- tex_clamp_x * tex_to_geom_scale_x,
- 0.5f * clamp_geom_rect.width() - kAntiAliasingEpsilon);
- float geom_clamp_y = std::min(
- tex_clamp_y * tex_to_geom_scale_y,
- 0.5f * clamp_geom_rect.height() - kAntiAliasingEpsilon);
+ float tex_clamp_x =
+ std::min(0.5f, 0.5f * clamp_tex_rect.width() - kAntiAliasingEpsilon);
+ float tex_clamp_y =
+ std::min(0.5f, 0.5f * clamp_tex_rect.height() - kAntiAliasingEpsilon);
+ float geom_clamp_x =
+ std::min(tex_clamp_x * tex_to_geom_scale_x,
+ 0.5f * clamp_geom_rect.width() - kAntiAliasingEpsilon);
+ float geom_clamp_y =
+ std::min(tex_clamp_y * tex_to_geom_scale_y,
+ 0.5f * clamp_geom_rect.height() - kAntiAliasingEpsilon);
clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y);
clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y);
@@ -1452,8 +1433,7 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &highp_threshold_cache_, highp_threshold_min_,
- quad->texture_size);
+ gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
gfx::Transform device_transform =
frame->window_matrix * frame->projection_matrix * quad->quadTransform();
@@ -1463,18 +1443,19 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
float edge[24];
- bool use_aa = settings_->allow_antialiasing && SetupQuadForAntialiasing(
- device_transform, quad, &local_quad, edge);
+ bool use_aa =
+ settings_->allow_antialiasing &&
+ SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
GLenum filter = (use_aa || scaled ||
!quad->quadTransform().IsIdentityOrIntegerTranslation())
- ? GL_LINEAR
- : GL_NEAREST;
+ ? GL_LINEAR
+ : GL_NEAREST;
ResourceProvider::ScopedSamplerGL quad_resource_lock(
resource_provider_, resource_id, filter);
- SamplerType sampler = SamplerTypeFromTextureTarget(
- quad_resource_lock.target());
+ SamplerType sampler =
+ SamplerTypeFromTextureTarget(quad_resource_lock.target());
float fragment_tex_translate_x = clamp_tex_rect.x();
float fragment_tex_translate_y = clamp_tex_rect.y();
@@ -1494,9 +1475,8 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
TileProgramUniforms uniforms;
if (use_aa) {
if (quad->swizzle_contents) {
- TileUniformLocation(
- GetTileProgramSwizzleAA(tex_coord_precision, sampler),
- &uniforms);
+ TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision, sampler),
+ &uniforms);
} else {
TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler),
&uniforms);
@@ -1504,9 +1484,8 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
} else {
if (quad->ShouldDrawWithBlending()) {
if (quad->swizzle_contents) {
- TileUniformLocation(
- GetTileProgramSwizzle(tex_coord_precision, sampler),
- &uniforms);
+ TileUniformLocation(GetTileProgramSwizzle(tex_coord_precision, sampler),
+ &uniforms);
} else {
TileUniformLocation(GetTileProgram(tex_coord_precision, sampler),
&uniforms);
@@ -1524,31 +1503,28 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
}
SetUseProgram(uniforms.program);
- GLC(Context(), Context()->uniform1i(uniforms.sampler_location, 0));
+ GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0));
if (use_aa) {
- float viewport[4] = {
- static_cast<float>(viewport_.x()),
- static_cast<float>(viewport_.y()),
- static_cast<float>(viewport_.width()),
- static_cast<float>(viewport_.height()),
- };
- GLC(Context(),
- Context()->uniform4fv(uniforms.viewport_location, 1, viewport));
- GLC(Context(), Context()->uniform3fv(uniforms.edge_location, 8, edge));
-
- GLC(Context(),
- Context()->uniform4f(uniforms.vertex_tex_transform_location,
- vertex_tex_translate_x,
- vertex_tex_translate_y,
- vertex_tex_scale_x,
- vertex_tex_scale_y));
- GLC(Context(),
- Context()->uniform4f(uniforms.fragment_tex_transform_location,
- fragment_tex_translate_x,
- fragment_tex_translate_y,
- fragment_tex_scale_x,
- fragment_tex_scale_y));
+ float viewport[4] = {static_cast<float>(viewport_.x()),
+ static_cast<float>(viewport_.y()),
+ static_cast<float>(viewport_.width()),
+ static_cast<float>(viewport_.height()), };
+ GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
+ GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
+
+ GLC(gl_,
+ gl_->Uniform4f(uniforms.vertex_tex_transform_location,
+ vertex_tex_translate_x,
+ vertex_tex_translate_y,
+ vertex_tex_scale_x,
+ vertex_tex_scale_y));
+ GLC(gl_,
+ gl_->Uniform4f(uniforms.fragment_tex_transform_location,
+ fragment_tex_translate_x,
+ fragment_tex_translate_y,
+ fragment_tex_scale_x,
+ fragment_tex_scale_y));
} else {
// Move fragment shader transform to vertex shader. We can do this while
// still producing correct results as fragment_tex_transform_location
@@ -1561,12 +1537,12 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
vertex_tex_translate_x += fragment_tex_translate_x;
vertex_tex_translate_y += fragment_tex_translate_y;
- GLC(Context(),
- Context()->uniform4f(uniforms.vertex_tex_transform_location,
- vertex_tex_translate_x,
- vertex_tex_translate_y,
- vertex_tex_scale_x,
- vertex_tex_scale_y));
+ GLC(gl_,
+ gl_->Uniform4f(uniforms.vertex_tex_transform_location,
+ vertex_tex_translate_x,
+ vertex_tex_translate_y,
+ vertex_tex_scale_x,
+ vertex_tex_scale_y));
}
// Enable blending when the quad properties require it or if we decided
@@ -1595,36 +1571,26 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
SetBlendEnabled(quad->ShouldDrawWithBlending());
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &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;
ResourceProvider::ScopedSamplerGL y_plane_lock(
- resource_provider_,
- quad->y_plane_resource_id,
- GL_TEXTURE1,
- GL_LINEAR);
+ resource_provider_, quad->y_plane_resource_id, GL_TEXTURE1, GL_LINEAR);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), y_plane_lock.target());
ResourceProvider::ScopedSamplerGL u_plane_lock(
- resource_provider_,
- quad->u_plane_resource_id,
- GL_TEXTURE2,
- GL_LINEAR);
+ resource_provider_, quad->u_plane_resource_id, GL_TEXTURE2, GL_LINEAR);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), u_plane_lock.target());
ResourceProvider::ScopedSamplerGL v_plane_lock(
- resource_provider_,
- quad->v_plane_resource_id,
- GL_TEXTURE3,
- GL_LINEAR);
+ resource_provider_, quad->v_plane_resource_id, GL_TEXTURE3, GL_LINEAR);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target());
scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
if (use_alpha_plane) {
a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
- resource_provider_,
- quad->a_plane_resource_id,
- GL_TEXTURE4,
- GL_LINEAR));
+ resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR));
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target());
}
@@ -1664,26 +1630,22 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
alpha_location = program->fragment_shader().alpha_location();
}
- GLC(Context(),
- Context()->uniform2f(tex_scale_location,
- quad->tex_scale.width(),
- quad->tex_scale.height()));
- GLC(Context(), Context()->uniform1i(y_texture_location, 1));
- GLC(Context(), Context()->uniform1i(u_texture_location, 2));
- GLC(Context(), Context()->uniform1i(v_texture_location, 3));
+ GLC(gl_,
+ gl_->Uniform2f(tex_scale_location,
+ quad->tex_scale.width(),
+ quad->tex_scale.height()));
+ GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
+ GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
+ GLC(gl_, gl_->Uniform1i(v_texture_location, 3));
if (use_alpha_plane)
- GLC(Context(), Context()->uniform1i(a_texture_location, 4));
+ GLC(gl_, gl_->Uniform1i(a_texture_location, 4));
// These values are magic numbers that are used in the transformation from YUV
// to RGB color values. They are taken from the following webpage:
// http://www.fourcc.org/fccyvrgb.php
- float yuv_to_rgb[9] = {
- 1.164f, 1.164f, 1.164f,
- 0.0f, -.391f, 2.018f,
- 1.596f, -.813f, 0.0f,
- };
- GLC(Context(),
- Context()->uniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
+ float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f,
+ 2.018f, 1.596f, -.813f, 0.0f, };
+ GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
// These values map to 16, 128, and 128 respectively, and are computed
// as a fraction over 256 (e.g. 16 / 256 = 0.0625).
@@ -1691,9 +1653,8 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
// Y - 16 : Gives 16 values of head and footroom for overshooting
// U - 128 : Turns unsigned U into signed U [-128,127]
// V - 128 : Turns unsigned V into signed V [-128,127]
- float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, };
- GLC(Context(), Context()->uniform3fv(yuv_adj_location, 1, yuv_adjust));
-
+ float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, };
+ GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
SetShaderOpacity(quad->opacity(), alpha_location);
DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location);
@@ -1708,7 +1669,9 @@ void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
DCHECK(capabilities_.using_egl_image);
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &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 =
@@ -1716,18 +1679,16 @@ void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
SetUseProgram(program->program());
ToGLMatrix(&gl_matrix[0], quad->matrix);
- GLC(Context(),
- Context()->uniformMatrix4fv(
+ GLC(gl_,
+ gl_->UniformMatrix4fv(
program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix));
ResourceProvider::ScopedReadLockGL lock(resource_provider_,
quad->resource_id);
DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
- GLC(Context(),
- Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
- GLC(Context(),
- Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
SetShaderOpacity(quad->opacity(),
program->fragment_shader().alpha_location());
@@ -1741,29 +1702,28 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
const PictureDrawQuad* quad) {
if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() ||
on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) {
- on_demand_tile_raster_bitmap_.setConfig(
- SkBitmap::kARGB_8888_Config,
- quad->texture_size.width(),
- quad->texture_size.height());
+ on_demand_tile_raster_bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
+ quad->texture_size.width(),
+ quad->texture_size.height());
on_demand_tile_raster_bitmap_.allocPixels();
if (on_demand_tile_raster_resource_id_)
resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
- on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
- quad->texture_size,
- GL_TEXTURE_2D,
- GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
- GL_CLAMP_TO_EDGE,
- ResourceProvider::TextureUsageAny,
- quad->texture_format);
+ on_demand_tile_raster_resource_id_ =
+ resource_provider_->CreateGLTexture(quad->texture_size,
+ GL_TEXTURE_2D,
+ GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
+ GL_CLAMP_TO_EDGE,
+ ResourceProvider::TextureUsageAny,
+ quad->texture_format);
}
SkBitmapDevice device(on_demand_tile_raster_bitmap_);
SkCanvas canvas(&device);
- quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect,
- quad->contents_scale, NULL);
+ quad->picture_pile->RasterToBitmap(
+ &canvas, quad->content_rect, quad->contents_scale, NULL);
uint8_t* bitmap_pixels = NULL;
SkBitmap on_demand_tile_raster_bitmap_dest;
@@ -1777,16 +1737,15 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
bitmap_pixels = reinterpret_cast<uint8_t*>(
on_demand_tile_raster_bitmap_dest.getPixels());
} else {
- bitmap_pixels = reinterpret_cast<uint8_t*>(
- on_demand_tile_raster_bitmap_.getPixels());
+ bitmap_pixels =
+ reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels());
}
- resource_provider_->SetPixels(
- on_demand_tile_raster_resource_id_,
- bitmap_pixels,
- gfx::Rect(quad->texture_size),
- gfx::Rect(quad->texture_size),
- gfx::Vector2d());
+ resource_provider_->SetPixels(on_demand_tile_raster_resource_id_,
+ bitmap_pixels,
+ gfx::Rect(quad->texture_size),
+ gfx::Rect(quad->texture_size),
+ gfx::Vector2d());
DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_);
}
@@ -1831,54 +1790,52 @@ void GLRenderer::FlushTextureQuadCache() {
SetUseProgram(draw_cache_.program_id);
// Bind the correct texture sampler location.
- GLC(Context(), Context()->uniform1i(draw_cache_.sampler_location, 0));
+ GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
// Assume the current active textures is 0.
ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_,
draw_cache_.resource_id);
DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
- GLC(Context(),
- Context()->bindTexture(GL_TEXTURE_2D, locked_quad.texture_id()));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id()));
- COMPILE_ASSERT(
- sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof)
- struct_is_densely_packed);
+ COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof)
+ struct_is_densely_packed);
COMPILE_ASSERT(
sizeof(Float16) == 16 * sizeof(float), // NOLINT(runtime/sizeof)
struct_is_densely_packed);
// Upload the tranforms for both points and uvs.
- GLC(context_,
- context_->uniformMatrix4fv(
+ GLC(gl_,
+ gl_->UniformMatrix4fv(
static_cast<int>(draw_cache_.matrix_location),
static_cast<int>(draw_cache_.matrix_data.size()),
false,
reinterpret_cast<float*>(&draw_cache_.matrix_data.front())));
- GLC(context_,
- context_->uniform4fv(
+ GLC(gl_,
+ gl_->Uniform4fv(
static_cast<int>(draw_cache_.uv_xform_location),
static_cast<int>(draw_cache_.uv_xform_data.size()),
reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front())));
if (draw_cache_.background_color != SK_ColorTRANSPARENT) {
Float4 background_color = PremultipliedColor(draw_cache_.background_color);
- GLC(context_,
- context_->uniform4fv(
+ GLC(gl_,
+ gl_->Uniform4fv(
draw_cache_.background_color_location, 1, background_color.data));
}
- GLC(context_,
- context_->uniform1fv(
+ GLC(gl_,
+ gl_->Uniform1fv(
static_cast<int>(draw_cache_.vertex_opacity_location),
static_cast<int>(draw_cache_.vertex_opacity_data.size()),
static_cast<float*>(&draw_cache_.vertex_opacity_data.front())));
// Draw the quads!
- GLC(context_,
- context_->drawElements(GL_TRIANGLES,
- 6 * draw_cache_.matrix_data.size(),
- GL_UNSIGNED_SHORT,
- 0));
+ GLC(gl_,
+ gl_->DrawElements(GL_TRIANGLES,
+ 6 * draw_cache_.matrix_data.size(),
+ GL_UNSIGNED_SHORT,
+ 0));
// Clear the cache.
draw_cache_.program_id = 0;
@@ -1890,7 +1847,9 @@ void GLRenderer::FlushTextureQuadCache() {
void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
const TextureDrawQuad* quad) {
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &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
@@ -1955,54 +1914,52 @@ void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
SetBlendEnabled(quad->ShouldDrawWithBlending());
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &highp_threshold_cache_, highp_threshold_min_,
+ gl_,
+ &highp_threshold_cache_,
+ highp_threshold_min_,
quad->shared_quad_state->visible_content_rect.bottom_right());
TexTransformTextureProgramBinding binding;
binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
SetUseProgram(binding.program_id);
- GLC(Context(), Context()->uniform1i(binding.sampler_location, 0));
+ GLC(gl_, gl_->Uniform1i(binding.sampler_location, 0));
if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) {
- GLC(Context(),
- Context()->uniform4f(binding.tex_transform_location,
- 0,
- quad->io_surface_size.height(),
- quad->io_surface_size.width(),
- quad->io_surface_size.height() * -1.0f));
+ GLC(gl_,
+ gl_->Uniform4f(binding.tex_transform_location,
+ 0,
+ quad->io_surface_size.height(),
+ quad->io_surface_size.width(),
+ quad->io_surface_size.height() * -1.0f));
} else {
- GLC(Context(),
- Context()->uniform4f(binding.tex_transform_location,
- 0,
- 0,
- quad->io_surface_size.width(),
- quad->io_surface_size.height()));
+ GLC(gl_,
+ gl_->Uniform4f(binding.tex_transform_location,
+ 0,
+ 0,
+ quad->io_surface_size.width(),
+ quad->io_surface_size.height()));
}
- const float vertex_opacity[] = { quad->opacity(), quad->opacity(),
- quad->opacity(), quad->opacity() };
- GLC(Context(),
- Context()->uniform1fv(
- binding.vertex_opacity_location, 4, vertex_opacity));
+ const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
+ quad->opacity(), quad->opacity()};
+ GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
ResourceProvider::ScopedReadLockGL lock(resource_provider_,
quad->io_surface_resource_id);
DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
- GLC(Context(),
- Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB,
- lock.texture_id()));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
DrawQuadGeometry(
frame, quad->quadTransform(), quad->rect, binding.matrix_location);
- GLC(Context(), Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
}
void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
current_framebuffer_lock_.reset();
swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
- GLC(context_, context_->disable(GL_BLEND));
+ GLC(gl_, gl_->Disable(GL_BLEND));
blend_shadow_ = false;
}
@@ -2015,7 +1972,7 @@ void GLRenderer::EnsureScissorTestEnabled() {
return;
FlushTextureQuadCache();
- GLC(context_, context_->enable(GL_SCISSOR_TEST));
+ GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
is_scissor_enabled_ = true;
}
@@ -2024,7 +1981,7 @@ void GLRenderer::EnsureScissorTestDisabled() {
return;
FlushTextureQuadCache();
- GLC(context_, context_->disable(GL_SCISSOR_TEST));
+ GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
is_scissor_enabled_ = false;
}
@@ -2054,12 +2011,12 @@ void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) {
gl_quad[5] = quad.p3().y();
gl_quad[6] = quad.p4().x();
gl_quad[7] = quad.p4().y();
- GLC(context_, context_->uniform2fv(quad_location, 4, gl_quad));
+ GLC(gl_, gl_->Uniform2fv(quad_location, 4, gl_quad));
}
void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) {
if (alpha_location != -1)
- GLC(context_, context_->uniform1f(alpha_location, opacity));
+ GLC(gl_, gl_->Uniform1f(alpha_location, opacity));
}
void GLRenderer::SetStencilEnabled(bool enabled) {
@@ -2067,9 +2024,9 @@ void GLRenderer::SetStencilEnabled(bool enabled) {
return;
if (enabled)
- GLC(context_, context_->enable(GL_STENCIL_TEST));
+ GLC(gl_, gl_->Enable(GL_STENCIL_TEST));
else
- GLC(context_, context_->disable(GL_STENCIL_TEST));
+ GLC(gl_, gl_->Disable(GL_STENCIL_TEST));
stencil_shadow_ = enabled;
}
@@ -2078,9 +2035,9 @@ void GLRenderer::SetBlendEnabled(bool enabled) {
return;
if (enabled)
- GLC(context_, context_->enable(GL_BLEND));
+ GLC(gl_, gl_->Enable(GL_BLEND));
else
- GLC(context_, context_->disable(GL_BLEND));
+ GLC(gl_, gl_->Disable(GL_BLEND));
blend_shadow_ = enabled;
}
@@ -2099,10 +2056,9 @@ void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
static float gl_matrix[16];
ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
- GLC(context_,
- context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
+ GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
- GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
+ GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
}
void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
@@ -2111,41 +2067,39 @@ void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
const gfx::Transform& draw_matrix,
bool flip_vertically) {
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
- gl_, &highp_threshold_cache_, highp_threshold_min_,
- rect.bottom_right());
+ gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right());
const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision);
SetUseProgram(program->program());
- GLC(Context(), Context()->uniform1i(
- program->fragment_shader().sampler_location(), 0));
+ GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
if (flip_vertically) {
- GLC(Context(), Context()->uniform4f(
- program->vertex_shader().tex_transform_location(),
- 0.f,
- 1.f,
- 1.f,
- -1.f));
+ GLC(gl_,
+ gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
+ 0.f,
+ 1.f,
+ 1.f,
+ -1.f));
} else {
- GLC(Context(), Context()->uniform4f(
- program->vertex_shader().tex_transform_location(),
- 0.f,
- 0.f,
- 1.f,
- 1.f));
+ GLC(gl_,
+ gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
+ 0.f,
+ 0.f,
+ 1.f,
+ 1.f));
}
SetShaderOpacity(1.f, program->fragment_shader().alpha_location());
DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
- GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
DrawQuadGeometry(
frame, draw_matrix, rect, program->vertex_shader().matrix_location());
}
void GLRenderer::Finish() {
TRACE_EVENT0("cc", "GLRenderer::Finish");
- GLC(context_, context_->finish());
+ GLC(gl_, gl_->Finish());
}
void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
@@ -2195,7 +2149,7 @@ void GLRenderer::EnforceMemoryPolicy() {
ReleaseRenderPassTextures();
DiscardBackbuffer();
resource_provider_->ReleaseCachedData();
- GLC(context_, context_->flush());
+ GLC(gl_, gl_->Flush());
}
}
@@ -2238,7 +2192,8 @@ void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
}
void GLRenderer::GetFramebufferPixelsAsync(
- gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) {
+ gfx::Rect rect,
+ scoped_ptr<CopyOutputRequest> request) {
DCHECK(!request->IsEmpty());
if (request->IsEmpty())
return;
@@ -2250,13 +2205,14 @@ void GLRenderer::GetFramebufferPixelsAsync(
if (!request->force_bitmap_result()) {
bool own_mailbox = !request->has_texture_mailbox();
- unsigned int texture_id = context_->createTexture();
+ GLuint texture_id = 0;
+ gl_->GenTextures(1, &texture_id);
gpu::Mailbox mailbox;
if (own_mailbox) {
- GLC(context_, context_->genMailboxCHROMIUM(mailbox.name));
+ GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name));
if (mailbox.IsZero()) {
- context_->deleteTexture(texture_id);
+ gl_->DeleteTextures(1, &texture_id);
request->SendEmptyResult();
return;
}
@@ -2267,33 +2223,29 @@ void GLRenderer::GetFramebufferPixelsAsync(
DCHECK(!mailbox.IsZero());
unsigned incoming_sync_point = request->texture_mailbox().sync_point();
if (incoming_sync_point)
- GLC(context_, context_->waitSyncPoint(incoming_sync_point));
+ GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point));
}
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
if (own_mailbox) {
- GLC(context_,
- context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
- GLC(context_,
- context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
- GLC(context_,
- context_->texParameteri(
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ GLC(gl_,
+ gl_->TexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLC(context_,
- context_->texParameteri(
+ GLC(gl_,
+ gl_->TexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- GLC(context_,
- context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
+ GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
} else {
- GLC(context_,
- context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
+ GLC(gl_, gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
}
GetFramebufferTexture(texture_id, RGBA_8888, window_rect);
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
- unsigned sync_point = context_->insertSyncPoint();
+ unsigned sync_point = gl_->InsertSyncPointCHROMIUM();
TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point);
scoped_ptr<SingleReleaseCallback> release_callback;
@@ -2301,21 +2253,19 @@ void GLRenderer::GetFramebufferPixelsAsync(
release_callback = texture_mailbox_deleter_->GetReleaseCallback(
output_surface_->context_provider(), texture_id);
} else {
- context_->deleteTexture(texture_id);
+ gl_->DeleteTextures(1, &texture_id);
}
- request->SendTextureResult(window_rect.size(),
- texture_mailbox,
- release_callback.Pass());
+ request->SendTextureResult(
+ window_rect.size(), texture_mailbox, release_callback.Pass());
return;
}
DCHECK(request->force_bitmap_result());
scoped_ptr<SkBitmap> bitmap(new SkBitmap);
- bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- window_rect.width(),
- window_rect.height());
+ bitmap->setConfig(
+ SkBitmap::kARGB_8888_Config, window_rect.width(), window_rect.height());
bitmap->allocPixels();
scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap));
@@ -2323,11 +2273,11 @@ void GLRenderer::GetFramebufferPixelsAsync(
// Save a pointer to the pixels, the bitmap is owned by the cleanup_callback.
uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
- AsyncGetFramebufferPixelsCleanupCallback cleanup_callback = base::Bind(
- &GLRenderer::PassOnSkBitmap,
- base::Unretained(this),
- base::Passed(&bitmap),
- base::Passed(&lock));
+ AsyncGetFramebufferPixelsCleanupCallback cleanup_callback =
+ base::Bind(&GLRenderer::PassOnSkBitmap,
+ base::Unretained(this),
+ base::Passed(&bitmap),
+ base::Passed(&lock));
scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels);
pending_read->copy_request = request.Pass();
@@ -2361,78 +2311,75 @@ void GLRenderer::DoGetFramebufferPixels(
// is the root cause of top crasher
// http://crbug.com/99393. <rdar://problem/10949687>
- temporary_texture = context_->createTexture();
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture));
- GLC(context_, context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
- GLC(context_, context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
- GLC(context_, context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLC(context_, context_->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+ gl_->GenTextures(1, &temporary_texture);
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, temporary_texture));
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+ GLC(gl_,
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
// Copy the contents of the current (IOSurface-backed) framebuffer into a
// temporary texture.
- GetFramebufferTexture(temporary_texture,
- RGBA_8888,
- gfx::Rect(current_surface_size_));
- temporary_fbo = context_->createFramebuffer();
+ GetFramebufferTexture(
+ temporary_texture, RGBA_8888, gfx::Rect(current_surface_size_));
+ gl_->GenFramebuffers(1, &temporary_fbo);
// Attach this texture to an FBO, and perform the readback from that FBO.
- GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo));
- GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- temporary_texture,
- 0));
+ GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, temporary_fbo));
+ GLC(gl_,
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ temporary_texture,
+ 0));
DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
- context_->checkFramebufferStatus(GL_FRAMEBUFFER));
+ gl_->CheckFramebufferStatus(GL_FRAMEBUFFER));
}
- unsigned buffer = context_->createBuffer();
- GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- buffer));
- GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- 4 * window_rect.size().GetArea(),
- NULL,
- GL_STREAM_READ));
+ GLuint buffer = 0;
+ gl_->GenBuffers(1, &buffer);
+ GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer));
+ GLC(gl_,
+ gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ 4 * window_rect.size().GetArea(),
+ NULL,
+ GL_STREAM_READ));
- blink::WebGLId query = 0;
+ GLuint query = 0;
if (is_async) {
- query = context_->createQueryEXT();
- GLC(context_, context_->beginQueryEXT(
- GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM,
- query));
+ gl_->GenQueriesEXT(1, &query);
+ GLC(gl_, gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query));
}
- GLC(context_,
- context_->readPixels(window_rect.x(),
- window_rect.y(),
- window_rect.width(),
- window_rect.height(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- NULL));
+ GLC(gl_,
+ gl_->ReadPixels(window_rect.x(),
+ window_rect.y(),
+ window_rect.width(),
+ window_rect.height(),
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ NULL));
- GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- 0));
+ GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0));
if (do_workaround) {
// Clean up.
- GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0));
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
- GLC(context_, context_->deleteFramebuffer(temporary_fbo));
- GLC(context_, context_->deleteTexture(temporary_texture));
- }
-
- base::Closure finished_callback =
- base::Bind(&GLRenderer::FinishedReadback,
- base::Unretained(this),
- cleanup_callback,
- buffer,
- query,
- dest_pixels,
- window_rect.size());
+ GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
+ GLC(gl_, gl_->DeleteFramebuffers(1, &temporary_fbo));
+ GLC(gl_, gl_->DeleteTextures(1, &temporary_texture));
+ }
+
+ base::Closure finished_callback = base::Bind(&GLRenderer::FinishedReadback,
+ base::Unretained(this),
+ cleanup_callback,
+ buffer,
+ query,
+ dest_pixels,
+ window_rect.size());
// Save the finished_callback so it can be cancelled.
pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset(
finished_callback);
@@ -2441,8 +2388,7 @@ void GLRenderer::DoGetFramebufferPixels(
pending_async_read_pixels_.front()->buffer = buffer;
if (is_async) {
- GLC(context_, context_->endQueryEXT(
- GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM));
+ GLC(gl_, gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM));
context_support_->SignalQuery(query, finished_callback);
} else {
resource_provider_->Finish();
@@ -2461,7 +2407,7 @@ void GLRenderer::FinishedReadback(
DCHECK(!pending_async_read_pixels_.empty());
if (query != 0) {
- GLC(context_, context_->deleteQueryEXT(query));
+ GLC(gl_, gl_->DeleteQueriesEXT(1, &query));
}
PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back();
@@ -2471,11 +2417,10 @@ void GLRenderer::FinishedReadback(
uint8* src_pixels = NULL;
if (source_buffer != 0) {
- GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- source_buffer));
- src_pixels = static_cast<uint8*>(
- context_->mapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- GL_READ_ONLY));
+ GLC(gl_,
+ gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer));
+ src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM(
+ GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
if (src_pixels) {
size_t row_bytes = size.width() * 4;
@@ -2486,19 +2431,22 @@ void GLRenderer::FinishedReadback(
size_t src_y = total_bytes - dest_y - row_bytes;
// Swizzle OpenGL -> Skia byte order.
for (size_t x = 0; x < row_bytes; x += 4) {
- dest_pixels[dest_y + x + SK_R32_SHIFT/8] = src_pixels[src_y + x + 0];
- dest_pixels[dest_y + x + SK_G32_SHIFT/8] = src_pixels[src_y + x + 1];
- dest_pixels[dest_y + x + SK_B32_SHIFT/8] = src_pixels[src_y + x + 2];
- dest_pixels[dest_y + x + SK_A32_SHIFT/8] = src_pixels[src_y + x + 3];
+ dest_pixels[dest_y + x + SK_R32_SHIFT / 8] =
+ src_pixels[src_y + x + 0];
+ dest_pixels[dest_y + x + SK_G32_SHIFT / 8] =
+ src_pixels[src_y + x + 1];
+ dest_pixels[dest_y + x + SK_B32_SHIFT / 8] =
+ src_pixels[src_y + x + 2];
+ dest_pixels[dest_y + x + SK_A32_SHIFT / 8] =
+ src_pixels[src_y + x + 3];
}
}
- GLC(context_, context_->unmapBufferCHROMIUM(
- GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM));
+ GLC(gl_,
+ gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM));
}
- GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- 0));
- GLC(context_, context_->deleteBuffer(source_buffer));
+ GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0));
+ GLC(gl_, gl_->DeleteBuffers(1, &source_buffer));
}
// TODO(danakj): This can go away when synchronous readback is no more and its
@@ -2509,11 +2457,10 @@ void GLRenderer::FinishedReadback(
pending_async_read_pixels_.pop_back();
}
-void GLRenderer::PassOnSkBitmap(
- scoped_ptr<SkBitmap> bitmap,
- scoped_ptr<SkAutoLockPixels> lock,
- scoped_ptr<CopyOutputRequest> request,
- bool success) {
+void GLRenderer::PassOnSkBitmap(scoped_ptr<SkBitmap> bitmap,
+ scoped_ptr<SkAutoLockPixels> lock,
+ scoped_ptr<CopyOutputRequest> request,
+ bool success) {
DCHECK(request->force_bitmap_result());
lock.reset();
@@ -2521,26 +2468,26 @@ void GLRenderer::PassOnSkBitmap(
request->SendBitmapResult(bitmap.Pass());
}
-void GLRenderer::GetFramebufferTexture(
- unsigned texture_id, ResourceFormat texture_format, gfx::Rect window_rect) {
+void GLRenderer::GetFramebufferTexture(unsigned texture_id,
+ ResourceFormat texture_format,
+ gfx::Rect window_rect) {
DCHECK(texture_id);
DCHECK_GE(window_rect.x(), 0);
DCHECK_GE(window_rect.y(), 0);
DCHECK_LE(window_rect.right(), current_surface_size_.width());
DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
- GLC(context_,
- context_->copyTexImage2D(
- GL_TEXTURE_2D,
- 0,
- GLDataFormat(texture_format),
- window_rect.x(),
- window_rect.y(),
- window_rect.width(),
- window_rect.height(),
- 0));
- GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
+ GLC(gl_,
+ gl_->CopyTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GLDataFormat(texture_format),
+ window_rect.x(),
+ window_rect.y(),
+ window_rect.width(),
+ window_rect.height(),
+ 0));
+ GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
}
bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
@@ -2559,7 +2506,7 @@ void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
if (output_surface_->HasExternalStencilTest()) {
SetStencilEnabled(true);
- GLC(context_, context_->stencilFunc(GL_EQUAL, 1, 1));
+ GLC(gl_, gl_->StencilFunc(GL_EQUAL, 1, 1));
} else {
SetStencilEnabled(false);
}
@@ -2573,23 +2520,21 @@ bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
current_framebuffer_lock_.reset();
SetStencilEnabled(false);
- GLC(context_,
- context_->bindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_));
+ GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_));
current_framebuffer_lock_ =
make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL(
resource_provider_, texture->id()));
unsigned texture_id = current_framebuffer_lock_->texture_id();
- GLC(context_,
- context_->framebufferTexture2D(
+ GLC(gl_,
+ gl_->FramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0));
- DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) ==
- GL_FRAMEBUFFER_COMPLETE || IsContextLost());
+ DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) ==
+ GL_FRAMEBUFFER_COMPLETE ||
+ IsContextLost());
- InitializeViewport(frame,
- target_rect,
- gfx::Rect(target_rect.size()),
- target_rect.size());
+ InitializeViewport(
+ frame, target_rect, gfx::Rect(target_rect.size()), target_rect.size());
return true;
}
@@ -2603,28 +2548,29 @@ void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) {
scissor_rect_ = scissor_rect;
FlushTextureQuadCache();
- GLC(context_,
- context_->scissor(scissor_rect.x(),
- scissor_rect.y(),
- scissor_rect.width(),
- scissor_rect.height()));
+ GLC(gl_,
+ gl_->Scissor(scissor_rect.x(),
+ scissor_rect.y(),
+ scissor_rect.width(),
+ scissor_rect.height()));
scissor_rect_needs_reset_ = false;
}
void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {
viewport_ = window_space_viewport;
- GLC(context_, context_->viewport(window_space_viewport.x(),
- window_space_viewport.y(),
- window_space_viewport.width(),
- window_space_viewport.height()));
+ GLC(gl_,
+ gl_->Viewport(window_space_viewport.x(),
+ window_space_viewport.y(),
+ window_space_viewport.width(),
+ window_space_viewport.height()));
}
void GLRenderer::InitializeSharedObjects() {
TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
// Create an FBO for doing offscreen rendering.
- GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer());
+ GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
shared_geometry_ = make_scoped_ptr(
new GeometryBinding(context_, QuadVertexRect()));
@@ -2634,10 +2580,9 @@ const GLRenderer::TileCheckerboardProgram*
GLRenderer::GetTileCheckerboardProgram() {
if (!tile_checkerboard_program_.initialized()) {
TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
- tile_checkerboard_program_.Initialize(
- output_surface_->context_provider(),
- TexCoordPrecisionNA,
- SamplerTypeNA);
+ tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
+ TexCoordPrecisionNA,
+ SamplerTypeNA);
}
return &tile_checkerboard_program_;
}
@@ -2645,10 +2590,9 @@ GLRenderer::GetTileCheckerboardProgram() {
const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() {
if (!debug_border_program_.initialized()) {
TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize");
- debug_border_program_.Initialize(
- output_surface_->context_provider(),
- TexCoordPrecisionNA,
- SamplerTypeNA);
+ debug_border_program_.Initialize(output_surface_->context_provider(),
+ TexCoordPrecisionNA,
+ SamplerTypeNA);
}
return &debug_border_program_;
}
@@ -2656,10 +2600,9 @@ const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() {
const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() {
if (!solid_color_program_.initialized()) {
TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize");
- solid_color_program_.Initialize(
- output_surface_->context_provider(),
- TexCoordPrecisionNA,
- SamplerTypeNA);
+ solid_color_program_.Initialize(output_surface_->context_provider(),
+ TexCoordPrecisionNA,
+ SamplerTypeNA);
}
return &solid_color_program_;
}
@@ -2667,16 +2610,15 @@ const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() {
const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() {
if (!solid_color_program_aa_.initialized()) {
TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize");
- solid_color_program_aa_.Initialize(
- output_surface_->context_provider(),
- TexCoordPrecisionNA,
- SamplerTypeNA);
+ solid_color_program_aa_.Initialize(output_surface_->context_provider(),
+ TexCoordPrecisionNA,
+ SamplerTypeNA);
}
return &solid_color_program_aa_;
}
const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram(
- TexCoordPrecision precision) {
+ TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
RenderPassProgram* program = &render_pass_program_[precision];
@@ -2689,7 +2631,7 @@ const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram(
}
const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
- TexCoordPrecision precision) {
+ TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
RenderPassProgramAA* program = &render_pass_program_aa_[precision];
@@ -2701,8 +2643,8 @@ const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
return program;
}
-const GLRenderer::RenderPassMaskProgram*
-GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) {
+const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
+ TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
RenderPassMaskProgram* program = &render_pass_mask_program_[precision];
@@ -2787,7 +2729,8 @@ GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) {
}
const GLRenderer::TileProgram* GLRenderer::GetTileProgram(
- TexCoordPrecision precision, SamplerType sampler) {
+ TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
@@ -2802,7 +2745,8 @@ const GLRenderer::TileProgram* GLRenderer::GetTileProgram(
}
const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque(
- TexCoordPrecision precision, SamplerType sampler) {
+ TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
@@ -2817,7 +2761,8 @@ const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque(
}
const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA(
- TexCoordPrecision precision, SamplerType sampler) {
+ TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
@@ -2832,7 +2777,8 @@ const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA(
}
const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle(
- TexCoordPrecision precision, SamplerType sampler) {
+ TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
@@ -2847,8 +2793,8 @@ const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle(
}
const GLRenderer::TileProgramSwizzleOpaque*
-GLRenderer::GetTileProgramSwizzleOpaque(
- TexCoordPrecision precision, SamplerType sampler) {
+GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
@@ -2864,13 +2810,13 @@ GLRenderer::GetTileProgramSwizzleOpaque(
}
const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA(
- TexCoordPrecision precision, SamplerType sampler) {
+ TexCoordPrecision precision,
+ SamplerType sampler) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
DCHECK_GE(sampler, 0);
DCHECK_LT(sampler, NumSamplerTypes);
- TileProgramSwizzleAA* program =
- &tile_program_swizzle_aa_[precision][sampler];
+ TileProgramSwizzleAA* program = &tile_program_swizzle_aa_[precision][sampler];
if (!program->initialized()) {
TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize");
program->Initialize(
@@ -2893,7 +2839,7 @@ const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram(
}
const GLRenderer::NonPremultipliedTextureProgram*
- GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) {
+GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
NonPremultipliedTextureProgram* program =
@@ -2936,8 +2882,8 @@ GLRenderer::GetNonPremultipliedTextureBackgroundProgram(
return program;
}
-const GLRenderer::TextureProgram*
-GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) {
+const GLRenderer::TextureProgram* GLRenderer::GetTextureIOSurfaceProgram(
+ TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
DCHECK_LT(precision, NumTexCoordPrecisions);
TextureProgram* program = &texture_io_surface_program_[precision];
@@ -2986,9 +2932,7 @@ GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) {
if (!program->initialized()) {
TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize");
program->Initialize(
- output_surface_->context_provider(),
- precision,
- SamplerTypeExternalOES);
+ output_surface_->context_provider(), precision, SamplerTypeExternalOES);
}
return program;
}
@@ -3033,7 +2977,7 @@ void GLRenderer::CleanupSharedObjects() {
solid_color_program_aa_.Cleanup(gl_);
if (offscreen_framebuffer_id_)
- GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_));
+ GLC(gl_, gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_));
if (on_demand_tile_raster_resource_id_)
resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
@@ -3045,20 +2989,20 @@ void GLRenderer::ReinitializeGLState() {
// Bind the common vertex attributes used for drawing all the layers.
shared_geometry_->PrepareForDraw();
- GLC(context_, context_->disable(GL_DEPTH_TEST));
- GLC(context_, context_->disable(GL_CULL_FACE));
- GLC(context_, context_->colorMask(true, true, true, true));
- GLC(context_, context_->disable(GL_STENCIL_TEST));
+ GLC(gl_, gl_->Disable(GL_DEPTH_TEST));
+ GLC(gl_, gl_->Disable(GL_CULL_FACE));
+ GLC(gl_, gl_->ColorMask(true, true, true, true));
+ GLC(gl_, gl_->Disable(GL_STENCIL_TEST));
stencil_shadow_ = false;
- GLC(context_, context_->enable(GL_BLEND));
+ GLC(gl_, gl_->Enable(GL_BLEND));
blend_shadow_ = true;
- GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
- GLC(context_, context_->activeTexture(GL_TEXTURE0));
+ GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
+ GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
program_shadow_ = 0;
// Make sure scissoring starts as disabled.
is_scissor_enabled_ = false;
- GLC(context_, context_->disable(GL_SCISSOR_TEST));
+ GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
scissor_rect_needs_reset_ = true;
}
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/test/test_gles2_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698