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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/software_renderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index e614d8b56131bd8402fde62e17b13980da162268..b6f696d838cb0a76832d64096484e8e43c90bac6 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -417,6 +417,8 @@ void GLRenderer::PrepareSurfaceForPass(
DrawingFrame* frame,
SurfaceInitializationMode initialization_mode,
const gfx::Rect& render_pass_scissor) {
+ SetViewport();
+
switch (initialization_mode) {
case SURFACE_INITIALIZATION_MODE_PRESERVE:
EnsureScissorTestDisabled();
@@ -1222,10 +1224,12 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge));
if (locations.viewport != -1) {
- float viewport[4] = {static_cast<float>(viewport_.x()),
- static_cast<float>(viewport_.y()),
- static_cast<float>(viewport_.width()),
- static_cast<float>(viewport_.height()), };
+ float viewport[4] = {
+ static_cast<float>(current_window_space_viewport_.x()),
+ static_cast<float>(current_window_space_viewport_.y()),
+ static_cast<float>(current_window_space_viewport_.width()),
+ static_cast<float>(current_window_space_viewport_.height()),
+ };
GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport));
}
@@ -1610,10 +1614,12 @@ void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
(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()), };
+ float viewport[4] = {
+ static_cast<float>(current_window_space_viewport_.x()),
+ static_cast<float>(current_window_space_viewport_.y()),
+ static_cast<float>(current_window_space_viewport_.width()),
+ static_cast<float>(current_window_space_viewport_.height()),
+ };
GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
}
@@ -1777,10 +1783,10 @@ void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame,
GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0));
float viewport[4] = {
- static_cast<float>(viewport_.x()),
- static_cast<float>(viewport_.y()),
- static_cast<float>(viewport_.width()),
- static_cast<float>(viewport_.height()),
+ static_cast<float>(current_window_space_viewport_.x()),
+ static_cast<float>(current_window_space_viewport_.y()),
+ static_cast<float>(current_window_space_viewport_.width()),
+ static_cast<float>(current_window_space_viewport_.height()),
};
GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
@@ -2952,13 +2958,11 @@ void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
scissor_rect_needs_reset_ = false;
}
-void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
- viewport_ = window_space_viewport;
- GLC(gl_,
- gl_->Viewport(window_space_viewport.x(),
- window_space_viewport.y(),
- window_space_viewport.width(),
- window_space_viewport.height()));
+void GLRenderer::SetViewport() {
+ GLC(gl_, gl_->Viewport(current_window_space_viewport_.x(),
+ current_window_space_viewport_.y(),
+ current_window_space_viewport_.width(),
+ current_window_space_viewport_.height()));
}
void GLRenderer::InitializeSharedObjects() {
@@ -3503,6 +3507,11 @@ void GLRenderer::RestoreGLState() {
void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) {
UseRenderPass(frame, frame->current_render_pass);
+
+ // Call SetViewport directly, rather than through PrepareSurfaceForPass.
+ // PrepareSurfaceForPass also clears the surface, which is not desired when
+ // restoring.
+ SetViewport();
}
bool GLRenderer::IsContextLost() {
« 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