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

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

Issue 1035863002: Remove SetDrawViewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetupViewport > SetViewport Created 5 years, 9 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/gl_renderer.h ('k') | cc/output/software_renderer.h » ('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>
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 GLenum attachments[] = {static_cast<GLenum>( 410 GLenum attachments[] = {static_cast<GLenum>(
411 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; 411 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)};
412 gl_->DiscardFramebufferEXT( 412 gl_->DiscardFramebufferEXT(
413 GL_FRAMEBUFFER, arraysize(attachments), attachments); 413 GL_FRAMEBUFFER, arraysize(attachments), attachments);
414 } 414 }
415 415
416 void GLRenderer::PrepareSurfaceForPass( 416 void GLRenderer::PrepareSurfaceForPass(
417 DrawingFrame* frame, 417 DrawingFrame* frame,
418 SurfaceInitializationMode initialization_mode, 418 SurfaceInitializationMode initialization_mode,
419 const gfx::Rect& render_pass_scissor) { 419 const gfx::Rect& render_pass_scissor) {
420 SetViewport();
421
420 switch (initialization_mode) { 422 switch (initialization_mode) {
421 case SURFACE_INITIALIZATION_MODE_PRESERVE: 423 case SURFACE_INITIALIZATION_MODE_PRESERVE:
422 EnsureScissorTestDisabled(); 424 EnsureScissorTestDisabled();
423 return; 425 return;
424 case SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR: 426 case SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR:
425 EnsureScissorTestDisabled(); 427 EnsureScissorTestDisabled();
426 DiscardPixels(); 428 DiscardPixels();
427 ClearFramebuffer(frame); 429 ClearFramebuffer(frame);
428 break; 430 break;
429 case SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR: 431 case SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR:
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 mask_uv_rect.width() / tex_scale_x, 1217 mask_uv_rect.width() / tex_scale_x,
1216 -mask_uv_rect.height() / tex_scale_y)); 1218 -mask_uv_rect.height() / tex_scale_y));
1217 1219
1218 last_texture_unit = 1; 1220 last_texture_unit = 1;
1219 } 1221 }
1220 1222
1221 if (locations.edge != -1) 1223 if (locations.edge != -1)
1222 GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge)); 1224 GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge));
1223 1225
1224 if (locations.viewport != -1) { 1226 if (locations.viewport != -1) {
1225 float viewport[4] = {static_cast<float>(viewport_.x()), 1227 float viewport[4] = {
1226 static_cast<float>(viewport_.y()), 1228 static_cast<float>(current_window_space_viewport_.x()),
1227 static_cast<float>(viewport_.width()), 1229 static_cast<float>(current_window_space_viewport_.y()),
1228 static_cast<float>(viewport_.height()), }; 1230 static_cast<float>(current_window_space_viewport_.width()),
1231 static_cast<float>(current_window_space_viewport_.height()),
1232 };
1229 GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport)); 1233 GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport));
1230 } 1234 }
1231 1235
1232 if (locations.color_matrix != -1) { 1236 if (locations.color_matrix != -1) {
1233 float matrix[16]; 1237 float matrix[16];
1234 for (int i = 0; i < 4; ++i) { 1238 for (int i = 0; i < 4; ++i) {
1235 for (int j = 0; j < 4; ++j) 1239 for (int j = 0; j < 4; ++j)
1236 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]); 1240 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]);
1237 } 1241 }
1238 GLC(gl_, 1242 GLC(gl_,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 } 1607 }
1604 SetUseProgram(uniforms.program); 1608 SetUseProgram(uniforms.program);
1605 1609
1606 GLC(gl_, 1610 GLC(gl_,
1607 gl_->Uniform4f(uniforms.color_location, 1611 gl_->Uniform4f(uniforms.color_location,
1608 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1612 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1609 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1613 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
1610 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, 1614 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
1611 alpha)); 1615 alpha));
1612 if (use_aa) { 1616 if (use_aa) {
1613 float viewport[4] = {static_cast<float>(viewport_.x()), 1617 float viewport[4] = {
1614 static_cast<float>(viewport_.y()), 1618 static_cast<float>(current_window_space_viewport_.x()),
1615 static_cast<float>(viewport_.width()), 1619 static_cast<float>(current_window_space_viewport_.y()),
1616 static_cast<float>(viewport_.height()), }; 1620 static_cast<float>(current_window_space_viewport_.width()),
1621 static_cast<float>(current_window_space_viewport_.height()),
1622 };
1617 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport)); 1623 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
1618 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge)); 1624 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
1619 } 1625 }
1620 1626
1621 // Enable blending when the quad properties require it or if we decided 1627 // Enable blending when the quad properties require it or if we decided
1622 // to use antialiasing. 1628 // to use antialiasing.
1623 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1629 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1624 1630
1625 // Normalize to tile_rect. 1631 // Normalize to tile_rect.
1626 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1632 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 &uniforms); 1776 &uniforms);
1771 } else { 1777 } else {
1772 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler), 1778 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler),
1773 &uniforms); 1779 &uniforms);
1774 } 1780 }
1775 1781
1776 SetUseProgram(uniforms.program); 1782 SetUseProgram(uniforms.program);
1777 GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0)); 1783 GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0));
1778 1784
1779 float viewport[4] = { 1785 float viewport[4] = {
1780 static_cast<float>(viewport_.x()), 1786 static_cast<float>(current_window_space_viewport_.x()),
1781 static_cast<float>(viewport_.y()), 1787 static_cast<float>(current_window_space_viewport_.y()),
1782 static_cast<float>(viewport_.width()), 1788 static_cast<float>(current_window_space_viewport_.width()),
1783 static_cast<float>(viewport_.height()), 1789 static_cast<float>(current_window_space_viewport_.height()),
1784 }; 1790 };
1785 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport)); 1791 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
1786 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge)); 1792 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
1787 1793
1788 GLC(gl_, 1794 GLC(gl_,
1789 gl_->Uniform4f(uniforms.vertex_tex_transform_location, 1795 gl_->Uniform4f(uniforms.vertex_tex_transform_location,
1790 vertex_tex_translate_x, 1796 vertex_tex_translate_x,
1791 vertex_tex_translate_y, 1797 vertex_tex_translate_y,
1792 vertex_tex_scale_x, 1798 vertex_tex_scale_x,
1793 vertex_tex_scale_y)); 1799 vertex_tex_scale_y));
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 FlushTextureQuadCache(SHARED_BINDING); 2951 FlushTextureQuadCache(SHARED_BINDING);
2946 GLC(gl_, 2952 GLC(gl_,
2947 gl_->Scissor(scissor_rect.x(), 2953 gl_->Scissor(scissor_rect.x(),
2948 scissor_rect.y(), 2954 scissor_rect.y(),
2949 scissor_rect.width(), 2955 scissor_rect.width(),
2950 scissor_rect.height())); 2956 scissor_rect.height()));
2951 2957
2952 scissor_rect_needs_reset_ = false; 2958 scissor_rect_needs_reset_ = false;
2953 } 2959 }
2954 2960
2955 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) { 2961 void GLRenderer::SetViewport() {
2956 viewport_ = window_space_viewport; 2962 GLC(gl_, gl_->Viewport(current_window_space_viewport_.x(),
2957 GLC(gl_, 2963 current_window_space_viewport_.y(),
2958 gl_->Viewport(window_space_viewport.x(), 2964 current_window_space_viewport_.width(),
2959 window_space_viewport.y(), 2965 current_window_space_viewport_.height()));
2960 window_space_viewport.width(),
2961 window_space_viewport.height()));
2962 } 2966 }
2963 2967
2964 void GLRenderer::InitializeSharedObjects() { 2968 void GLRenderer::InitializeSharedObjects() {
2965 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 2969 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2966 2970
2967 // Create an FBO for doing offscreen rendering. 2971 // Create an FBO for doing offscreen rendering.
2968 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_)); 2972 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
2969 2973
2970 shared_geometry_ = 2974 shared_geometry_ =
2971 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect())); 2975 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect()));
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 scissor_rect_.y(), 3500 scissor_rect_.y(),
3497 scissor_rect_.width(), 3501 scissor_rect_.width(),
3498 scissor_rect_.height())); 3502 scissor_rect_.height()));
3499 } else { 3503 } else {
3500 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 3504 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
3501 } 3505 }
3502 } 3506 }
3503 3507
3504 void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) { 3508 void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) {
3505 UseRenderPass(frame, frame->current_render_pass); 3509 UseRenderPass(frame, frame->current_render_pass);
3510
3511 // Call SetViewport directly, rather than through PrepareSurfaceForPass.
3512 // PrepareSurfaceForPass also clears the surface, which is not desired when
3513 // restoring.
3514 SetViewport();
3506 } 3515 }
3507 3516
3508 bool GLRenderer::IsContextLost() { 3517 bool GLRenderer::IsContextLost() {
3509 return output_surface_->context_provider()->IsContextLost(); 3518 return output_surface_->context_provider()->IsContextLost();
3510 } 3519 }
3511 3520
3512 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { 3521 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) {
3513 if (!frame->overlay_list.size()) 3522 if (!frame->overlay_list.size())
3514 return; 3523 return;
3515 3524
(...skipping 13 matching lines...) Expand all
3529 context_support_->ScheduleOverlayPlane( 3538 context_support_->ScheduleOverlayPlane(
3530 overlay.plane_z_order, 3539 overlay.plane_z_order,
3531 overlay.transform, 3540 overlay.transform,
3532 pending_overlay_resources_.back()->texture_id(), 3541 pending_overlay_resources_.back()->texture_id(),
3533 overlay.display_rect, 3542 overlay.display_rect,
3534 overlay.uv_rect); 3543 overlay.uv_rect);
3535 } 3544 }
3536 } 3545 }
3537 3546
3538 } // namespace cc 3547 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/software_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698