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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « cc/output/filter_operations.cc ('k') | cc/output/output_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/debug/trace_event.h"
14 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/trace_event/trace_event.h"
15 #include "cc/base/math_util.h" 15 #include "cc/base/math_util.h"
16 #include "cc/output/compositor_frame.h" 16 #include "cc/output/compositor_frame.h"
17 #include "cc/output/compositor_frame_metadata.h" 17 #include "cc/output/compositor_frame_metadata.h"
18 #include "cc/output/context_provider.h" 18 #include "cc/output/context_provider.h"
19 #include "cc/output/copy_output_request.h" 19 #include "cc/output/copy_output_request.h"
20 #include "cc/output/geometry_binding.h" 20 #include "cc/output/geometry_binding.h"
21 #include "cc/output/gl_frame_data.h" 21 #include "cc/output/gl_frame_data.h"
22 #include "cc/output/output_surface.h" 22 #include "cc/output/output_surface.h"
23 #include "cc/output/render_surface_filters.h" 23 #include "cc/output/render_surface_filters.h"
24 #include "cc/quads/picture_draw_quad.h" 24 #include "cc/quads/picture_draw_quad.h"
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; 1824 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
1825 if (use_alpha_plane) { 1825 if (use_alpha_plane) {
1826 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( 1826 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
1827 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); 1827 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR));
1828 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); 1828 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target());
1829 } 1829 }
1830 1830
1831 int matrix_location = -1; 1831 int matrix_location = -1;
1832 int tex_scale_location = -1; 1832 int tex_scale_location = -1;
1833 int tex_offset_location = -1; 1833 int tex_offset_location = -1;
1834 int clamp_rect_location = -1;
1834 int y_texture_location = -1; 1835 int y_texture_location = -1;
1835 int u_texture_location = -1; 1836 int u_texture_location = -1;
1836 int v_texture_location = -1; 1837 int v_texture_location = -1;
1837 int a_texture_location = -1; 1838 int a_texture_location = -1;
1838 int yuv_matrix_location = -1; 1839 int yuv_matrix_location = -1;
1839 int yuv_adj_location = -1; 1840 int yuv_adj_location = -1;
1840 int alpha_location = -1; 1841 int alpha_location = -1;
1841 if (use_alpha_plane) { 1842 if (use_alpha_plane) {
1842 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); 1843 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision);
1843 DCHECK(program && (program->initialized() || IsContextLost())); 1844 DCHECK(program && (program->initialized() || IsContextLost()));
1844 SetUseProgram(program->program()); 1845 SetUseProgram(program->program());
1845 matrix_location = program->vertex_shader().matrix_location(); 1846 matrix_location = program->vertex_shader().matrix_location();
1846 tex_scale_location = program->vertex_shader().tex_scale_location(); 1847 tex_scale_location = program->vertex_shader().tex_scale_location();
1847 tex_offset_location = program->vertex_shader().tex_offset_location(); 1848 tex_offset_location = program->vertex_shader().tex_offset_location();
1848 y_texture_location = program->fragment_shader().y_texture_location(); 1849 y_texture_location = program->fragment_shader().y_texture_location();
1849 u_texture_location = program->fragment_shader().u_texture_location(); 1850 u_texture_location = program->fragment_shader().u_texture_location();
1850 v_texture_location = program->fragment_shader().v_texture_location(); 1851 v_texture_location = program->fragment_shader().v_texture_location();
1851 a_texture_location = program->fragment_shader().a_texture_location(); 1852 a_texture_location = program->fragment_shader().a_texture_location();
1852 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1853 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
1853 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 1854 yuv_adj_location = program->fragment_shader().yuv_adj_location();
1855 clamp_rect_location = program->fragment_shader().clamp_rect_location();
1854 alpha_location = program->fragment_shader().alpha_location(); 1856 alpha_location = program->fragment_shader().alpha_location();
1855 } else { 1857 } else {
1856 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); 1858 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision);
1857 DCHECK(program && (program->initialized() || IsContextLost())); 1859 DCHECK(program && (program->initialized() || IsContextLost()));
1858 SetUseProgram(program->program()); 1860 SetUseProgram(program->program());
1859 matrix_location = program->vertex_shader().matrix_location(); 1861 matrix_location = program->vertex_shader().matrix_location();
1860 tex_scale_location = program->vertex_shader().tex_scale_location(); 1862 tex_scale_location = program->vertex_shader().tex_scale_location();
1861 tex_offset_location = program->vertex_shader().tex_offset_location(); 1863 tex_offset_location = program->vertex_shader().tex_offset_location();
1862 y_texture_location = program->fragment_shader().y_texture_location(); 1864 y_texture_location = program->fragment_shader().y_texture_location();
1863 u_texture_location = program->fragment_shader().u_texture_location(); 1865 u_texture_location = program->fragment_shader().u_texture_location();
1864 v_texture_location = program->fragment_shader().v_texture_location(); 1866 v_texture_location = program->fragment_shader().v_texture_location();
1865 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1867 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
1866 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 1868 yuv_adj_location = program->fragment_shader().yuv_adj_location();
1869 clamp_rect_location = program->fragment_shader().clamp_rect_location();
1867 alpha_location = program->fragment_shader().alpha_location(); 1870 alpha_location = program->fragment_shader().alpha_location();
1868 } 1871 }
1869 1872
1870 GLC(gl_, 1873 GLC(gl_,
1871 gl_->Uniform2f(tex_scale_location, 1874 gl_->Uniform2f(tex_scale_location,
1872 quad->tex_coord_rect.width(), 1875 quad->tex_coord_rect.width(),
1873 quad->tex_coord_rect.height())); 1876 quad->tex_coord_rect.height()));
1874 GLC(gl_, 1877 GLC(gl_,
1875 gl_->Uniform2f(tex_offset_location, 1878 gl_->Uniform2f(tex_offset_location,
1876 quad->tex_coord_rect.x(), 1879 quad->tex_coord_rect.x(),
1877 quad->tex_coord_rect.y())); 1880 quad->tex_coord_rect.y()));
1881 // Clamping to half a texel inside the tex coord rect prevents bilinear
1882 // filtering from filtering outside the tex coord rect.
1883 gfx::RectF clamp_rect(quad->tex_coord_rect);
1884 // Special case: empty texture size implies no clamping.
1885 if (!quad->tex_size.IsEmpty()) {
1886 clamp_rect.Inset(0.5f / quad->tex_size.width(),
1887 0.5f / quad->tex_size.height());
1888 }
1889 GLC(gl_, gl_->Uniform4f(clamp_rect_location, clamp_rect.x(), clamp_rect.y(),
1890 clamp_rect.right(), clamp_rect.bottom()));
1891
1878 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); 1892 GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
1879 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); 1893 GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
1880 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); 1894 GLC(gl_, gl_->Uniform1i(v_texture_location, 3));
1881 if (use_alpha_plane) 1895 if (use_alpha_plane)
1882 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); 1896 GLC(gl_, gl_->Uniform1i(a_texture_location, 4));
1883 1897
1884 // These values are magic numbers that are used in the transformation from YUV 1898 // These values are magic numbers that are used in the transformation from YUV
1885 // to RGB color values. They are taken from the following webpage: 1899 // to RGB color values. They are taken from the following webpage:
1886 // http://www.fourcc.org/fccyvrgb.php 1900 // http://www.fourcc.org/fccyvrgb.php
1887 float yuv_to_rgb_rec601[9] = { 1901 float yuv_to_rgb_rec601[9] = {
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 context_support_->ScheduleOverlayPlane( 3305 context_support_->ScheduleOverlayPlane(
3292 overlay.plane_z_order, 3306 overlay.plane_z_order,
3293 overlay.transform, 3307 overlay.transform,
3294 pending_overlay_resources_.back()->texture_id(), 3308 pending_overlay_resources_.back()->texture_id(),
3295 overlay.display_rect, 3309 overlay.display_rect,
3296 overlay.uv_rect); 3310 overlay.uv_rect);
3297 } 3311 }
3298 } 3312 }
3299 3313
3300 } // namespace cc 3314 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/filter_operations.cc ('k') | cc/output/output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698