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

Side by Side Diff: content/common/gpu/image_transport_surface_fbo_mac.mm

Issue 797533002: Add a glBegin/End pair to make glBindFramebuffer work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/gpu/image_transport_surface_fbo_mac.h" 5 #include "content/common/gpu/image_transport_surface_fbo_mac.h"
6 6
7 #include "content/common/gpu/gpu_messages.h" 7 #include "content/common/gpu/gpu_messages.h"
8 #include "content/common/gpu/image_transport_surface_calayer_mac.h" 8 #include "content/common/gpu/image_transport_surface_calayer_mac.h"
9 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" 9 #include "content/common/gpu/image_transport_surface_iosurface_mac.h"
10 #include "ui/base/cocoa/remote_layer_api.h" 10 #include "ui/base/cocoa/remote_layer_api.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 if (made_current_) 75 if (made_current_)
76 return true; 76 return true;
77 77
78 AllocateOrResizeFramebuffer(gfx::Size(1, 1), 1.f); 78 AllocateOrResizeFramebuffer(gfx::Size(1, 1), 1.f);
79 79
80 made_current_ = true; 80 made_current_ = true;
81 return true; 81 return true;
82 } 82 }
83 83
84 void ImageTransportSurfaceFBO::NotifyWasBound() {
85 // Sometimes calling glBindFramebuffer doesn't seem to be enough to get
86 // rendered contents to show up in the color attachment. It appears that doing
87 // a glBegin/End pair with program 0 is enough to tickle the driver into
88 // actually effecting the binding.
89 // http://crbug.com/435786
90 DCHECK(has_complete_framebuffer_);
91
92 // We will restore the current program after the dummy glBegin/End pair.
93 // Ensure that we will be able to restore this state before attempting to
94 // change it.
95 GLint old_program_signed = 0;
96 glGetIntegerv(GL_CURRENT_PROGRAM, &old_program_signed);
97 GLuint old_program = static_cast<GLuint>(old_program_signed);
98 if (old_program && glIsProgram(old_program)) {
99 // A deleted program cannot be re-bound.
100 GLint delete_status = GL_FALSE;
101 glGetProgramiv(old_program, GL_DELETE_STATUS, &delete_status);
102 if (delete_status == GL_TRUE)
103 return;
104 // A program which has had the most recent link fail cannot be re-bound.
105 GLint link_status = GL_FALSE;
106 glGetProgramiv(old_program, GL_LINK_STATUS, &link_status);
107 if (link_status != GL_TRUE)
108 return;
109 }
110
111 // Issue the dummy call and then restore the state.
112 glUseProgram(0);
113 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
114 DCHECK(status == GL_FRAMEBUFFER_COMPLETE);
115 glBegin(GL_TRIANGLES);
116 glEnd();
117 glUseProgram(old_program);
118 }
119
84 unsigned int ImageTransportSurfaceFBO::GetBackingFrameBufferObject() { 120 unsigned int ImageTransportSurfaceFBO::GetBackingFrameBufferObject() {
85 return fbo_id_; 121 return fbo_id_;
86 } 122 }
87 123
88 bool ImageTransportSurfaceFBO::SetBackbufferAllocation(bool allocation) { 124 bool ImageTransportSurfaceFBO::SetBackbufferAllocation(bool allocation) {
89 if (backbuffer_suggested_allocation_ == allocation) 125 if (backbuffer_suggested_allocation_ == allocation)
90 return true; 126 return true;
91 backbuffer_suggested_allocation_ = allocation; 127 backbuffer_suggested_allocation_ = allocation;
92 AdjustBufferAllocation(); 128 AdjustBufferAllocation();
93 if (!allocation) 129 if (!allocation)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 361 return;
326 } 362 }
327 363
328 has_complete_framebuffer_ = true; 364 has_complete_framebuffer_ = true;
329 365
330 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id); 366 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, previous_texture_id);
331 // The FBO remains bound for this GL context. 367 // The FBO remains bound for this GL context.
332 } 368 }
333 369
334 } // namespace content 370 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_fbo_mac.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698