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

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

Issue 2286593002: [Command Buffer] emulate SRGB color format for BlitFramebuffer in OpenGL (Closed)
Patch Set: addressed feedbacks from zhenyao and qiankun Created 4 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 26 matching lines...) Expand all
37 #include "gpu/command_buffer/service/error_state.h" 37 #include "gpu/command_buffer/service/error_state.h"
38 #include "gpu/command_buffer/service/feature_info.h" 38 #include "gpu/command_buffer/service/feature_info.h"
39 #include "gpu/command_buffer/service/framebuffer_manager.h" 39 #include "gpu/command_buffer/service/framebuffer_manager.h"
40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h"
41 #include "gpu/command_buffer/service/gl_utils.h" 41 #include "gpu/command_buffer/service/gl_utils.h"
42 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" 42 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h"
43 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" 43 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h"
44 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" 44 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h"
45 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 45 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
46 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" 46 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
47 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h"
47 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 48 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
48 #include "gpu/command_buffer/service/gpu_preferences.h" 49 #include "gpu/command_buffer/service/gpu_preferences.h"
49 #include "gpu/command_buffer/service/gpu_state_tracer.h" 50 #include "gpu/command_buffer/service/gpu_state_tracer.h"
50 #include "gpu/command_buffer/service/gpu_tracer.h" 51 #include "gpu/command_buffer/service/gpu_tracer.h"
51 #include "gpu/command_buffer/service/image_factory.h" 52 #include "gpu/command_buffer/service/image_factory.h"
52 #include "gpu/command_buffer/service/image_manager.h" 53 #include "gpu/command_buffer/service/image_manager.h"
53 #include "gpu/command_buffer/service/logger.h" 54 #include "gpu/command_buffer/service/logger.h"
54 #include "gpu/command_buffer/service/mailbox_manager.h" 55 #include "gpu/command_buffer/service/mailbox_manager.h"
55 #include "gpu/command_buffer/service/memory_tracking.h" 56 #include "gpu/command_buffer/service/memory_tracking.h"
56 #include "gpu/command_buffer/service/path_manager.h" 57 #include "gpu/command_buffer/service/path_manager.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 876
876 // Deletes the TransformFeedback info for the given transformfeedback. 877 // Deletes the TransformFeedback info for the given transformfeedback.
877 void RemoveTransformFeedback(GLuint client_id) { 878 void RemoveTransformFeedback(GLuint client_id) {
878 transform_feedback_manager_->RemoveTransformFeedback(client_id); 879 transform_feedback_manager_->RemoveTransformFeedback(client_id);
879 } 880 }
880 881
881 // Get the size (in pixels) of the currently bound frame buffer (either FBO 882 // Get the size (in pixels) of the currently bound frame buffer (either FBO
882 // or regular back buffer). 883 // or regular back buffer).
883 gfx::Size GetBoundReadFramebufferSize(); 884 gfx::Size GetBoundReadFramebufferSize();
884 885
885 // Get the service side ID for the bound read frame buffer. 886 // Get the service side ID for the bound read framebuffer.
886 // If it's back buffer, 0 is returned. 887 // If it's back buffer, 0 is returned.
887 GLuint GetBoundReadFramebufferServiceId(); 888 GLuint GetBoundReadFramebufferServiceId();
888 889
890 // Get the service side ID for the bound draw framebuffer.
891 // If it's back buffer, 0 is returned.
892 GLuint GetBoundDrawFramebufferServiceId();
893
889 // Get the format/type of the currently bound frame buffer (either FBO or 894 // Get the format/type of the currently bound frame buffer (either FBO or
890 // regular back buffer). 895 // regular back buffer).
891 // If the color image is a renderbuffer, returns 0 for type. 896 // If the color image is a renderbuffer, returns 0 for type.
892 GLenum GetBoundReadFramebufferTextureType(); 897 GLenum GetBoundReadFramebufferTextureType();
893 GLenum GetBoundReadFramebufferInternalFormat(); 898 GLenum GetBoundReadFramebufferInternalFormat();
894 899
895 // Get the i-th draw buffer's internal format/type from the bound framebuffer. 900 // Get the i-th draw buffer's internal format/type from the bound framebuffer.
896 // If no framebuffer is bound, or no image is attached, or the DrawBuffers 901 // If no framebuffer is bound, or no image is attached, or the DrawBuffers
897 // setting for that image is GL_NONE, return 0. 902 // setting for that image is GL_NONE, return 0.
898 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); 903 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i);
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 // Whether a texture backed by a Chromium Image needs to emulate GL_RGB format 2069 // Whether a texture backed by a Chromium Image needs to emulate GL_RGB format
2065 // using GL_RGBA and glColorMask. 2070 // using GL_RGBA and glColorMask.
2066 bool ChromiumImageNeedsRGBEmulation(); 2071 bool ChromiumImageNeedsRGBEmulation();
2067 2072
2068 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and 2073 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and
2069 // equivalent functions reset shared state. 2074 // equivalent functions reset shared state.
2070 void ClearScheduleCALayerState(); 2075 void ClearScheduleCALayerState();
2071 2076
2072 bool InitializeCopyTexImageBlitter(const char* function_name); 2077 bool InitializeCopyTexImageBlitter(const char* function_name);
2073 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2078 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2079 bool InitializeSRGBDecoder(const char* function_name);
2080 bool InitializeSRGBEncoder(const char* function_name);
2074 // Generate a member function prototype for each command in an automated and 2081 // Generate a member function prototype for each command in an automated and
2075 // typesafe way. 2082 // typesafe way.
2076 #define GLES2_CMD_OP(name) \ 2083 #define GLES2_CMD_OP(name) \
2077 Error Handle##name(uint32_t immediate_data_size, const void* data); 2084 Error Handle##name(uint32_t immediate_data_size, const void* data);
2078 2085
2079 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2086 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2080 2087
2081 #undef GLES2_CMD_OP 2088 #undef GLES2_CMD_OP
2082 2089
2083 // The GL context this decoder renders to on behalf of the client. 2090 // The GL context this decoder renders to on behalf of the client.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. 2262 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture.
2256 bool should_use_native_gmb_for_backbuffer_; 2263 bool should_use_native_gmb_for_backbuffer_;
2257 2264
2258 // Log extra info. 2265 // Log extra info.
2259 bool service_logging_; 2266 bool service_logging_;
2260 2267
2261 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> 2268 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager>
2262 apply_framebuffer_attachment_cmaa_intel_; 2269 apply_framebuffer_attachment_cmaa_intel_;
2263 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; 2270 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_;
2264 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; 2271 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
2272 std::unique_ptr<SRGBConverter> srgb_converter_;
2265 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; 2273 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_;
2266 2274
2267 // Cached values of the currently assigned viewport dimensions. 2275 // Cached values of the currently assigned viewport dimensions.
2268 GLsizei viewport_max_width_; 2276 GLsizei viewport_max_width_;
2269 GLsizei viewport_max_height_; 2277 GLsizei viewport_max_height_;
2270 2278
2271 // Command buffer stats. 2279 // Command buffer stats.
2272 base::TimeDelta total_processing_commands_time_; 2280 base::TimeDelta total_processing_commands_time_;
2273 2281
2274 // States related to each manager. 2282 // States related to each manager.
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
4219 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 4227 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
4220 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); 4228 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target);
4221 bool valid = CheckFramebufferValid( 4229 bool valid = CheckFramebufferValid(
4222 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4230 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4223 4231
4224 target = features().chromium_framebuffer_multisample ? 4232 target = features().chromium_framebuffer_multisample ?
4225 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 4233 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4226 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); 4234 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target);
4227 valid = valid && CheckFramebufferValid( 4235 valid = valid && CheckFramebufferValid(
4228 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4236 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4229
4230 if (valid && feature_info_->feature_flags().desktop_srgb_support) {
4231 bool enable_framebuffer_srgb =
4232 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) ||
4233 (read_framebuffer && read_framebuffer->HasSRGBAttachments());
4234 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4235 }
4236
4237 return valid; 4237 return valid;
4238 } 4238 }
4239 4239
4240 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 4240 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4241 GLenum internalformat) { 4241 GLenum internalformat) {
4242 switch (internalformat) { 4242 switch (internalformat) {
4243 case GL_SRGB_EXT: 4243 case GL_SRGB_EXT:
4244 case GL_SRGB_ALPHA_EXT: 4244 case GL_SRGB_ALPHA_EXT:
4245 case GL_SRGB8: 4245 case GL_SRGB8:
4246 case GL_SRGB8_ALPHA8: 4246 case GL_SRGB8_ALPHA8:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 } 4292 }
4293 if (offscreen_target_frame_buffer_.get()) { 4293 if (offscreen_target_frame_buffer_.get()) {
4294 return offscreen_target_frame_buffer_->id(); 4294 return offscreen_target_frame_buffer_->id();
4295 } 4295 }
4296 if (surface_.get()) { 4296 if (surface_.get()) {
4297 return surface_->GetBackingFramebufferObject(); 4297 return surface_->GetBackingFramebufferObject();
4298 } 4298 }
4299 return 0; 4299 return 0;
4300 } 4300 }
4301 4301
4302 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() {
4303 Framebuffer* framebuffer =
4304 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4305 if (framebuffer) {
4306 return framebuffer->service_id();
4307 }
4308 if (offscreen_resolved_frame_buffer_.get()) {
Zhenyao Mo 2016/09/01 19:28:33 This is incorrect. It should be offscreen_target_
yunchao 2016/09/02 14:11:16 Done.
4309 return offscreen_resolved_frame_buffer_->id();
4310 }
4311 if (offscreen_target_frame_buffer_.get()) {
4312 return offscreen_target_frame_buffer_->id();
4313 }
4314 if (surface_.get()) {
4315 return surface_->GetBackingFramebufferObject();
4316 }
4317 return 0;
4318 }
4319
4302 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { 4320 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() {
4303 Framebuffer* framebuffer = 4321 Framebuffer* framebuffer =
4304 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4322 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4305 if (framebuffer) { 4323 if (framebuffer) {
4306 return framebuffer->GetReadBufferTextureType(); 4324 return framebuffer->GetReadBufferTextureType();
4307 } else { // Back buffer. 4325 } else { // Back buffer.
4308 if (back_buffer_read_buffer_ == GL_NONE) 4326 if (back_buffer_read_buffer_ == GL_NONE)
4309 return 0; 4327 return 0;
4310 return GL_UNSIGNED_BYTE; 4328 return GL_UNSIGNED_BYTE;
4311 } 4329 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 if (copy_tex_image_blit_.get()) { 4546 if (copy_tex_image_blit_.get()) {
4529 copy_tex_image_blit_->Destroy(); 4547 copy_tex_image_blit_->Destroy();
4530 copy_tex_image_blit_.reset(); 4548 copy_tex_image_blit_.reset();
4531 } 4549 }
4532 4550
4533 if (copy_texture_CHROMIUM_.get()) { 4551 if (copy_texture_CHROMIUM_.get()) {
4534 copy_texture_CHROMIUM_->Destroy(); 4552 copy_texture_CHROMIUM_->Destroy();
4535 copy_texture_CHROMIUM_.reset(); 4553 copy_texture_CHROMIUM_.reset();
4536 } 4554 }
4537 4555
4556 if (srgb_converter_.get()) {
4557 srgb_converter_->Destroy();
4558 srgb_converter_.reset();
4559 }
4560
4538 clear_framebuffer_blit_.reset(); 4561 clear_framebuffer_blit_.reset();
4539 4562
4540 if (state_.current_program.get()) { 4563 if (state_.current_program.get()) {
4541 program_manager()->UnuseProgram(shader_manager(), 4564 program_manager()->UnuseProgram(shader_manager(),
4542 state_.current_program.get()); 4565 state_.current_program.get());
4543 } 4566 }
4544 4567
4545 if (attrib_0_buffer_id_) { 4568 if (attrib_0_buffer_id_) {
4546 glDeleteBuffersARB(1, &attrib_0_buffer_id_); 4569 glDeleteBuffersARB(1, &attrib_0_buffer_id_);
4547 } 4570 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4620 // Current program must be cleared after calling ProgramManager::UnuseProgram. 4643 // Current program must be cleared after calling ProgramManager::UnuseProgram.
4621 // Otherwise, we can leak objects. http://crbug.com/258772. 4644 // Otherwise, we can leak objects. http://crbug.com/258772.
4622 // state_.current_program must be reset before group_ is reset because 4645 // state_.current_program must be reset before group_ is reset because
4623 // the later deletes the ProgramManager object that referred by 4646 // the later deletes the ProgramManager object that referred by
4624 // state_.current_program object. 4647 // state_.current_program object.
4625 state_.current_program = NULL; 4648 state_.current_program = NULL;
4626 4649
4627 apply_framebuffer_attachment_cmaa_intel_.reset(); 4650 apply_framebuffer_attachment_cmaa_intel_.reset();
4628 copy_tex_image_blit_.reset(); 4651 copy_tex_image_blit_.reset();
4629 copy_texture_CHROMIUM_.reset(); 4652 copy_texture_CHROMIUM_.reset();
4653 srgb_converter_.reset();
4630 clear_framebuffer_blit_.reset(); 4654 clear_framebuffer_blit_.reset();
4631 4655
4632 if (query_manager_.get()) { 4656 if (query_manager_.get()) {
4633 query_manager_->Destroy(have_context); 4657 query_manager_->Destroy(have_context);
4634 query_manager_.reset(); 4658 query_manager_.reset();
4635 } 4659 }
4636 4660
4637 if (vertex_array_manager_ .get()) { 4661 if (vertex_array_manager_ .get()) {
4638 vertex_array_manager_->Destroy(have_context); 4662 vertex_array_manager_->Destroy(have_context);
4639 vertex_array_manager_.reset(); 4663 vertex_array_manager_.reset();
(...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after
7517 } 7541 }
7518 7542
7519 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); 7543 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER);
7520 if (read_buffer_samples > 0 && 7544 if (read_buffer_samples > 0 &&
7521 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { 7545 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) {
7522 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7546 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7523 "src framebuffer is multisampled, but src/dst regions are different"); 7547 "src framebuffer is multisampled, but src/dst regions are different");
7524 return; 7548 return;
7525 } 7549 }
7526 7550
7527 GLenum src_format = GetBoundReadFramebufferInternalFormat(); 7551 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat();
7528 GLenum src_type = GetBoundReadFramebufferTextureType(); 7552 GLenum src_type = GetBoundReadFramebufferTextureType();
7529 7553
7554 bool read_buffer_has_srgb =
7555 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB;
7556 bool draw_buffers_has_srgb = false;
7530 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { 7557 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
7531 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); 7558 bool is_src_signed_int =
7532 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); 7559 GLES2Util::IsSignedIntegerFormat(src_internal_format);
7560 bool is_src_unsigned_int =
7561 GLES2Util::IsUnsignedIntegerFormat(src_internal_format);
7533 DCHECK(!is_src_signed_int || !is_src_unsigned_int); 7562 DCHECK(!is_src_signed_int || !is_src_unsigned_int);
7534 7563
7535 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { 7564 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) {
7536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7565 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7537 "invalid filter for integer format"); 7566 "invalid filter for integer format");
7538 return; 7567 return;
7539 } 7568 }
7540 7569
7541 GLenum src_sized_format = 7570 GLenum src_sized_format =
7542 GLES2Util::ConvertToSizedFormat(src_format, src_type); 7571 GLES2Util::ConvertToSizedFormat(src_internal_format, src_type);
7543 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { 7572 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
7544 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( 7573 GLenum dst_format = GetBoundColorDrawBufferInternalFormat(
7545 static_cast<GLint>(ii)); 7574 static_cast<GLint>(ii));
7546 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); 7575 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii));
7547 if (dst_format == 0) 7576 if (dst_format == 0)
7548 continue; 7577 continue;
7578 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB)
7579 draw_buffers_has_srgb = true;
7549 if (read_buffer_samples > 0 && 7580 if (read_buffer_samples > 0 &&
7550 (src_sized_format != 7581 (src_sized_format !=
7551 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { 7582 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) {
7552 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7583 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7553 "src and dst formats differ for color"); 7584 "src and dst formats differ for color");
7554 return; 7585 return;
7555 } 7586 }
7556 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); 7587 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format);
7557 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); 7588 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format);
7558 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); 7589 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int);
(...skipping 16 matching lines...) Expand all
7575 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != 7606 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=
7576 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || 7607 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) ||
7577 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != 7608 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=
7578 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { 7609 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) {
7579 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7610 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7580 "src and dst formats differ for depth/stencil"); 7611 "src and dst formats differ for depth/stencil");
7581 return; 7612 return;
7582 } 7613 }
7583 } 7614 }
7584 7615
7585 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7616 bool enable_srgb = read_buffer_has_srgb || draw_buffers_has_srgb;
7586 BlitFramebufferHelper( 7617 bool same_size = (abs(srcX1 - srcX0) == abs(dstX1 - dstX0)) &&
7587 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 7618 (abs(srcY1 - srcY0) == abs(dstY1 - dstY0));
7588 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 7619 if (!enable_srgb ||
7620 !feature_info_->feature_flags().desktop_srgb_support ||
7621 (read_buffer_has_srgb && draw_buffers_has_srgb && same_size) ||
7622 gl_version_info().IsAtLeastGL(4, 4)) {
7623 if (enable_srgb && gl_version_info().IsAtLeastGL(4, 4)) {
7624 state_.EnableDisableFramebufferSRGB(enable_srgb);
7625 }
7626
7627 // TODO(yunchao) Need to revisit here. In GLES spec, blitFramebuffer
7628 // should do scissor test per fragment operation.
7629 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
7630 BlitFramebufferHelper(
7631 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
7632 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
7589 state_.enable_flags.scissor_test); 7633 state_.enable_flags.scissor_test);
7634 return;
7635 }
7636
7637 // emulate srgb for desktop core profile when GL version < 4.4
7638 // TODO(yunchao): Need to handle this situation:
7639 // There are multiple draw buffers. Some of them are srgb image.
7640 // The others are not.
7641
7642 if (read_buffer_has_srgb) {
7643 state_.EnableDisableFramebufferSRGB(false);
7644 if (!InitializeSRGBDecoder(func_name)) {
7645 return;
7646 }
7647 srgb_converter_->SRGBToLinear(this, srcX0, srcY0, srcX1, srcY1,
7648 dstX0, dstY0, dstX1, dstY1,
7649 mask, filter,
7650 GetBoundReadFramebufferSize(),
7651 GetBoundReadFramebufferServiceId(),
7652 src_internal_format,
7653 GetBoundDrawFramebufferServiceId(),
7654 GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
7655 }
7656
7657 if (draw_buffers_has_srgb) {
7658 state_.EnableDisableFramebufferSRGB(false);
7659 if (!InitializeSRGBEncoder(func_name)) {
7660 return;
7661 }
7662 srgb_converter_->LinearToSRGB(this, srcX0, srcY0, srcX1, srcY1,
7663 dstX0, dstY0, dstX1, dstY1,
7664 mask, filter,
7665 GetBoundReadFramebufferSize(),
7666 GetBoundReadFramebufferServiceId(),
7667 src_internal_format,
7668 GetBoundDrawFramebufferServiceId(),
7669 GL_SRGB8_ALPHA8,
7670 GL_RGBA, GL_UNSIGNED_BYTE);
7671 }
7672 }
7673
7674 bool GLES2DecoderImpl::InitializeSRGBDecoder(
7675 const char* function_name) {
7676 if (!srgb_converter_.get()) {
7677 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
7678 srgb_converter_.reset(
7679 new SRGBConverter(feature_info_.get()));
7680 }
7681 srgb_converter_->InitializeSRGBDecoder(this);
7682 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
7683 return false;
7684 }
7685 return true;
7686 }
7687
7688 bool GLES2DecoderImpl::InitializeSRGBEncoder(
7689 const char* function_name) {
7690 if (!srgb_converter_.get()) {
7691 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
7692 srgb_converter_.reset(
7693 new SRGBConverter(feature_info_.get()));
7694 }
7695 srgb_converter_->InitializeSRGBEncoder(this);
7696 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
7697 return false;
7698 }
7699 return true;
7590 } 7700 }
7591 7701
7592 void GLES2DecoderImpl::EnsureRenderbufferBound() { 7702 void GLES2DecoderImpl::EnsureRenderbufferBound() {
7593 if (!state_.bound_renderbuffer_valid) { 7703 if (!state_.bound_renderbuffer_valid) {
7594 state_.bound_renderbuffer_valid = true; 7704 state_.bound_renderbuffer_valid = true;
7595 glBindRenderbufferEXT(GL_RENDERBUFFER, 7705 glBindRenderbufferEXT(GL_RENDERBUFFER,
7596 state_.bound_renderbuffer.get() 7706 state_.bound_renderbuffer.get()
7597 ? state_.bound_renderbuffer->service_id() 7707 ? state_.bound_renderbuffer->service_id()
7598 : 0); 7708 : 0);
7599 } 7709 }
(...skipping 10134 matching lines...) Expand 10 before | Expand all | Expand 10 after
17734 } 17844 }
17735 17845
17736 // Include the auto-generated part of this file. We split this because it means 17846 // Include the auto-generated part of this file. We split this because it means
17737 // we can easily edit the non-auto generated parts right here in this file 17847 // we can easily edit the non-auto generated parts right here in this file
17738 // instead of having to edit some template or the code generator. 17848 // instead of having to edit some template or the code generator.
17739 #include "base/macros.h" 17849 #include "base/macros.h"
17740 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17850 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17741 17851
17742 } // namespace gles2 17852 } // namespace gles2
17743 } // namespace gpu 17853 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698