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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_srgb_converter.cc

Issue 2362163003: [Command buffer] blitFramebuffer should not disable scissor test (Closed)
Patch Set: Fix bots failure: we don't disable scissor test deliberately now Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "gpu/command_buffer/service/gles2_cmd_srgb_converter.h" 5 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h"
6 6
7 #include "gpu/command_buffer/service/texture_manager.h" 7 #include "gpu/command_buffer/service/texture_manager.h"
8 #include "ui/gl/gl_version_info.h" 8 #include "ui/gl/gl_version_info.h"
9 9
10 namespace { 10 namespace {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 GLint dstY1, 178 GLint dstY1,
179 GLbitfield mask, 179 GLbitfield mask,
180 GLenum filter, 180 GLenum filter,
181 const gfx::Size& framebuffer_size, 181 const gfx::Size& framebuffer_size,
182 GLuint src_framebuffer, 182 GLuint src_framebuffer,
183 GLenum src_framebuffer_internal_format, 183 GLenum src_framebuffer_internal_format,
184 GLenum src_framebuffer_format, 184 GLenum src_framebuffer_format,
185 GLenum src_framebuffer_type, 185 GLenum src_framebuffer_type,
186 GLuint dst_framebuffer, 186 GLuint dst_framebuffer,
187 bool decode, 187 bool decode,
188 bool encode) { 188 bool encode,
189 bool enable_scissor_test) {
189 // This function blits srgb image in src fb to srgb image in dst fb. 190 // This function blits srgb image in src fb to srgb image in dst fb.
190 // The steps are: 191 // The steps are:
191 // 1) Copy and crop pixels from source srgb image to the 1st texture(srgb). 192 // 1) Copy and crop pixels from source srgb image to the 1st texture(srgb).
192 // 2) Sampling from the 1st texture and drawing to the 2nd texture(linear). 193 // 2) Sampling from the 1st texture and drawing to the 2nd texture(linear).
193 // During this step, color space is converted from srgb to linear. 194 // During this step, color space is converted from srgb to linear.
194 // 3) Blit pixels from the 2nd texture to the 3rd texture(linear). 195 // 3) Blit pixels from the 2nd texture to the 3rd texture(linear).
195 // 4) Sampling from the 3rd texture and drawing to the dst image(srgb). 196 // 4) Sampling from the 3rd texture and drawing to the dst image(srgb).
196 // During this step, color space is converted from linear to srgb. 197 // During this step, color space is converted from linear to srgb.
197 // If we need to blit from linear to srgb or vice versa, some steps will be 198 // If we need to blit from linear to srgb or vice versa, some steps will be
198 // skipped. 199 // skipped.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 decode ? GL_RGBA : src_framebuffer_format, 277 decode ? GL_RGBA : src_framebuffer_format,
277 decode ? GL_UNSIGNED_BYTE : src_framebuffer_type, 278 decode ? GL_UNSIGNED_BYTE : src_framebuffer_type,
278 nullptr); 279 nullptr);
279 280
280 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); 281 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_);
281 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 282 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
282 GL_TEXTURE_2D, srgb_converter_textures_[0], 0); 283 GL_TEXTURE_2D, srgb_converter_textures_[0], 0);
283 } else { 284 } else {
284 // Set approriate draw framebuffer if encoding is skipped. 285 // Set approriate draw framebuffer if encoding is skipped.
285 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, dst_framebuffer); 286 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, dst_framebuffer);
287
288 if (enable_scissor_test) {
289 glEnable(GL_SCISSOR_TEST);
290 }
286 } 291 }
287 292
288 glBlitFramebuffer( 293 glBlitFramebuffer(
289 decode ? (srcX0 < srcX1 ? 0 - xoffset : width_read - xoffset) : srcX0, 294 decode ? (srcX0 < srcX1 ? 0 - xoffset : width_read - xoffset) : srcX0,
290 decode ? (srcY0 < srcY1 ? 0 - yoffset : height_read - yoffset) : srcY0, 295 decode ? (srcY0 < srcY1 ? 0 - yoffset : height_read - yoffset) : srcY0,
291 decode ? (srcX0 < srcX1 ? width_read - xoffset : 0 - xoffset) : srcX1, 296 decode ? (srcX0 < srcX1 ? width_read - xoffset : 0 - xoffset) : srcX1,
292 decode ? (srcY0 < srcY1 ? height_read - yoffset : 0 - yoffset) : srcY1, 297 decode ? (srcY0 < srcY1 ? height_read - yoffset : 0 - yoffset) : srcY1,
293 encode ? (dstX0 < dstX1 ? 0 : width_draw) : dstX0, 298 encode ? (dstX0 < dstX1 ? 0 : width_draw) : dstX0,
294 encode ? (dstY0 < dstY1 ? 0 : height_draw) : dstY0, 299 encode ? (dstY0 < dstY1 ? 0 : height_draw) : dstY0,
295 encode ? (dstX0 < dstX1 ? width_draw : 0) : dstX1, 300 encode ? (dstX0 < dstX1 ? width_draw : 0) : dstX1,
296 encode ? (dstY0 < dstY1 ? height_draw : 0) : dstY1, 301 encode ? (dstY0 < dstY1 ? height_draw : 0) : dstY1,
297 mask, filter); 302 mask, filter);
298 303
299 // Sampling from the 3rd texture(linear) and drawing to the target srgb image. 304 // Sampling from the 3rd texture(linear) and drawing to the target srgb image.
300 // During this step, color space is converted from linear to srgb. We should 305 // During this step, color space is converted from linear to srgb. We should
301 // set appropriate viewport to draw to the correct location in target FB. 306 // set appropriate viewport to draw to the correct location in target FB.
302 if (encode) { 307 if (encode) {
303 GLuint xstart = dstX0 < dstX1 ? dstX0 : dstX1; 308 GLuint xstart = dstX0 < dstX1 ? dstX0 : dstX1;
304 GLuint ystart = dstY0 < dstY1 ? dstY0 : dstY1; 309 GLuint ystart = dstY0 < dstY1 ? dstY0 : dstY1;
305 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, dst_framebuffer); 310 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, dst_framebuffer);
306 glUseProgram(srgb_converter_program_); 311 glUseProgram(srgb_converter_program_);
307 glViewport(xstart, ystart, width_draw, height_draw); 312 glViewport(xstart, ystart, width_draw, height_draw);
308 313
309 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[0]); 314 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[0]);
310 glBindVertexArrayOES(srgb_converter_vao_); 315 glBindVertexArrayOES(srgb_converter_vao_);
311 316
317 if (enable_scissor_test) {
318 glEnable(GL_SCISSOR_TEST);
319 }
320
312 glDrawArrays(GL_TRIANGLES, 0, 6); 321 glDrawArrays(GL_TRIANGLES, 0, 6);
313 } 322 }
314 323
315 // Restore state 324 // Restore state
316 decoder->RestoreAllAttributes(); 325 decoder->RestoreAllAttributes();
317 decoder->RestoreTextureUnitBindings(0); 326 decoder->RestoreTextureUnitBindings(0);
318 decoder->RestoreActiveTexture(); 327 decoder->RestoreActiveTexture();
319 decoder->RestoreProgramBindings(); 328 decoder->RestoreProgramBindings();
320 decoder->RestoreBufferBindings(); 329 decoder->RestoreBufferBindings();
321 decoder->RestoreFramebufferBindings(); 330 decoder->RestoreFramebufferBindings();
322 decoder->RestoreGlobalState(); 331 decoder->RestoreGlobalState();
323 } 332 }
324 333
325 } // namespace gles2. 334 } // namespace gles2.
326 } // namespace gpu 335 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698