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

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
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index d85886765038015600cfb6dadbada889e88bb084..d6657a72f0cb053d201da1c65f29e26aa4c5fa69 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;
}
@@ -195,11 +194,11 @@ GLRenderer::GLRenderer(RendererClient* client,
}
bool GLRenderer::Initialize() {
- if (!context_->makeContextCurrent())
+ if (!MakeContextCurrent())
return false;
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;
@@ -225,8 +224,7 @@ bool GLRenderer::Initialize() {
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;
if (!InitializeSharedObjects())
return false;
@@ -237,14 +235,13 @@ bool GLRenderer::Initialize() {
}
void GLRenderer::InitializeGrContext() {
- skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
- context_->createGrGLInterface());
+ skia::RefPtr<GrGLInterface> interface =
+ skia::AdoptRef(context_->createGrGLInterface());
if (!interface)
return;
gr_context_ = skia::AdoptRef(GrContext::Create(
- kOpenGL_GrBackend,
- reinterpret_cast<GrBackendContext>(interface.get())));
+ kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get())));
ReinitializeGrCanvas();
}
@@ -264,11 +261,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 "
@@ -302,9 +299,7 @@ void GLRenderer::SendManagedMemoryStats(size_t bytes_visible,
void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); }
-void GLRenderer::ViewportChanged() {
- ReinitializeGrCanvas();
-}
+void GLRenderer::ViewportChanged() { ReinitializeGrCanvas(); }
void GLRenderer::DiscardPixels(bool has_external_stencil_test,
bool draw_rect_covers_full_surface) {
@@ -316,7 +311,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);
}
@@ -332,9 +327,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
@@ -345,10 +340,10 @@ void GLRenderer::ClearFramebuffer(DrawingFrame* frame,
// Only the Skia GPU backend uses the stencil buffer. No need to clear it
// otherwise.
if (always_clear || CanUseSkiaGPUBackend()) {
- GLC(context_, context_->clearStencil(0));
+ GLC(gl_, gl_->ClearStencil(0));
clear_bits |= GL_STENCIL_BUFFER_BIT;
}
- context_->clear(clear_bits);
+ gl_->Clear(clear_bits);
}
}
@@ -364,8 +359,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) {
@@ -420,12 +415,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;
@@ -435,16 +430,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());
@@ -472,26 +467,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,
@@ -762,9 +756,8 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
} else {
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(
@@ -817,8 +810,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
@@ -954,10 +947,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();
@@ -979,18 +972,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;
@@ -1009,8 +1003,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();
@@ -1029,8 +1022,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();
@@ -1046,8 +1038,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();
@@ -1060,8 +1051,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();
@@ -1084,8 +1074,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();
@@ -1102,8 +1091,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 =
@@ -1123,8 +1111,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 =
@@ -1138,8 +1125,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();
@@ -1157,17 +1143,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;
@@ -1175,15 +1162,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,
@@ -1197,18 +1183,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) {
@@ -1217,9 +1200,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) {
@@ -1227,8 +1209,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
@@ -1245,7 +1226,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 {
@@ -1257,7 +1238,7 @@ struct SolidColorProgramUniforms {
unsigned color_location;
};
-template<class T>
+template <class T>
static void SolidColorUniformLocation(T program,
SolidColorProgramUniforms* uniforms) {
uniforms->program = program->program();
@@ -1281,7 +1262,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.
@@ -1340,8 +1322,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(
@@ -1385,22 +1366,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
@@ -1416,11 +1394,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 {
@@ -1475,16 +1453,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);
@@ -1496,8 +1474,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();
@@ -1507,18 +1484,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();
@@ -1538,9 +1516,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);
@@ -1548,9 +1525,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);
@@ -1568,31 +1544,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
@@ -1605,12 +1578,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
@@ -1639,36 +1612,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());
}
@@ -1708,26 +1671,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).
@@ -1735,9 +1694,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);
@@ -1752,7 +1710,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 =
@@ -1760,18 +1720,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());
@@ -1805,10 +1763,9 @@ void GLRenderer::DrawPictureQuadDirectToBackbuffer(
SkRegion::kReplace_Op);
}
- gfx::Transform contents_device_transform = frame->window_matrix *
- frame->projection_matrix * quad->quadTransform();
- contents_device_transform.Translate(quad->rect.x(),
- quad->rect.y());
+ gfx::Transform contents_device_transform =
+ frame->window_matrix * frame->projection_matrix * quad->quadTransform();
+ contents_device_transform.Translate(quad->rect.x(), quad->rect.y());
contents_device_transform.FlattenTo2d();
SkMatrix sk_device_matrix;
gfx::TransformToFlattenedSkMatrix(contents_device_transform,
@@ -1834,29 +1791,28 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
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;
@@ -1870,16 +1826,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_);
}
@@ -1924,54 +1879,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;
@@ -1983,7 +1936,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
@@ -2048,54 +2003,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;
}
@@ -2108,7 +2061,7 @@ void GLRenderer::EnsureScissorTestEnabled() {
return;
FlushTextureQuadCache();
- GLC(context_, context_->enable(GL_SCISSOR_TEST));
+ GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
is_scissor_enabled_ = true;
}
@@ -2117,7 +2070,7 @@ void GLRenderer::EnsureScissorTestDisabled() {
return;
FlushTextureQuadCache();
- GLC(context_, context_->disable(GL_SCISSOR_TEST));
+ GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
is_scissor_enabled_ = false;
}
@@ -2147,12 +2100,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) {
@@ -2160,9 +2113,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;
}
@@ -2171,9 +2124,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;
}
@@ -2192,10 +2145,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,
@@ -2204,41 +2156,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) {
@@ -2256,9 +2206,9 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
// If supported, we can save significant bandwidth by only swapping the
// damaged/scissored region (clamped to the viewport)
swap_buffer_rect_.Intersect(client_->DeviceViewport());
- int flipped_y_pos_of_rect_bottom =
- client_->DeviceViewport().height() - swap_buffer_rect_.y() -
- swap_buffer_rect_.height();
+ int flipped_y_pos_of_rect_bottom = client_->DeviceViewport().height() -
+ swap_buffer_rect_.y() -
+ swap_buffer_rect_.height();
compositor_frame.gl_frame_data->sub_buffer_rect =
gfx::Rect(swap_buffer_rect_.x(),
flipped_y_pos_of_rect_bottom,
@@ -2287,7 +2237,7 @@ void GLRenderer::EnforceMemoryPolicy() {
ReleaseRenderPassTextures();
DiscardBackbuffer();
resource_provider_->ReleaseCachedData();
- GLC(context_, context_->flush());
piman 2013/12/06 00:49:44 This is where the FreeEverything happens inside th
+ GLC(gl_, gl_->Flush());
}
}
@@ -2330,7 +2280,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;
@@ -2342,13 +2293,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;
}
@@ -2359,33 +2311,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;
@@ -2393,21 +2341,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));
@@ -2415,11 +2361,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();
@@ -2455,78 +2401,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);
@@ -2535,8 +2478,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();
@@ -2555,7 +2497,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();
@@ -2565,11 +2507,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;
@@ -2580,19 +2521,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
@@ -2603,11 +2547,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();
@@ -2615,26 +2558,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,
@@ -2653,7 +2596,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);
}
@@ -2667,23 +2610,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;
}
@@ -2697,21 +2638,22 @@ 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()));
}
bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); }
@@ -2721,10 +2663,10 @@ bool GLRenderer::InitializeSharedObjects() {
MakeContextCurrent();
// 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()));
+ shared_geometry_ =
+ make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect()));
return true;
}
@@ -2733,10 +2675,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_;
}
@@ -2744,10 +2685,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_;
}
@@ -2755,10 +2695,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_;
}
@@ -2766,16 +2705,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];
@@ -2788,7 +2726,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];
@@ -2800,8 +2738,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];
@@ -2886,7 +2824,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);
@@ -2901,7 +2840,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);
@@ -2916,7 +2856,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);
@@ -2931,7 +2872,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);
@@ -2946,8 +2888,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);
@@ -2963,13 +2905,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(
@@ -2992,7 +2934,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 =
@@ -3035,8 +2977,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];
@@ -3085,9 +3027,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;
}
@@ -3134,7 +3074,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_);
@@ -3166,20 +3106,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;
}

Powered by Google App Engine
This is Rietveld 408576698