OLD | NEW |
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 explicit ScopedRenderBufferBinder(ContextState* state, GLuint id); | 337 explicit ScopedRenderBufferBinder(ContextState* state, GLuint id); |
338 ~ScopedRenderBufferBinder(); | 338 ~ScopedRenderBufferBinder(); |
339 | 339 |
340 private: | 340 private: |
341 ContextState* state_; | 341 ContextState* state_; |
342 DISALLOW_COPY_AND_ASSIGN(ScopedRenderBufferBinder); | 342 DISALLOW_COPY_AND_ASSIGN(ScopedRenderBufferBinder); |
343 }; | 343 }; |
344 | 344 |
345 // Temporarily changes a decoder's bound frame buffer and restore it when this | 345 // Temporarily changes a decoder's bound frame buffer and restore it when this |
346 // object goes out of scope. | 346 // object goes out of scope. |
347 class ScopedFrameBufferBinder { | 347 class ScopedFramebufferBinder { |
348 public: | 348 public: |
349 explicit ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, GLuint id); | 349 explicit ScopedFramebufferBinder(GLES2DecoderImpl* decoder, GLuint id); |
350 ~ScopedFrameBufferBinder(); | 350 ~ScopedFramebufferBinder(); |
351 | 351 |
352 private: | 352 private: |
353 GLES2DecoderImpl* decoder_; | 353 GLES2DecoderImpl* decoder_; |
354 DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder); | 354 DISALLOW_COPY_AND_ASSIGN(ScopedFramebufferBinder); |
355 }; | 355 }; |
356 | 356 |
357 // Temporarily changes a decoder's bound frame buffer to a resolved version of | 357 // Temporarily changes a decoder's bound frame buffer to a resolved version of |
358 // the multisampled offscreen render buffer if that buffer is multisampled, and, | 358 // the multisampled offscreen render buffer if that buffer is multisampled, and, |
359 // if it is bound or enforce_internal_framebuffer is true. If internal is | 359 // if it is bound or enforce_internal_framebuffer is true. If internal is |
360 // true, the resolved framebuffer is not visible to the parent. | 360 // true, the resolved framebuffer is not visible to the parent. |
361 class ScopedResolvedFrameBufferBinder { | 361 class ScopedResolvedFramebufferBinder { |
362 public: | 362 public: |
363 explicit ScopedResolvedFrameBufferBinder(GLES2DecoderImpl* decoder, | 363 explicit ScopedResolvedFramebufferBinder(GLES2DecoderImpl* decoder, |
364 bool enforce_internal_framebuffer, | 364 bool enforce_internal_framebuffer, |
365 bool internal); | 365 bool internal); |
366 ~ScopedResolvedFrameBufferBinder(); | 366 ~ScopedResolvedFramebufferBinder(); |
367 | 367 |
368 private: | 368 private: |
369 GLES2DecoderImpl* decoder_; | 369 GLES2DecoderImpl* decoder_; |
370 bool resolve_and_bind_; | 370 bool resolve_and_bind_; |
371 DISALLOW_COPY_AND_ASSIGN(ScopedResolvedFrameBufferBinder); | 371 DISALLOW_COPY_AND_ASSIGN(ScopedResolvedFramebufferBinder); |
372 }; | 372 }; |
373 | 373 |
374 // Encapsulates an OpenGL texture. | 374 // Encapsulates an OpenGL texture. |
375 class BackTexture { | 375 class BackTexture { |
376 public: | 376 public: |
377 explicit BackTexture(GLES2DecoderImpl* decoder); | 377 explicit BackTexture(GLES2DecoderImpl* decoder); |
378 ~BackTexture(); | 378 ~BackTexture(); |
379 | 379 |
380 // Create a new render texture. | 380 // Create a new render texture. |
381 void Create(); | 381 void Create(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 bool Initialize(const scoped_refptr<gl::GLSurface>& surface, | 571 bool Initialize(const scoped_refptr<gl::GLSurface>& surface, |
572 const scoped_refptr<gl::GLContext>& context, | 572 const scoped_refptr<gl::GLContext>& context, |
573 bool offscreen, | 573 bool offscreen, |
574 const DisallowedFeatures& disallowed_features, | 574 const DisallowedFeatures& disallowed_features, |
575 const ContextCreationAttribHelper& attrib_helper) override; | 575 const ContextCreationAttribHelper& attrib_helper) override; |
576 void Destroy(bool have_context) override; | 576 void Destroy(bool have_context) override; |
577 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; | 577 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; |
578 void ReleaseSurface() override; | 578 void ReleaseSurface() override; |
579 void TakeFrontBuffer(const Mailbox& mailbox) override; | 579 void TakeFrontBuffer(const Mailbox& mailbox) override; |
580 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; | 580 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; |
581 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 581 bool ResizeOffscreenFramebuffer(const gfx::Size& size) override; |
582 bool MakeCurrent() override; | 582 bool MakeCurrent() override; |
583 GLES2Util* GetGLES2Util() override { return &util_; } | 583 GLES2Util* GetGLES2Util() override { return &util_; } |
584 gl::GLContext* GetGLContext() override { return context_.get(); } | 584 gl::GLContext* GetGLContext() override { return context_.get(); } |
585 ContextGroup* GetContextGroup() override { return group_.get(); } | 585 ContextGroup* GetContextGroup() override { return group_.get(); } |
586 const FeatureInfo* GetFeatureInfo() const override { | 586 const FeatureInfo* GetFeatureInfo() const override { |
587 return feature_info_.get(); | 587 return feature_info_.get(); |
588 } | 588 } |
589 Capabilities GetCapabilities() override; | 589 Capabilities GetCapabilities() override; |
590 void RestoreState(const ContextState* prev_state) override; | 590 void RestoreState(const ContextState* prev_state) override; |
591 | 591 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 GLint dstX0, | 704 GLint dstX0, |
705 GLint dstY0, | 705 GLint dstY0, |
706 GLint dstX1, | 706 GLint dstX1, |
707 GLint dstY1, | 707 GLint dstY1, |
708 GLbitfield mask, | 708 GLbitfield mask, |
709 GLenum filter); | 709 GLenum filter); |
710 | 710 |
711 PathManager* path_manager() { return group_->path_manager(); } | 711 PathManager* path_manager() { return group_->path_manager(); } |
712 | 712 |
713 private: | 713 private: |
714 friend class ScopedFrameBufferBinder; | 714 friend class ScopedFramebufferBinder; |
715 friend class ScopedResolvedFrameBufferBinder; | 715 friend class ScopedResolvedFramebufferBinder; |
716 friend class BackFramebuffer; | 716 friend class BackFramebuffer; |
717 friend class BackRenderbuffer; | 717 friend class BackRenderbuffer; |
718 friend class BackTexture; | 718 friend class BackTexture; |
719 | 719 |
720 enum FramebufferOperation { | 720 enum FramebufferOperation { |
721 kFramebufferDiscard, | 721 kFramebufferDiscard, |
722 kFramebufferInvalidate, | 722 kFramebufferInvalidate, |
723 kFramebufferInvalidateSub | 723 kFramebufferInvalidateSub |
724 }; | 724 }; |
725 | 725 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 return transform_feedback_manager_->GetTransformFeedback(client_id); | 873 return transform_feedback_manager_->GetTransformFeedback(client_id); |
874 } | 874 } |
875 | 875 |
876 // Deletes the TransformFeedback info for the given transformfeedback. | 876 // Deletes the TransformFeedback info for the given transformfeedback. |
877 void RemoveTransformFeedback(GLuint client_id) { | 877 void RemoveTransformFeedback(GLuint client_id) { |
878 transform_feedback_manager_->RemoveTransformFeedback(client_id); | 878 transform_feedback_manager_->RemoveTransformFeedback(client_id); |
879 } | 879 } |
880 | 880 |
881 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 881 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
882 // or regular back buffer). | 882 // or regular back buffer). |
883 gfx::Size GetBoundReadFrameBufferSize(); | 883 gfx::Size GetBoundReadFramebufferSize(); |
884 | 884 |
885 // Get the service side ID for the bound read frame buffer. | 885 // Get the service side ID for the bound read frame buffer. |
886 // If it's back buffer, 0 is returned. | 886 // If it's back buffer, 0 is returned. |
887 GLuint GetBoundReadFrameBufferServiceId(); | 887 GLuint GetBoundReadFramebufferServiceId(); |
888 | 888 |
889 // Get the format/type of the currently bound frame buffer (either FBO or | 889 // Get the format/type of the currently bound frame buffer (either FBO or |
890 // regular back buffer). | 890 // regular back buffer). |
891 // If the color image is a renderbuffer, returns 0 for type. | 891 // If the color image is a renderbuffer, returns 0 for type. |
892 GLenum GetBoundReadFrameBufferTextureType(); | 892 GLenum GetBoundReadFramebufferTextureType(); |
893 GLenum GetBoundReadFrameBufferInternalFormat(); | 893 GLenum GetBoundReadFramebufferInternalFormat(); |
894 | 894 |
895 // Get the i-th draw buffer's internal format/type from the bound framebuffer. | 895 // 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 | 896 // If no framebuffer is bound, or no image is attached, or the DrawBuffers |
897 // setting for that image is GL_NONE, return 0. | 897 // setting for that image is GL_NONE, return 0. |
898 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); | 898 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); |
899 GLenum GetBoundColorDrawBufferInternalFormat(GLint drawbuffer_i); | 899 GLenum GetBoundColorDrawBufferInternalFormat(GLint drawbuffer_i); |
900 | 900 |
901 GLsizei GetBoundFrameBufferSamples(GLenum target); | 901 GLsizei GetBoundFramebufferSamples(GLenum target); |
902 | 902 |
903 // Return 0 if no depth attachment. | 903 // Return 0 if no depth attachment. |
904 GLenum GetBoundFrameBufferDepthFormat(GLenum target); | 904 GLenum GetBoundFramebufferDepthFormat(GLenum target); |
905 // Return 0 if no stencil attachment. | 905 // Return 0 if no stencil attachment. |
906 GLenum GetBoundFrameBufferStencilFormat(GLenum target); | 906 GLenum GetBoundFramebufferStencilFormat(GLenum target); |
907 | 907 |
908 void MarkDrawBufferAsCleared(GLenum buffer, GLint drawbuffer_i); | 908 void MarkDrawBufferAsCleared(GLenum buffer, GLint drawbuffer_i); |
909 | 909 |
910 // Wrapper for CompressedTexImage2D commands. | 910 // Wrapper for CompressedTexImage2D commands. |
911 error::Error DoCompressedTexImage2D( | 911 error::Error DoCompressedTexImage2D( |
912 GLenum target, | 912 GLenum target, |
913 GLint level, | 913 GLint level, |
914 GLenum internal_format, | 914 GLenum internal_format, |
915 GLsizei width, | 915 GLsizei width, |
916 GLsizei height, | 916 GLsizei height, |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 "ScopedRenderBufferBinder::ctor", state_->GetErrorState()); | 2398 "ScopedRenderBufferBinder::ctor", state_->GetErrorState()); |
2399 glBindRenderbufferEXT(GL_RENDERBUFFER, id); | 2399 glBindRenderbufferEXT(GL_RENDERBUFFER, id); |
2400 } | 2400 } |
2401 | 2401 |
2402 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { | 2402 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { |
2403 ScopedGLErrorSuppressor suppressor( | 2403 ScopedGLErrorSuppressor suppressor( |
2404 "ScopedRenderBufferBinder::dtor", state_->GetErrorState()); | 2404 "ScopedRenderBufferBinder::dtor", state_->GetErrorState()); |
2405 state_->RestoreRenderbufferBindings(); | 2405 state_->RestoreRenderbufferBindings(); |
2406 } | 2406 } |
2407 | 2407 |
2408 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, | 2408 ScopedFramebufferBinder::ScopedFramebufferBinder(GLES2DecoderImpl* decoder, |
2409 GLuint id) | 2409 GLuint id) |
2410 : decoder_(decoder) { | 2410 : decoder_(decoder) { |
2411 ScopedGLErrorSuppressor suppressor( | 2411 ScopedGLErrorSuppressor suppressor( |
2412 "ScopedFrameBufferBinder::ctor", decoder_->GetErrorState()); | 2412 "ScopedFramebufferBinder::ctor", decoder_->GetErrorState()); |
2413 glBindFramebufferEXT(GL_FRAMEBUFFER, id); | 2413 glBindFramebufferEXT(GL_FRAMEBUFFER, id); |
2414 decoder->OnFboChanged(); | 2414 decoder->OnFboChanged(); |
2415 } | 2415 } |
2416 | 2416 |
2417 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 2417 ScopedFramebufferBinder::~ScopedFramebufferBinder() { |
2418 ScopedGLErrorSuppressor suppressor( | 2418 ScopedGLErrorSuppressor suppressor( |
2419 "ScopedFrameBufferBinder::dtor", decoder_->GetErrorState()); | 2419 "ScopedFramebufferBinder::dtor", decoder_->GetErrorState()); |
2420 decoder_->RestoreCurrentFramebufferBindings(); | 2420 decoder_->RestoreCurrentFramebufferBindings(); |
2421 } | 2421 } |
2422 | 2422 |
2423 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( | 2423 ScopedResolvedFramebufferBinder::ScopedResolvedFramebufferBinder( |
2424 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) | 2424 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) |
2425 : decoder_(decoder) { | 2425 : decoder_(decoder) { |
2426 resolve_and_bind_ = ( | 2426 resolve_and_bind_ = ( |
2427 decoder_->offscreen_target_frame_buffer_.get() && | 2427 decoder_->offscreen_target_frame_buffer_.get() && |
2428 decoder_->IsOffscreenBufferMultisampled() && | 2428 decoder_->IsOffscreenBufferMultisampled() && |
2429 (!decoder_->framebuffer_state_.bound_read_framebuffer.get() || | 2429 (!decoder_->framebuffer_state_.bound_read_framebuffer.get() || |
2430 enforce_internal_framebuffer)); | 2430 enforce_internal_framebuffer)); |
2431 if (!resolve_and_bind_) | 2431 if (!resolve_and_bind_) |
2432 return; | 2432 return; |
2433 ScopedGLErrorSuppressor suppressor( | 2433 ScopedGLErrorSuppressor suppressor( |
2434 "ScopedResolvedFrameBufferBinder::ctor", decoder_->GetErrorState()); | 2434 "ScopedResolvedFramebufferBinder::ctor", decoder_->GetErrorState()); |
2435 | 2435 |
2436 // On old AMD GPUs on macOS, glColorMask doesn't work correctly for | 2436 // On old AMD GPUs on macOS, glColorMask doesn't work correctly for |
2437 // multisampled renderbuffers and the alpha channel can be overwritten. This | 2437 // multisampled renderbuffers and the alpha channel can be overwritten. This |
2438 // workaround clears the alpha channel before resolving. | 2438 // workaround clears the alpha channel before resolving. |
2439 bool alpha_channel_needs_clear = | 2439 bool alpha_channel_needs_clear = |
2440 decoder_->should_use_native_gmb_for_backbuffer_ && | 2440 decoder_->should_use_native_gmb_for_backbuffer_ && |
2441 !decoder_->offscreen_buffer_should_have_alpha_ && | 2441 !decoder_->offscreen_buffer_should_have_alpha_ && |
2442 decoder_->ChromiumImageNeedsRGBEmulation() && | 2442 decoder_->ChromiumImageNeedsRGBEmulation() && |
2443 decoder_->feature_info_->workarounds() | 2443 decoder_->feature_info_->workarounds() |
2444 .disable_multisampling_color_mask_usage; | 2444 .disable_multisampling_color_mask_usage; |
(...skipping 20 matching lines...) Expand all Loading... |
2465 decoder_->offscreen_resolved_color_texture_->Create(); | 2465 decoder_->offscreen_resolved_color_texture_->Create(); |
2466 | 2466 |
2467 DCHECK(decoder_->offscreen_saved_color_format_); | 2467 DCHECK(decoder_->offscreen_saved_color_format_); |
2468 decoder_->offscreen_resolved_color_texture_->AllocateStorage( | 2468 decoder_->offscreen_resolved_color_texture_->AllocateStorage( |
2469 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_, | 2469 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_, |
2470 false); | 2470 false); |
2471 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture( | 2471 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture( |
2472 decoder_->offscreen_resolved_color_texture_.get()); | 2472 decoder_->offscreen_resolved_color_texture_.get()); |
2473 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() != | 2473 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() != |
2474 GL_FRAMEBUFFER_COMPLETE) { | 2474 GL_FRAMEBUFFER_COMPLETE) { |
2475 LOG(ERROR) << "ScopedResolvedFrameBufferBinder failed " | 2475 LOG(ERROR) << "ScopedResolvedFramebufferBinder failed " |
2476 << "because offscreen resolved FBO was incomplete."; | 2476 << "because offscreen resolved FBO was incomplete."; |
2477 return; | 2477 return; |
2478 } | 2478 } |
2479 } | 2479 } |
2480 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); | 2480 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); |
2481 } else { | 2481 } else { |
2482 targetid = decoder_->offscreen_saved_frame_buffer_->id(); | 2482 targetid = decoder_->offscreen_saved_frame_buffer_->id(); |
2483 } | 2483 } |
2484 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); | 2484 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); |
2485 const int width = decoder_->offscreen_size_.width(); | 2485 const int width = decoder_->offscreen_size_.width(); |
2486 const int height = decoder_->offscreen_size_.height(); | 2486 const int height = decoder_->offscreen_size_.height(); |
2487 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 2487 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
2488 decoder->BlitFramebufferHelper(0, | 2488 decoder->BlitFramebufferHelper(0, |
2489 0, | 2489 0, |
2490 width, | 2490 width, |
2491 height, | 2491 height, |
2492 0, | 2492 0, |
2493 0, | 2493 0, |
2494 width, | 2494 width, |
2495 height, | 2495 height, |
2496 GL_COLOR_BUFFER_BIT, | 2496 GL_COLOR_BUFFER_BIT, |
2497 GL_NEAREST); | 2497 GL_NEAREST); |
2498 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 2498 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
2499 } | 2499 } |
2500 | 2500 |
2501 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 2501 ScopedResolvedFramebufferBinder::~ScopedResolvedFramebufferBinder() { |
2502 if (!resolve_and_bind_) | 2502 if (!resolve_and_bind_) |
2503 return; | 2503 return; |
2504 | 2504 |
2505 ScopedGLErrorSuppressor suppressor( | 2505 ScopedGLErrorSuppressor suppressor( |
2506 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); | 2506 "ScopedResolvedFramebufferBinder::dtor", decoder_->GetErrorState()); |
2507 decoder_->RestoreCurrentFramebufferBindings(); | 2507 decoder_->RestoreCurrentFramebufferBindings(); |
2508 if (decoder_->state_.enable_flags.scissor_test) { | 2508 if (decoder_->state_.enable_flags.scissor_test) { |
2509 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 2509 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); |
2510 } | 2510 } |
2511 } | 2511 } |
2512 | 2512 |
2513 BackTexture::BackTexture(GLES2DecoderImpl* decoder) | 2513 BackTexture::BackTexture(GLES2DecoderImpl* decoder) |
2514 : memory_tracker_(decoder->memory_tracker()), | 2514 : memory_tracker_(decoder->memory_tracker()), |
2515 bytes_allocated_(0), | 2515 bytes_allocated_(0), |
2516 decoder_(decoder) { | 2516 decoder_(decoder) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2681 | 2681 |
2682 // Ignore the zero flag if the alpha channel needs to be cleared for RGB | 2682 // Ignore the zero flag if the alpha channel needs to be cleared for RGB |
2683 // emulation. | 2683 // emulation. |
2684 bool needs_clear_for_rgb_emulation = | 2684 bool needs_clear_for_rgb_emulation = |
2685 !decoder_->offscreen_buffer_should_have_alpha_ && | 2685 !decoder_->offscreen_buffer_should_have_alpha_ && |
2686 decoder_->ChromiumImageNeedsRGBEmulation(); | 2686 decoder_->ChromiumImageNeedsRGBEmulation(); |
2687 if (zero || needs_clear_for_rgb_emulation) { | 2687 if (zero || needs_clear_for_rgb_emulation) { |
2688 GLuint fbo; | 2688 GLuint fbo; |
2689 glGenFramebuffersEXT(1, &fbo); | 2689 glGenFramebuffersEXT(1, &fbo); |
2690 { | 2690 { |
2691 ScopedFrameBufferBinder binder(decoder_, fbo); | 2691 ScopedFramebufferBinder binder(decoder_, fbo); |
2692 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, Target(), | 2692 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, Target(), |
2693 id(), 0); | 2693 id(), 0); |
2694 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); | 2694 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); |
2695 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 2695 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
2696 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 2696 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
2697 glClear(GL_COLOR_BUFFER_BIT); | 2697 glClear(GL_COLOR_BUFFER_BIT); |
2698 decoder_->RestoreClearState(); | 2698 decoder_->RestoreClearState(); |
2699 } | 2699 } |
2700 glDeleteFramebuffersEXT(1, &fbo); | 2700 glDeleteFramebuffersEXT(1, &fbo); |
2701 } | 2701 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 size.height()); | 2769 size.height()); |
2770 } | 2770 } |
2771 | 2771 |
2772 bool alpha_channel_needs_clear = | 2772 bool alpha_channel_needs_clear = |
2773 (format == GL_RGBA || format == GL_RGBA8) && | 2773 (format == GL_RGBA || format == GL_RGBA8) && |
2774 !decoder_->offscreen_buffer_should_have_alpha_; | 2774 !decoder_->offscreen_buffer_should_have_alpha_; |
2775 if (alpha_channel_needs_clear) { | 2775 if (alpha_channel_needs_clear) { |
2776 GLuint fbo; | 2776 GLuint fbo; |
2777 glGenFramebuffersEXT(1, &fbo); | 2777 glGenFramebuffersEXT(1, &fbo); |
2778 { | 2778 { |
2779 ScopedFrameBufferBinder binder(decoder_, fbo); | 2779 ScopedFramebufferBinder binder(decoder_, fbo); |
2780 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 2780 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
2781 GL_RENDERBUFFER, id_); | 2781 GL_RENDERBUFFER, id_); |
2782 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); | 2782 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); |
2783 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 2783 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
2784 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 2784 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
2785 glClear(GL_COLOR_BUFFER_BIT); | 2785 glClear(GL_COLOR_BUFFER_BIT); |
2786 decoder_->RestoreClearState(); | 2786 decoder_->RestoreClearState(); |
2787 } | 2787 } |
2788 glDeleteFramebuffersEXT(1, &fbo); | 2788 glDeleteFramebuffersEXT(1, &fbo); |
2789 } | 2789 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2830 ScopedGLErrorSuppressor suppressor("BackFramebuffer::Create", | 2830 ScopedGLErrorSuppressor suppressor("BackFramebuffer::Create", |
2831 decoder_->GetErrorState()); | 2831 decoder_->GetErrorState()); |
2832 Destroy(); | 2832 Destroy(); |
2833 glGenFramebuffersEXT(1, &id_); | 2833 glGenFramebuffersEXT(1, &id_); |
2834 } | 2834 } |
2835 | 2835 |
2836 void BackFramebuffer::AttachRenderTexture(BackTexture* texture) { | 2836 void BackFramebuffer::AttachRenderTexture(BackTexture* texture) { |
2837 DCHECK_NE(id_, 0u); | 2837 DCHECK_NE(id_, 0u); |
2838 ScopedGLErrorSuppressor suppressor( | 2838 ScopedGLErrorSuppressor suppressor( |
2839 "BackFramebuffer::AttachRenderTexture", decoder_->GetErrorState()); | 2839 "BackFramebuffer::AttachRenderTexture", decoder_->GetErrorState()); |
2840 ScopedFrameBufferBinder binder(decoder_, id_); | 2840 ScopedFramebufferBinder binder(decoder_, id_); |
2841 GLuint attach_id = texture ? texture->id() : 0; | 2841 GLuint attach_id = texture ? texture->id() : 0; |
2842 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 2842 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
2843 texture->Target(), attach_id, 0); | 2843 texture->Target(), attach_id, 0); |
2844 } | 2844 } |
2845 | 2845 |
2846 void BackFramebuffer::AttachRenderBuffer(GLenum target, | 2846 void BackFramebuffer::AttachRenderBuffer(GLenum target, |
2847 BackRenderbuffer* render_buffer) { | 2847 BackRenderbuffer* render_buffer) { |
2848 DCHECK_NE(id_, 0u); | 2848 DCHECK_NE(id_, 0u); |
2849 ScopedGLErrorSuppressor suppressor( | 2849 ScopedGLErrorSuppressor suppressor( |
2850 "BackFramebuffer::AttachRenderBuffer", decoder_->GetErrorState()); | 2850 "BackFramebuffer::AttachRenderBuffer", decoder_->GetErrorState()); |
2851 ScopedFrameBufferBinder binder(decoder_, id_); | 2851 ScopedFramebufferBinder binder(decoder_, id_); |
2852 GLuint attach_id = render_buffer ? render_buffer->id() : 0; | 2852 GLuint attach_id = render_buffer ? render_buffer->id() : 0; |
2853 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, | 2853 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, |
2854 target, | 2854 target, |
2855 GL_RENDERBUFFER, | 2855 GL_RENDERBUFFER, |
2856 attach_id); | 2856 attach_id); |
2857 } | 2857 } |
2858 | 2858 |
2859 void BackFramebuffer::Destroy() { | 2859 void BackFramebuffer::Destroy() { |
2860 if (id_ != 0) { | 2860 if (id_ != 0) { |
2861 ScopedGLErrorSuppressor suppressor("BackFramebuffer::Destroy", | 2861 ScopedGLErrorSuppressor suppressor("BackFramebuffer::Destroy", |
2862 decoder_->GetErrorState()); | 2862 decoder_->GetErrorState()); |
2863 glDeleteFramebuffersEXT(1, &id_); | 2863 glDeleteFramebuffersEXT(1, &id_); |
2864 id_ = 0; | 2864 id_ = 0; |
2865 } | 2865 } |
2866 } | 2866 } |
2867 | 2867 |
2868 void BackFramebuffer::Invalidate() { | 2868 void BackFramebuffer::Invalidate() { |
2869 id_ = 0; | 2869 id_ = 0; |
2870 } | 2870 } |
2871 | 2871 |
2872 GLenum BackFramebuffer::CheckStatus() { | 2872 GLenum BackFramebuffer::CheckStatus() { |
2873 DCHECK_NE(id_, 0u); | 2873 DCHECK_NE(id_, 0u); |
2874 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus", | 2874 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus", |
2875 decoder_->GetErrorState()); | 2875 decoder_->GetErrorState()); |
2876 ScopedFrameBufferBinder binder(decoder_, id_); | 2876 ScopedFramebufferBinder binder(decoder_, id_); |
2877 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 2877 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
2878 } | 2878 } |
2879 | 2879 |
2880 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 2880 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
2881 if (group->gpu_preferences().use_passthrough_cmd_decoder) { | 2881 if (group->gpu_preferences().use_passthrough_cmd_decoder) { |
2882 return new GLES2DecoderPassthroughImpl(group); | 2882 return new GLES2DecoderPassthroughImpl(group); |
2883 } | 2883 } |
2884 return new GLES2DecoderImpl(group); | 2884 return new GLES2DecoderImpl(group); |
2885 } | 2885 } |
2886 | 2886 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 // If we're an offscreen surface with zero width and/or height, set to a | 3254 // If we're an offscreen surface with zero width and/or height, set to a |
3255 // non-zero size so that we have a complete framebuffer for operations | 3255 // non-zero size so that we have a complete framebuffer for operations |
3256 // like glClear. | 3256 // like glClear. |
3257 // TODO(piman): allow empty framebuffers, similar to | 3257 // TODO(piman): allow empty framebuffers, similar to |
3258 // EGL_KHR_surfaceless_context / GL_OES_surfaceless_context. | 3258 // EGL_KHR_surfaceless_context / GL_OES_surfaceless_context. |
3259 initial_size = gfx::Size(1, 1); | 3259 initial_size = gfx::Size(1, 1); |
3260 } | 3260 } |
3261 | 3261 |
3262 // Allocate the render buffers at their initial size and check the status | 3262 // Allocate the render buffers at their initial size and check the status |
3263 // of the frame buffers is okay. | 3263 // of the frame buffers is okay. |
3264 if (!ResizeOffscreenFrameBuffer(initial_size)) { | 3264 if (!ResizeOffscreenFramebuffer(initial_size)) { |
3265 LOG(ERROR) << "Could not allocate offscreen buffer storage."; | 3265 LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
3266 Destroy(true); | 3266 Destroy(true); |
3267 return false; | 3267 return false; |
3268 } | 3268 } |
3269 | 3269 |
3270 state_.viewport_width = initial_size.width(); | 3270 state_.viewport_width = initial_size.width(); |
3271 state_.viewport_height = initial_size.height(); | 3271 state_.viewport_height = initial_size.height(); |
3272 | 3272 |
3273 // Allocate the offscreen saved color texture. | 3273 // Allocate the offscreen saved color texture. |
3274 DCHECK(offscreen_saved_color_format_); | 3274 DCHECK(offscreen_saved_color_format_); |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 framebuffer_state_.bound_draw_framebuffer.get(); | 4257 framebuffer_state_.bound_draw_framebuffer.get(); |
4258 if (!framebuffer) | 4258 if (!framebuffer) |
4259 return false; | 4259 return false; |
4260 const Framebuffer::Attachment* attachment = | 4260 const Framebuffer::Attachment* attachment = |
4261 framebuffer->GetReadBufferAttachment(); | 4261 framebuffer->GetReadBufferAttachment(); |
4262 if (!attachment) | 4262 if (!attachment) |
4263 return false; | 4263 return false; |
4264 return attachment->FormsFeedbackLoop(texture, level, layer); | 4264 return attachment->FormsFeedbackLoop(texture, level, layer); |
4265 } | 4265 } |
4266 | 4266 |
4267 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { | 4267 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() { |
4268 Framebuffer* framebuffer = | 4268 Framebuffer* framebuffer = |
4269 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4269 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
4270 if (framebuffer != NULL) { | 4270 if (framebuffer != NULL) { |
4271 const Framebuffer::Attachment* attachment = | 4271 const Framebuffer::Attachment* attachment = |
4272 framebuffer->GetReadBufferAttachment(); | 4272 framebuffer->GetReadBufferAttachment(); |
4273 if (attachment) { | 4273 if (attachment) { |
4274 return gfx::Size(attachment->width(), attachment->height()); | 4274 return gfx::Size(attachment->width(), attachment->height()); |
4275 } | 4275 } |
4276 return gfx::Size(0, 0); | 4276 return gfx::Size(0, 0); |
4277 } else if (offscreen_target_frame_buffer_.get()) { | 4277 } else if (offscreen_target_frame_buffer_.get()) { |
4278 return offscreen_size_; | 4278 return offscreen_size_; |
4279 } else { | 4279 } else { |
4280 return surface_->GetSize(); | 4280 return surface_->GetSize(); |
4281 } | 4281 } |
4282 } | 4282 } |
4283 | 4283 |
4284 GLuint GLES2DecoderImpl::GetBoundReadFrameBufferServiceId() { | 4284 GLuint GLES2DecoderImpl::GetBoundReadFramebufferServiceId() { |
4285 Framebuffer* framebuffer = | 4285 Framebuffer* framebuffer = |
4286 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4286 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
4287 if (framebuffer) { | 4287 if (framebuffer) { |
4288 return framebuffer->service_id(); | 4288 return framebuffer->service_id(); |
4289 } | 4289 } |
4290 if (offscreen_resolved_frame_buffer_.get()) { | 4290 if (offscreen_resolved_frame_buffer_.get()) { |
4291 return offscreen_resolved_frame_buffer_->id(); | 4291 return offscreen_resolved_frame_buffer_->id(); |
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 GLenum GLES2DecoderImpl::GetBoundReadFrameBufferTextureType() { | 4302 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { |
4303 Framebuffer* framebuffer = | 4303 Framebuffer* framebuffer = |
4304 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4304 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
4305 if (framebuffer) { | 4305 if (framebuffer) { |
4306 return framebuffer->GetReadBufferTextureType(); | 4306 return framebuffer->GetReadBufferTextureType(); |
4307 } else { // Back buffer. | 4307 } else { // Back buffer. |
4308 if (back_buffer_read_buffer_ == GL_NONE) | 4308 if (back_buffer_read_buffer_ == GL_NONE) |
4309 return 0; | 4309 return 0; |
4310 return GL_UNSIGNED_BYTE; | 4310 return GL_UNSIGNED_BYTE; |
4311 } | 4311 } |
4312 } | 4312 } |
4313 | 4313 |
4314 GLenum GLES2DecoderImpl::GetBoundReadFrameBufferInternalFormat() { | 4314 GLenum GLES2DecoderImpl::GetBoundReadFramebufferInternalFormat() { |
4315 Framebuffer* framebuffer = | 4315 Framebuffer* framebuffer = |
4316 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4316 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
4317 if (framebuffer) { | 4317 if (framebuffer) { |
4318 return framebuffer->GetReadBufferInternalFormat(); | 4318 return framebuffer->GetReadBufferInternalFormat(); |
4319 } else { // Back buffer. | 4319 } else { // Back buffer. |
4320 if (back_buffer_read_buffer_ == GL_NONE) | 4320 if (back_buffer_read_buffer_ == GL_NONE) |
4321 return 0; | 4321 return 0; |
4322 if (offscreen_target_frame_buffer_.get()) { | 4322 if (offscreen_target_frame_buffer_.get()) { |
4323 return offscreen_target_color_format_; | 4323 return offscreen_target_color_format_; |
4324 } | 4324 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 } | 4360 } |
4361 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); | 4361 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); |
4362 const Framebuffer::Attachment* buffer = | 4362 const Framebuffer::Attachment* buffer = |
4363 framebuffer->GetAttachment(attachment); | 4363 framebuffer->GetAttachment(attachment); |
4364 if (!buffer) { | 4364 if (!buffer) { |
4365 return 0; | 4365 return 0; |
4366 } | 4366 } |
4367 return buffer->internal_format(); | 4367 return buffer->internal_format(); |
4368 } | 4368 } |
4369 | 4369 |
4370 GLsizei GLES2DecoderImpl::GetBoundFrameBufferSamples(GLenum target) { | 4370 GLsizei GLES2DecoderImpl::GetBoundFramebufferSamples(GLenum target) { |
4371 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || | 4371 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || |
4372 target == GL_FRAMEBUFFER); | 4372 target == GL_FRAMEBUFFER); |
4373 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4373 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
4374 if (framebuffer) { | 4374 if (framebuffer) { |
4375 return framebuffer->GetSamples(); | 4375 return framebuffer->GetSamples(); |
4376 } else { // Back buffer. | 4376 } else { // Back buffer. |
4377 if (offscreen_target_frame_buffer_.get()) { | 4377 if (offscreen_target_frame_buffer_.get()) { |
4378 return offscreen_target_samples_; | 4378 return offscreen_target_samples_; |
4379 } | 4379 } |
4380 return 0; | 4380 return 0; |
4381 } | 4381 } |
4382 } | 4382 } |
4383 | 4383 |
4384 GLenum GLES2DecoderImpl::GetBoundFrameBufferDepthFormat( | 4384 GLenum GLES2DecoderImpl::GetBoundFramebufferDepthFormat( |
4385 GLenum target) { | 4385 GLenum target) { |
4386 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || | 4386 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || |
4387 target == GL_FRAMEBUFFER); | 4387 target == GL_FRAMEBUFFER); |
4388 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4388 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
4389 if (framebuffer) { | 4389 if (framebuffer) { |
4390 return framebuffer->GetDepthFormat(); | 4390 return framebuffer->GetDepthFormat(); |
4391 } else { // Back buffer. | 4391 } else { // Back buffer. |
4392 if (offscreen_target_frame_buffer_.get()) { | 4392 if (offscreen_target_frame_buffer_.get()) { |
4393 return offscreen_target_depth_format_; | 4393 return offscreen_target_depth_format_; |
4394 } | 4394 } |
4395 if (back_buffer_has_depth_) | 4395 if (back_buffer_has_depth_) |
4396 return GL_DEPTH; | 4396 return GL_DEPTH; |
4397 return 0; | 4397 return 0; |
4398 } | 4398 } |
4399 } | 4399 } |
4400 | 4400 |
4401 GLenum GLES2DecoderImpl::GetBoundFrameBufferStencilFormat( | 4401 GLenum GLES2DecoderImpl::GetBoundFramebufferStencilFormat( |
4402 GLenum target) { | 4402 GLenum target) { |
4403 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || | 4403 DCHECK(target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER || |
4404 target == GL_FRAMEBUFFER); | 4404 target == GL_FRAMEBUFFER); |
4405 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4405 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
4406 if (framebuffer) { | 4406 if (framebuffer) { |
4407 return framebuffer->GetStencilFormat(); | 4407 return framebuffer->GetStencilFormat(); |
4408 } else { // Back buffer. | 4408 } else { // Back buffer. |
4409 if (offscreen_target_frame_buffer_.get()) { | 4409 if (offscreen_target_frame_buffer_.get()) { |
4410 return offscreen_target_stencil_format_; | 4410 return offscreen_target_stencil_format_; |
4411 } | 4411 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4790 } | 4790 } |
4791 | 4791 |
4792 size_t GLES2DecoderImpl::GetSavedBackTextureCountForTest() { | 4792 size_t GLES2DecoderImpl::GetSavedBackTextureCountForTest() { |
4793 return saved_back_textures_.size(); | 4793 return saved_back_textures_.size(); |
4794 } | 4794 } |
4795 | 4795 |
4796 size_t GLES2DecoderImpl::GetCreatedBackTextureCountForTest() { | 4796 size_t GLES2DecoderImpl::GetCreatedBackTextureCountForTest() { |
4797 return create_back_texture_count_for_test_; | 4797 return create_back_texture_count_for_test_; |
4798 } | 4798 } |
4799 | 4799 |
4800 bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { | 4800 bool GLES2DecoderImpl::ResizeOffscreenFramebuffer(const gfx::Size& size) { |
4801 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 4801 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
4802 if (!is_offscreen) { | 4802 if (!is_offscreen) { |
4803 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer called " | 4803 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer called " |
4804 << " with an onscreen framebuffer."; | 4804 << " with an onscreen framebuffer."; |
4805 return false; | 4805 return false; |
4806 } | 4806 } |
4807 | 4807 |
4808 if (offscreen_size_ == size) | 4808 if (offscreen_size_ == size) |
4809 return true; | 4809 return true; |
4810 | 4810 |
4811 offscreen_size_ = size; | 4811 offscreen_size_ = size; |
4812 int w = offscreen_size_.width(); | 4812 int w = offscreen_size_.width(); |
4813 int h = offscreen_size_.height(); | 4813 int h = offscreen_size_.height(); |
4814 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { | 4814 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { |
4815 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4815 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4816 << "to allocate storage due to excessive dimensions."; | 4816 << "to allocate storage due to excessive dimensions."; |
4817 return false; | 4817 return false; |
4818 } | 4818 } |
4819 | 4819 |
4820 // Reallocate the offscreen target buffers. | 4820 // Reallocate the offscreen target buffers. |
4821 DCHECK(offscreen_target_color_format_); | 4821 DCHECK(offscreen_target_color_format_); |
4822 if (IsOffscreenBufferMultisampled()) { | 4822 if (IsOffscreenBufferMultisampled()) { |
4823 if (!offscreen_target_color_render_buffer_->AllocateStorage( | 4823 if (!offscreen_target_color_render_buffer_->AllocateStorage( |
4824 feature_info_.get(), offscreen_size_, | 4824 feature_info_.get(), offscreen_size_, |
4825 offscreen_target_color_format_, offscreen_target_samples_)) { | 4825 offscreen_target_color_format_, offscreen_target_samples_)) { |
4826 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4826 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4827 << "to allocate storage for offscreen target color buffer."; | 4827 << "to allocate storage for offscreen target color buffer."; |
4828 return false; | 4828 return false; |
4829 } | 4829 } |
4830 } else { | 4830 } else { |
4831 if (!offscreen_target_color_texture_->AllocateStorage( | 4831 if (!offscreen_target_color_texture_->AllocateStorage( |
4832 offscreen_size_, offscreen_target_color_format_, false)) { | 4832 offscreen_size_, offscreen_target_color_format_, false)) { |
4833 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4833 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4834 << "to allocate storage for offscreen target color texture."; | 4834 << "to allocate storage for offscreen target color texture."; |
4835 return false; | 4835 return false; |
4836 } | 4836 } |
4837 } | 4837 } |
4838 if (offscreen_target_depth_format_ && | 4838 if (offscreen_target_depth_format_ && |
4839 !offscreen_target_depth_render_buffer_->AllocateStorage( | 4839 !offscreen_target_depth_render_buffer_->AllocateStorage( |
4840 feature_info_.get(), | 4840 feature_info_.get(), |
4841 offscreen_size_, | 4841 offscreen_size_, |
4842 offscreen_target_depth_format_, | 4842 offscreen_target_depth_format_, |
4843 offscreen_target_samples_)) { | 4843 offscreen_target_samples_)) { |
4844 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4844 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4845 << "to allocate storage for offscreen target depth buffer."; | 4845 << "to allocate storage for offscreen target depth buffer."; |
4846 return false; | 4846 return false; |
4847 } | 4847 } |
4848 if (offscreen_target_stencil_format_ && | 4848 if (offscreen_target_stencil_format_ && |
4849 !offscreen_target_stencil_render_buffer_->AllocateStorage( | 4849 !offscreen_target_stencil_render_buffer_->AllocateStorage( |
4850 feature_info_.get(), | 4850 feature_info_.get(), |
4851 offscreen_size_, | 4851 offscreen_size_, |
4852 offscreen_target_stencil_format_, | 4852 offscreen_target_stencil_format_, |
4853 offscreen_target_samples_)) { | 4853 offscreen_target_samples_)) { |
4854 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4854 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4855 << "to allocate storage for offscreen target stencil buffer."; | 4855 << "to allocate storage for offscreen target stencil buffer."; |
4856 return false; | 4856 return false; |
4857 } | 4857 } |
4858 | 4858 |
4859 // Attach the offscreen target buffers to the target frame buffer. | 4859 // Attach the offscreen target buffers to the target frame buffer. |
4860 if (IsOffscreenBufferMultisampled()) { | 4860 if (IsOffscreenBufferMultisampled()) { |
4861 offscreen_target_frame_buffer_->AttachRenderBuffer( | 4861 offscreen_target_frame_buffer_->AttachRenderBuffer( |
4862 GL_COLOR_ATTACHMENT0, | 4862 GL_COLOR_ATTACHMENT0, |
4863 offscreen_target_color_render_buffer_.get()); | 4863 offscreen_target_color_render_buffer_.get()); |
4864 } else { | 4864 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
4877 GL_STENCIL_ATTACHMENT, | 4877 GL_STENCIL_ATTACHMENT, |
4878 offscreen_target_depth_render_buffer_.get()); | 4878 offscreen_target_depth_render_buffer_.get()); |
4879 } else if (offscreen_target_stencil_format_) { | 4879 } else if (offscreen_target_stencil_format_) { |
4880 offscreen_target_frame_buffer_->AttachRenderBuffer( | 4880 offscreen_target_frame_buffer_->AttachRenderBuffer( |
4881 GL_STENCIL_ATTACHMENT, | 4881 GL_STENCIL_ATTACHMENT, |
4882 offscreen_target_stencil_render_buffer_.get()); | 4882 offscreen_target_stencil_render_buffer_.get()); |
4883 } | 4883 } |
4884 | 4884 |
4885 if (offscreen_target_frame_buffer_->CheckStatus() != | 4885 if (offscreen_target_frame_buffer_->CheckStatus() != |
4886 GL_FRAMEBUFFER_COMPLETE) { | 4886 GL_FRAMEBUFFER_COMPLETE) { |
4887 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 4887 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
4888 << "because offscreen FBO was incomplete."; | 4888 << "because offscreen FBO was incomplete."; |
4889 return false; | 4889 return false; |
4890 } | 4890 } |
4891 | 4891 |
4892 // Clear the target frame buffer. | 4892 // Clear the target frame buffer. |
4893 { | 4893 { |
4894 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); | 4894 ScopedFramebufferBinder binder(this, offscreen_target_frame_buffer_->id()); |
4895 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); | 4895 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); |
4896 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 4896 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
4897 glClearStencil(0); | 4897 glClearStencil(0); |
4898 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 4898 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
4899 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 4899 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
4900 glClearDepth(0); | 4900 glClearDepth(0); |
4901 state_.SetDeviceDepthMask(GL_TRUE); | 4901 state_.SetDeviceDepthMask(GL_TRUE); |
4902 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 4902 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
4903 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 4903 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
4904 RestoreClearState(); | 4904 RestoreClearState(); |
(...skipping 27 matching lines...) Expand all Loading... |
4932 width = std::max(1U, width); | 4932 width = std::max(1U, width); |
4933 height = std::max(1U, height); | 4933 height = std::max(1U, height); |
4934 | 4934 |
4935 #if defined(OS_POSIX) && !defined(OS_MACOSX) && \ | 4935 #if defined(OS_POSIX) && !defined(OS_MACOSX) && \ |
4936 !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 4936 !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
4937 // Make sure that we are done drawing to the back buffer before resizing. | 4937 // Make sure that we are done drawing to the back buffer before resizing. |
4938 glFinish(); | 4938 glFinish(); |
4939 #endif | 4939 #endif |
4940 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 4940 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
4941 if (is_offscreen) { | 4941 if (is_offscreen) { |
4942 if (!ResizeOffscreenFrameBuffer(gfx::Size(width, height))) { | 4942 if (!ResizeOffscreenFramebuffer(gfx::Size(width, height))) { |
4943 LOG(ERROR) << "GLES2DecoderImpl: Context lost because " | 4943 LOG(ERROR) << "GLES2DecoderImpl: Context lost because " |
4944 << "ResizeOffscreenFrameBuffer failed."; | 4944 << "ResizeOffscreenFramebuffer failed."; |
4945 return error::kLostContext; | 4945 return error::kLostContext; |
4946 } | 4946 } |
4947 } else { | 4947 } else { |
4948 if (!surface_->Resize(gfx::Size(width, height), scale_factor, | 4948 if (!surface_->Resize(gfx::Size(width, height), scale_factor, |
4949 !!has_alpha)) { | 4949 !!has_alpha)) { |
4950 LOG(ERROR) << "GLES2DecoderImpl: Context lost because resize failed."; | 4950 LOG(ERROR) << "GLES2DecoderImpl: Context lost because resize failed."; |
4951 return error::kLostContext; | 4951 return error::kLostContext; |
4952 } | 4952 } |
4953 DCHECK(context_->IsCurrent(surface_.get())); | 4953 DCHECK(context_->IsCurrent(surface_.get())); |
4954 if (!context_->IsCurrent(surface_.get())) { | 4954 if (!context_->IsCurrent(surface_.get())) { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5336 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); | 5336 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); |
5337 state_.SetDeviceCapabilityState( | 5337 state_.SetDeviceCapabilityState( |
5338 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); | 5338 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); |
5339 framebuffer_state_.clear_state_dirty = false; | 5339 framebuffer_state_.clear_state_dirty = false; |
5340 } | 5340 } |
5341 } | 5341 } |
5342 | 5342 |
5343 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { | 5343 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
5344 return (offscreen_target_frame_buffer_.get()) | 5344 return (offscreen_target_frame_buffer_.get()) |
5345 ? offscreen_target_frame_buffer_->id() | 5345 ? offscreen_target_frame_buffer_->id() |
5346 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); | 5346 : (surface_.get() ? surface_->GetBackingFramebufferObject() : 0); |
5347 } | 5347 } |
5348 | 5348 |
5349 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) { | 5349 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) { |
5350 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", | 5350 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", |
5351 "context", logger_.GetLogPrefix()); | 5351 "context", logger_.GetLogPrefix()); |
5352 // Restore the Framebuffer first because of bugs in Intel drivers. | 5352 // Restore the Framebuffer first because of bugs in Intel drivers. |
5353 // Intel drivers incorrectly clip the viewport settings to | 5353 // Intel drivers incorrectly clip the viewport settings to |
5354 // the size of the current framebuffer object. | 5354 // the size of the current framebuffer object. |
5355 RestoreFramebufferBindings(); | 5355 RestoreFramebufferBindings(); |
5356 state_.RestoreState(prev_state); | 5356 state_.RestoreState(prev_state); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6004 glGetIntegerv(pname, params); | 6004 glGetIntegerv(pname, params); |
6005 bool is_valid = glGetError() == GL_NO_ERROR; | 6005 bool is_valid = glGetError() == GL_NO_ERROR; |
6006 if (is_valid) { | 6006 if (is_valid) { |
6007 is_valid = pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT ? | 6007 is_valid = pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT ? |
6008 validators_->read_pixel_format.IsValid(*params) : | 6008 validators_->read_pixel_format.IsValid(*params) : |
6009 validators_->read_pixel_type.IsValid(*params); | 6009 validators_->read_pixel_type.IsValid(*params); |
6010 } | 6010 } |
6011 if (!is_valid) { | 6011 if (!is_valid) { |
6012 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { | 6012 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { |
6013 *params = GLES2Util::GetGLReadPixelsImplementationFormat( | 6013 *params = GLES2Util::GetGLReadPixelsImplementationFormat( |
6014 GetBoundReadFrameBufferInternalFormat(), | 6014 GetBoundReadFramebufferInternalFormat(), |
6015 GetBoundReadFrameBufferTextureType(), | 6015 GetBoundReadFramebufferTextureType(), |
6016 feature_info_->feature_flags().ext_read_format_bgra); | 6016 feature_info_->feature_flags().ext_read_format_bgra); |
6017 } else { | 6017 } else { |
6018 *params = GLES2Util::GetGLReadPixelsImplementationType( | 6018 *params = GLES2Util::GetGLReadPixelsImplementationType( |
6019 GetBoundReadFrameBufferInternalFormat(), | 6019 GetBoundReadFramebufferInternalFormat(), |
6020 GetBoundReadFrameBufferTextureType()); | 6020 GetBoundReadFramebufferTextureType()); |
6021 } | 6021 } |
6022 } | 6022 } |
6023 if (*params == GL_HALF_FLOAT && feature_info_->IsWebGL1OrES2Context()) { | 6023 if (*params == GL_HALF_FLOAT && feature_info_->IsWebGL1OrES2Context()) { |
6024 *params = GL_HALF_FLOAT_OES; | 6024 *params = GL_HALF_FLOAT_OES; |
6025 } | 6025 } |
6026 if (*params == GL_SRGB_ALPHA_EXT) { | 6026 if (*params == GL_SRGB_ALPHA_EXT) { |
6027 *params = GL_RGBA; | 6027 *params = GL_RGBA; |
6028 } | 6028 } |
6029 if (*params == GL_SRGB_EXT) { | 6029 if (*params == GL_SRGB_EXT) { |
6030 *params = GL_RGB; | 6030 *params = GL_RGB; |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6910 if (CheckBoundDrawFramebufferValid(func_name)) { | 6910 if (CheckBoundDrawFramebufferValid(func_name)) { |
6911 ApplyDirtyState(); | 6911 ApplyDirtyState(); |
6912 if (workarounds().gl_clear_broken) { | 6912 if (workarounds().gl_clear_broken) { |
6913 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", | 6913 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", |
6914 GetErrorState()); | 6914 GetErrorState()); |
6915 if (!BoundFramebufferHasDepthAttachment()) | 6915 if (!BoundFramebufferHasDepthAttachment()) |
6916 mask &= ~GL_DEPTH_BUFFER_BIT; | 6916 mask &= ~GL_DEPTH_BUFFER_BIT; |
6917 if (!BoundFramebufferHasStencilAttachment()) | 6917 if (!BoundFramebufferHasStencilAttachment()) |
6918 mask &= ~GL_STENCIL_BUFFER_BIT; | 6918 mask &= ~GL_STENCIL_BUFFER_BIT; |
6919 clear_framebuffer_blit_->ClearFramebuffer( | 6919 clear_framebuffer_blit_->ClearFramebuffer( |
6920 this, GetBoundReadFrameBufferSize(), mask, state_.color_clear_red, | 6920 this, GetBoundReadFramebufferSize(), mask, state_.color_clear_red, |
6921 state_.color_clear_green, state_.color_clear_blue, | 6921 state_.color_clear_green, state_.color_clear_blue, |
6922 state_.color_clear_alpha, state_.depth_clear, state_.stencil_clear); | 6922 state_.color_clear_alpha, state_.depth_clear, state_.stencil_clear); |
6923 return error::kNoError; | 6923 return error::kNoError; |
6924 } | 6924 } |
6925 if (mask & GL_COLOR_BUFFER_BIT) { | 6925 if (mask & GL_COLOR_BUFFER_BIT) { |
6926 Framebuffer* framebuffer = | 6926 Framebuffer* framebuffer = |
6927 framebuffer_state_.bound_draw_framebuffer.get(); | 6927 framebuffer_state_.bound_draw_framebuffer.get(); |
6928 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { | 6928 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { |
6929 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 6929 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
6930 "can't be called on integer buffers"); | 6930 "can't be called on integer buffers"); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7190 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { | 7190 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { |
7191 // TODO(zmo): There is no guarantee that an FBO that is complete on the | 7191 // TODO(zmo): There is no guarantee that an FBO that is complete on the |
7192 // READ attachment will be complete as a DRAW attachment. | 7192 // READ attachment will be complete as a DRAW attachment. |
7193 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id()); | 7193 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id()); |
7194 } | 7194 } |
7195 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7195 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
7196 if (workarounds().gl_clear_broken) { | 7196 if (workarounds().gl_clear_broken) { |
7197 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", | 7197 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::ClearWorkaround", |
7198 GetErrorState()); | 7198 GetErrorState()); |
7199 clear_framebuffer_blit_->ClearFramebuffer( | 7199 clear_framebuffer_blit_->ClearFramebuffer( |
7200 this, GetBoundReadFrameBufferSize(), clear_bits, | 7200 this, GetBoundReadFramebufferSize(), clear_bits, |
7201 state_.color_clear_red, state_.color_clear_green, | 7201 state_.color_clear_red, state_.color_clear_green, |
7202 state_.color_clear_blue, state_.color_clear_alpha, state_.depth_clear, | 7202 state_.color_clear_blue, state_.color_clear_alpha, state_.depth_clear, |
7203 state_.stencil_clear); | 7203 state_.stencil_clear); |
7204 } else { | 7204 } else { |
7205 glClear(clear_bits); | 7205 glClear(clear_bits); |
7206 } | 7206 } |
7207 } | 7207 } |
7208 | 7208 |
7209 if (cleared_int_renderbuffers || clear_bits) { | 7209 if (cleared_int_renderbuffers || clear_bits) { |
7210 if (reset_draw_buffers) | 7210 if (reset_draw_buffers) |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7503 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 7503 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
7504 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 7504 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
7505 GLbitfield mask, GLenum filter) { | 7505 GLbitfield mask, GLenum filter) { |
7506 const char* func_name = "glBlitFramebufferCHROMIUM"; | 7506 const char* func_name = "glBlitFramebufferCHROMIUM"; |
7507 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); | 7507 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); |
7508 | 7508 |
7509 if (!CheckBoundFramebufferValid(func_name)) { | 7509 if (!CheckBoundFramebufferValid(func_name)) { |
7510 return; | 7510 return; |
7511 } | 7511 } |
7512 | 7512 |
7513 if (GetBoundFrameBufferSamples(GL_DRAW_FRAMEBUFFER) > 0) { | 7513 if (GetBoundFramebufferSamples(GL_DRAW_FRAMEBUFFER) > 0) { |
7514 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7514 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7515 "destination framebuffer is multisampled"); | 7515 "destination framebuffer is multisampled"); |
7516 return; | 7516 return; |
7517 } | 7517 } |
7518 | 7518 |
7519 GLsizei read_buffer_samples = GetBoundFrameBufferSamples(GL_READ_FRAMEBUFFER); | 7519 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); |
7520 if (read_buffer_samples > 0 && | 7520 if (read_buffer_samples > 0 && |
7521 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { | 7521 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { |
7522 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7522 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7523 "src framebuffer is multisampled, but src/dst regions are different"); | 7523 "src framebuffer is multisampled, but src/dst regions are different"); |
7524 return; | 7524 return; |
7525 } | 7525 } |
7526 | 7526 |
7527 GLenum src_format = GetBoundReadFrameBufferInternalFormat(); | 7527 GLenum src_format = GetBoundReadFramebufferInternalFormat(); |
7528 GLenum src_type = GetBoundReadFrameBufferTextureType(); | 7528 GLenum src_type = GetBoundReadFramebufferTextureType(); |
7529 | 7529 |
7530 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { | 7530 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
7531 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); | 7531 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); |
7532 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); | 7532 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); |
7533 DCHECK(!is_src_signed_int || !is_src_unsigned_int); | 7533 DCHECK(!is_src_signed_int || !is_src_unsigned_int); |
7534 | 7534 |
7535 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { | 7535 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { |
7536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7537 "invalid filter for integer format"); | 7537 "invalid filter for integer format"); |
7538 return; | 7538 return; |
(...skipping 26 matching lines...) Expand all Loading... |
7565 } | 7565 } |
7566 } | 7566 } |
7567 | 7567 |
7568 if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) { | 7568 if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) { |
7569 if (filter != GL_NEAREST) { | 7569 if (filter != GL_NEAREST) { |
7570 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7570 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7571 "invalid filter for depth/stencil"); | 7571 "invalid filter for depth/stencil"); |
7572 return; | 7572 return; |
7573 } | 7573 } |
7574 | 7574 |
7575 if ((GetBoundFrameBufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7575 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != |
7576 GetBoundFrameBufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7576 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
7577 (GetBoundFrameBufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7577 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != |
7578 GetBoundFrameBufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7578 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
7579 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7579 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7580 "src and dst formats differ for depth/stencil"); | 7580 "src and dst formats differ for depth/stencil"); |
7581 return; | 7581 return; |
7582 } | 7582 } |
7583 } | 7583 } |
7584 | 7584 |
7585 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7585 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
7586 BlitFramebufferHelper( | 7586 BlitFramebufferHelper( |
7587 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 7587 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
7588 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 7588 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, |
(...skipping 2962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10551 } | 10551 } |
10552 if (!validators_->read_pixel_type.IsValid(type)) { | 10552 if (!validators_->read_pixel_type.IsValid(type)) { |
10553 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); | 10553 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); |
10554 return error::kNoError; | 10554 return error::kNoError; |
10555 } | 10555 } |
10556 | 10556 |
10557 if (!CheckBoundReadFramebufferValid("glReadPixels", | 10557 if (!CheckBoundReadFramebufferValid("glReadPixels", |
10558 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 10558 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
10559 return error::kNoError; | 10559 return error::kNoError; |
10560 } | 10560 } |
10561 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); | 10561 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat(); |
10562 if (src_internal_format == 0) { | 10562 if (src_internal_format == 0) { |
10563 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", | 10563 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", |
10564 "no valid color image"); | 10564 "no valid color image"); |
10565 return error::kNoError; | 10565 return error::kNoError; |
10566 } | 10566 } |
10567 std::vector<GLenum> accepted_formats; | 10567 std::vector<GLenum> accepted_formats; |
10568 std::vector<GLenum> accepted_types; | 10568 std::vector<GLenum> accepted_types; |
10569 switch (src_internal_format) { | 10569 switch (src_internal_format) { |
10570 case GL_R8UI: | 10570 case GL_R8UI: |
10571 case GL_R16UI: | 10571 case GL_R16UI: |
(...skipping 24 matching lines...) Expand all Loading... |
10596 case GL_RGB10_A2: | 10596 case GL_RGB10_A2: |
10597 accepted_formats.push_back(GL_RGBA); | 10597 accepted_formats.push_back(GL_RGBA); |
10598 accepted_types.push_back(GL_UNSIGNED_BYTE); | 10598 accepted_types.push_back(GL_UNSIGNED_BYTE); |
10599 // Special case with an extra supported format/type. | 10599 // Special case with an extra supported format/type. |
10600 accepted_formats.push_back(GL_RGBA); | 10600 accepted_formats.push_back(GL_RGBA); |
10601 accepted_types.push_back(GL_UNSIGNED_INT_2_10_10_10_REV); | 10601 accepted_types.push_back(GL_UNSIGNED_INT_2_10_10_10_REV); |
10602 break; | 10602 break; |
10603 default: | 10603 default: |
10604 accepted_formats.push_back(GL_RGBA); | 10604 accepted_formats.push_back(GL_RGBA); |
10605 { | 10605 { |
10606 GLenum src_type = GetBoundReadFrameBufferTextureType(); | 10606 GLenum src_type = GetBoundReadFramebufferTextureType(); |
10607 switch (src_type) { | 10607 switch (src_type) { |
10608 case GL_HALF_FLOAT: | 10608 case GL_HALF_FLOAT: |
10609 case GL_HALF_FLOAT_OES: | 10609 case GL_HALF_FLOAT_OES: |
10610 case GL_FLOAT: | 10610 case GL_FLOAT: |
10611 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 10611 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
10612 accepted_types.push_back(GL_FLOAT); | 10612 accepted_types.push_back(GL_FLOAT); |
10613 break; | 10613 break; |
10614 default: | 10614 default: |
10615 accepted_types.push_back(GL_UNSIGNED_BYTE); | 10615 accepted_types.push_back(GL_UNSIGNED_BYTE); |
10616 break; | 10616 break; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10648 return error::kNoError; | 10648 return error::kNoError; |
10649 } | 10649 } |
10650 if (type == GL_HALF_FLOAT_OES && !gl_version_info().is_es2) { | 10650 if (type == GL_HALF_FLOAT_OES && !gl_version_info().is_es2) { |
10651 type = GL_HALF_FLOAT; | 10651 type = GL_HALF_FLOAT; |
10652 } | 10652 } |
10653 if (width == 0 || height == 0) { | 10653 if (width == 0 || height == 0) { |
10654 return error::kNoError; | 10654 return error::kNoError; |
10655 } | 10655 } |
10656 | 10656 |
10657 // Get the size of the current fbo or backbuffer. | 10657 // Get the size of the current fbo or backbuffer. |
10658 gfx::Size max_size = GetBoundReadFrameBufferSize(); | 10658 gfx::Size max_size = GetBoundReadFramebufferSize(); |
10659 | 10659 |
10660 int32_t max_x; | 10660 int32_t max_x; |
10661 int32_t max_y; | 10661 int32_t max_y; |
10662 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { | 10662 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { |
10663 LOCAL_SET_GL_ERROR( | 10663 LOCAL_SET_GL_ERROR( |
10664 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 10664 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
10665 return error::kNoError; | 10665 return error::kNoError; |
10666 } | 10666 } |
10667 | 10667 |
10668 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); | 10668 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); |
10669 | 10669 |
10670 ScopedResolvedFrameBufferBinder binder(this, false, true); | 10670 ScopedResolvedFramebufferBinder binder(this, false, true); |
10671 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 10671 GLenum read_format = GetBoundReadFramebufferInternalFormat(); |
10672 | 10672 |
10673 gfx::Rect rect(x, y, width, height); // Safe before we checked above. | 10673 gfx::Rect rect(x, y, width, height); // Safe before we checked above. |
10674 gfx::Rect max_rect(max_size); | 10674 gfx::Rect max_rect(max_size); |
10675 if (!max_rect.Contains(rect)) { | 10675 if (!max_rect.Contains(rect)) { |
10676 rect.Intersect(max_rect); | 10676 rect.Intersect(max_rect); |
10677 if (!rect.IsEmpty()) { | 10677 if (!rect.IsEmpty()) { |
10678 if (y < 0) { | 10678 if (y < 0) { |
10679 pixels += static_cast<uint32_t>(-y) * padded_row_size;; | 10679 pixels += static_cast<uint32_t>(-y) * padded_row_size;; |
10680 } | 10680 } |
10681 if (x < 0) { | 10681 if (x < 0) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10878 LOCAL_SET_GL_ERROR( | 10878 LOCAL_SET_GL_ERROR( |
10879 GL_INVALID_OPERATION, | 10879 GL_INVALID_OPERATION, |
10880 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 10880 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
10881 return error::kNoError; | 10881 return error::kNoError; |
10882 } | 10882 } |
10883 bool is_tracing; | 10883 bool is_tracing; |
10884 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 10884 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
10885 &is_tracing); | 10885 &is_tracing); |
10886 if (is_tracing) { | 10886 if (is_tracing) { |
10887 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 10887 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
10888 ScopedFrameBufferBinder binder(this, GetBackbufferServiceId()); | 10888 ScopedFramebufferBinder binder(this, GetBackbufferServiceId()); |
10889 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | 10889 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( |
10890 is_offscreen ? offscreen_size_ : surface_->GetSize()); | 10890 is_offscreen ? offscreen_size_ : surface_->GetSize()); |
10891 } | 10891 } |
10892 | 10892 |
10893 ClearScheduleCALayerState(); | 10893 ClearScheduleCALayerState(); |
10894 | 10894 |
10895 if (supports_async_swap_) { | 10895 if (supports_async_swap_) { |
10896 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); | 10896 TRACE_EVENT_ASYNC_BEGIN0("cc", "GLES2DecoderImpl::AsyncSwapBuffers", this); |
10897 surface_->PostSubBufferAsync( | 10897 surface_->PostSubBufferAsync( |
10898 c.x, c.y, c.width, c.height, | 10898 c.x, c.y, c.width, c.height, |
(...skipping 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12941 LOCAL_SET_GL_ERROR( | 12941 LOCAL_SET_GL_ERROR( |
12942 GL_INVALID_VALUE, func_name, "dimensions out of range"); | 12942 GL_INVALID_VALUE, func_name, "dimensions out of range"); |
12943 return; | 12943 return; |
12944 } | 12944 } |
12945 | 12945 |
12946 if (!CheckBoundReadFramebufferValid(func_name, | 12946 if (!CheckBoundReadFramebufferValid(func_name, |
12947 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 12947 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
12948 return; | 12948 return; |
12949 } | 12949 } |
12950 | 12950 |
12951 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 12951 GLenum read_format = GetBoundReadFramebufferInternalFormat(); |
12952 GLenum read_type = GetBoundReadFrameBufferTextureType(); | 12952 GLenum read_type = GetBoundReadFramebufferTextureType(); |
12953 if (!ValidateCopyTexFormat(func_name, internal_format, | 12953 if (!ValidateCopyTexFormat(func_name, internal_format, |
12954 read_format, read_type)) { | 12954 read_format, read_type)) { |
12955 return; | 12955 return; |
12956 } | 12956 } |
12957 | 12957 |
12958 uint32_t pixels_size = 0; | 12958 uint32_t pixels_size = 0; |
12959 // TODO(piman): OpenGL ES 3.0.4 Section 3.8.5 specifies how to pick an | 12959 // TODO(piman): OpenGL ES 3.0.4 Section 3.8.5 specifies how to pick an |
12960 // effective internal format if internal_format is unsized, which is a fairly | 12960 // effective internal format if internal_format is unsized, which is a fairly |
12961 // involved logic. For now, just make sure we pick something valid. | 12961 // involved logic. For now, just make sure we pick something valid. |
12962 GLenum format = | 12962 GLenum format = |
(...skipping 23 matching lines...) Expand all Loading... |
12986 } | 12986 } |
12987 | 12987 |
12988 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { | 12988 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { |
12989 LOCAL_SET_GL_ERROR( | 12989 LOCAL_SET_GL_ERROR( |
12990 GL_INVALID_OPERATION, | 12990 GL_INVALID_OPERATION, |
12991 func_name, "source and destination textures are the same"); | 12991 func_name, "source and destination textures are the same"); |
12992 return; | 12992 return; |
12993 } | 12993 } |
12994 | 12994 |
12995 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); | 12995 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); |
12996 ScopedResolvedFrameBufferBinder binder(this, false, true); | 12996 ScopedResolvedFramebufferBinder binder(this, false, true); |
12997 gfx::Size size = GetBoundReadFrameBufferSize(); | 12997 gfx::Size size = GetBoundReadFramebufferSize(); |
12998 | 12998 |
12999 if (texture->IsAttachedToFramebuffer()) { | 12999 if (texture->IsAttachedToFramebuffer()) { |
13000 framebuffer_state_.clear_state_dirty = true; | 13000 framebuffer_state_.clear_state_dirty = true; |
13001 } | 13001 } |
13002 | 13002 |
13003 bool requires_luma_blit = | 13003 bool requires_luma_blit = |
13004 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), | 13004 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), |
13005 format); | 13005 format); |
13006 if (requires_luma_blit && | 13006 if (requires_luma_blit && |
13007 !InitializeCopyTexImageBlitter(func_name)) { | 13007 !InitializeCopyTexImageBlitter(func_name)) { |
(...skipping 20 matching lines...) Expand all Loading... |
13028 width, height, border, format, type, zero.get()); | 13028 width, height, border, format, type, zero.get()); |
13029 if (copyHeight > 0 && copyWidth > 0) { | 13029 if (copyHeight > 0 && copyWidth > 0) { |
13030 GLint dx = copyX - x; | 13030 GLint dx = copyX - x; |
13031 GLint dy = copyY - y; | 13031 GLint dy = copyY - y; |
13032 GLint destX = dx; | 13032 GLint destX = dx; |
13033 GLint destY = dy; | 13033 GLint destY = dy; |
13034 if (requires_luma_blit) { | 13034 if (requires_luma_blit) { |
13035 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | 13035 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
13036 this, texture->service_id(), texture->target(), target, format, | 13036 this, texture->service_id(), texture->target(), target, format, |
13037 type, level, destX, destY, 0, copyX, copyY, copyWidth, copyHeight, | 13037 type, level, destX, destY, 0, copyX, copyY, copyWidth, copyHeight, |
13038 GetBoundReadFrameBufferServiceId(), | 13038 GetBoundReadFramebufferServiceId(), |
13039 GetBoundReadFrameBufferInternalFormat()); | 13039 GetBoundReadFramebufferInternalFormat()); |
13040 } else { | 13040 } else { |
13041 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, | 13041 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, |
13042 copyWidth, copyHeight); | 13042 copyWidth, copyHeight); |
13043 } | 13043 } |
13044 } | 13044 } |
13045 } else { | 13045 } else { |
13046 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( | 13046 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( |
13047 feature_info_.get(), internal_format); | 13047 feature_info_.get(), internal_format); |
13048 | 13048 |
13049 // The service id and target of the texture attached to READ_FRAMEBUFFER. | 13049 // The service id and target of the texture attached to READ_FRAMEBUFFER. |
13050 GLuint source_texture_service_id = 0; | 13050 GLuint source_texture_service_id = 0; |
13051 GLenum source_texture_target = 0; | 13051 GLenum source_texture_target = 0; |
13052 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 13052 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
13053 bool use_workaround = NeedsCopyTextureImageWorkaround( | 13053 bool use_workaround = NeedsCopyTextureImageWorkaround( |
13054 final_internal_format, channels_exist, &source_texture_service_id, | 13054 final_internal_format, channels_exist, &source_texture_service_id, |
13055 &source_texture_target); | 13055 &source_texture_target); |
13056 if (requires_luma_blit) { | 13056 if (requires_luma_blit) { |
13057 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( | 13057 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( |
13058 this, texture->service_id(), texture->target(), target, format, | 13058 this, texture->service_id(), texture->target(), target, format, |
13059 type, level, internal_format, copyX, copyY, copyWidth, copyHeight, | 13059 type, level, internal_format, copyX, copyY, copyWidth, copyHeight, |
13060 GetBoundReadFrameBufferServiceId(), | 13060 GetBoundReadFramebufferServiceId(), |
13061 GetBoundReadFrameBufferInternalFormat()); | 13061 GetBoundReadFramebufferInternalFormat()); |
13062 } else if (use_workaround) { | 13062 } else if (use_workaround) { |
13063 GLenum dest_texture_target = target; | 13063 GLenum dest_texture_target = target; |
13064 GLenum framebuffer_target = features().chromium_framebuffer_multisample | 13064 GLenum framebuffer_target = features().chromium_framebuffer_multisample |
13065 ? GL_READ_FRAMEBUFFER_EXT | 13065 ? GL_READ_FRAMEBUFFER_EXT |
13066 : GL_FRAMEBUFFER; | 13066 : GL_FRAMEBUFFER; |
13067 | 13067 |
13068 GLenum temp_internal_format = 0; | 13068 GLenum temp_internal_format = 0; |
13069 if (channels_exist == GLES2Util::kRGBA) { | 13069 if (channels_exist == GLES2Util::kRGBA) { |
13070 temp_internal_format = GL_RGBA; | 13070 temp_internal_format = GL_RGBA; |
13071 } else if (channels_exist == GLES2Util::kRGB) { | 13071 } else if (channels_exist == GLES2Util::kRGB) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13143 target, level, xoffset, yoffset, 0, width, height, 1)) { | 13143 target, level, xoffset, yoffset, 0, width, height, 1)) { |
13144 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "bad dimensions."); | 13144 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "bad dimensions."); |
13145 return; | 13145 return; |
13146 } | 13146 } |
13147 | 13147 |
13148 if (!CheckBoundReadFramebufferValid(func_name, | 13148 if (!CheckBoundReadFramebufferValid(func_name, |
13149 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 13149 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
13150 return; | 13150 return; |
13151 } | 13151 } |
13152 | 13152 |
13153 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 13153 GLenum read_format = GetBoundReadFramebufferInternalFormat(); |
13154 GLenum read_type = GetBoundReadFrameBufferTextureType(); | 13154 GLenum read_type = GetBoundReadFramebufferTextureType(); |
13155 if (!ValidateCopyTexFormat(func_name, internal_format, | 13155 if (!ValidateCopyTexFormat(func_name, internal_format, |
13156 read_format, read_type)) { | 13156 read_format, read_type)) { |
13157 return; | 13157 return; |
13158 } | 13158 } |
13159 | 13159 |
13160 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { | 13160 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { |
13161 LOCAL_SET_GL_ERROR( | 13161 LOCAL_SET_GL_ERROR( |
13162 GL_INVALID_OPERATION, | 13162 GL_INVALID_OPERATION, |
13163 func_name, "source and destination textures are the same"); | 13163 func_name, "source and destination textures are the same"); |
13164 return; | 13164 return; |
13165 } | 13165 } |
13166 | 13166 |
13167 ScopedResolvedFrameBufferBinder binder(this, false, true); | 13167 ScopedResolvedFramebufferBinder binder(this, false, true); |
13168 gfx::Size size = GetBoundReadFrameBufferSize(); | 13168 gfx::Size size = GetBoundReadFramebufferSize(); |
13169 GLint copyX = 0; | 13169 GLint copyX = 0; |
13170 GLint copyY = 0; | 13170 GLint copyY = 0; |
13171 GLint copyWidth = 0; | 13171 GLint copyWidth = 0; |
13172 GLint copyHeight = 0; | 13172 GLint copyHeight = 0; |
13173 Clip(x, width, size.width(), ©X, ©Width); | 13173 Clip(x, width, size.width(), ©X, ©Width); |
13174 Clip(y, height, size.height(), ©Y, ©Height); | 13174 Clip(y, height, size.height(), ©Y, ©Height); |
13175 | 13175 |
13176 GLint dx = copyX - x; | 13176 GLint dx = copyX - x; |
13177 GLint dy = copyY - y; | 13177 GLint dy = copyY - y; |
13178 GLint destX = xoffset + dx; | 13178 GLint destX = xoffset + dx; |
(...skipping 24 matching lines...) Expand all Loading... |
13203 if (copyHeight > 0 && copyWidth > 0) { | 13203 if (copyHeight > 0 && copyWidth > 0) { |
13204 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( | 13204 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
13205 feature_info_.get(), internal_format)) { | 13205 feature_info_.get(), internal_format)) { |
13206 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { | 13206 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { |
13207 return; | 13207 return; |
13208 } | 13208 } |
13209 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | 13209 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
13210 this, texture->service_id(), texture->target(), target, | 13210 this, texture->service_id(), texture->target(), target, |
13211 internal_format, type, level, destX, destY, 0, | 13211 internal_format, type, level, destX, destY, 0, |
13212 copyX, copyY, copyWidth, copyHeight, | 13212 copyX, copyY, copyWidth, copyHeight, |
13213 GetBoundReadFrameBufferServiceId(), | 13213 GetBoundReadFramebufferServiceId(), |
13214 GetBoundReadFrameBufferInternalFormat()); | 13214 GetBoundReadFramebufferInternalFormat()); |
13215 } else { | 13215 } else { |
13216 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, copyWidth, | 13216 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, copyWidth, |
13217 copyHeight); | 13217 copyHeight); |
13218 } | 13218 } |
13219 } | 13219 } |
13220 | 13220 |
13221 // This may be a slow command. Exit command processing to allow for | 13221 // This may be a slow command. Exit command processing to allow for |
13222 // context preemption and GPU watchdog checks. | 13222 // context preemption and GPU watchdog checks. |
13223 ExitCommandProcessingEarly(); | 13223 ExitCommandProcessingEarly(); |
13224 } | 13224 } |
(...skipping 25 matching lines...) Expand all Loading... |
13250 target, level, xoffset, yoffset, zoffset, width, height, 1)) { | 13250 target, level, xoffset, yoffset, zoffset, width, height, 1)) { |
13251 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "bad dimensions."); | 13251 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "bad dimensions."); |
13252 return; | 13252 return; |
13253 } | 13253 } |
13254 | 13254 |
13255 if (!CheckBoundReadFramebufferValid(func_name, | 13255 if (!CheckBoundReadFramebufferValid(func_name, |
13256 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 13256 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
13257 return; | 13257 return; |
13258 } | 13258 } |
13259 | 13259 |
13260 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 13260 GLenum read_format = GetBoundReadFramebufferInternalFormat(); |
13261 GLenum read_type = GetBoundReadFrameBufferTextureType(); | 13261 GLenum read_type = GetBoundReadFramebufferTextureType(); |
13262 if (!ValidateCopyTexFormat(func_name, internal_format, | 13262 if (!ValidateCopyTexFormat(func_name, internal_format, |
13263 read_format, read_type)) { | 13263 read_format, read_type)) { |
13264 return; | 13264 return; |
13265 } | 13265 } |
13266 | 13266 |
13267 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { | 13267 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { |
13268 LOCAL_SET_GL_ERROR( | 13268 LOCAL_SET_GL_ERROR( |
13269 GL_INVALID_OPERATION, | 13269 GL_INVALID_OPERATION, |
13270 func_name, "source and destination textures are the same"); | 13270 func_name, "source and destination textures are the same"); |
13271 return; | 13271 return; |
13272 } | 13272 } |
13273 | 13273 |
13274 ScopedResolvedFrameBufferBinder binder(this, false, true); | 13274 ScopedResolvedFramebufferBinder binder(this, false, true); |
13275 gfx::Size size = GetBoundReadFrameBufferSize(); | 13275 gfx::Size size = GetBoundReadFramebufferSize(); |
13276 GLint copyX = 0; | 13276 GLint copyX = 0; |
13277 GLint copyY = 0; | 13277 GLint copyY = 0; |
13278 GLint copyWidth = 0; | 13278 GLint copyWidth = 0; |
13279 GLint copyHeight = 0; | 13279 GLint copyHeight = 0; |
13280 Clip(x, width, size.width(), ©X, ©Width); | 13280 Clip(x, width, size.width(), ©X, ©Width); |
13281 Clip(y, height, size.height(), ©Y, ©Height); | 13281 Clip(y, height, size.height(), ©Y, ©Height); |
13282 | 13282 |
13283 GLint dx = copyX - x; | 13283 GLint dx = copyX - x; |
13284 GLint dy = copyY - y; | 13284 GLint dy = copyY - y; |
13285 GLint destX = xoffset + dx; | 13285 GLint destX = xoffset + dx; |
(...skipping 13 matching lines...) Expand all Loading... |
13299 if (copyHeight > 0 && copyWidth > 0) { | 13299 if (copyHeight > 0 && copyWidth > 0) { |
13300 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( | 13300 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
13301 feature_info_.get(), internal_format)) { | 13301 feature_info_.get(), internal_format)) { |
13302 if (!InitializeCopyTexImageBlitter(func_name)) { | 13302 if (!InitializeCopyTexImageBlitter(func_name)) { |
13303 return; | 13303 return; |
13304 } | 13304 } |
13305 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | 13305 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
13306 this, texture->service_id(), texture->target(), target, | 13306 this, texture->service_id(), texture->target(), target, |
13307 internal_format, type, level, destX, destY, zoffset, | 13307 internal_format, type, level, destX, destY, zoffset, |
13308 copyX, copyY, copyWidth, copyHeight, | 13308 copyX, copyY, copyWidth, copyHeight, |
13309 GetBoundReadFrameBufferServiceId(), | 13309 GetBoundReadFramebufferServiceId(), |
13310 GetBoundReadFrameBufferInternalFormat()); | 13310 GetBoundReadFramebufferInternalFormat()); |
13311 } else { | 13311 } else { |
13312 glCopyTexSubImage3D(target, level, destX, destY, zoffset, | 13312 glCopyTexSubImage3D(target, level, destX, destY, zoffset, |
13313 copyX, copyY, copyWidth, copyHeight); | 13313 copyX, copyY, copyWidth, copyHeight); |
13314 } | 13314 } |
13315 } | 13315 } |
13316 | 13316 |
13317 // This may be a slow command. Exit command processing to allow for | 13317 // This may be a slow command. Exit command processing to allow for |
13318 // context preemption and GPU watchdog checks. | 13318 // context preemption and GPU watchdog checks. |
13319 ExitCommandProcessingEarly(); | 13319 ExitCommandProcessingEarly(); |
13320 } | 13320 } |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14039 TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame"); | 14039 TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame"); |
14040 } | 14040 } |
14041 | 14041 |
14042 ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder, | 14042 ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder, |
14043 "GLES2Decoder", "SwapBuffer"); | 14043 "GLES2Decoder", "SwapBuffer"); |
14044 | 14044 |
14045 bool is_tracing; | 14045 bool is_tracing; |
14046 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 14046 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
14047 &is_tracing); | 14047 &is_tracing); |
14048 if (is_tracing) { | 14048 if (is_tracing) { |
14049 ScopedFrameBufferBinder binder(this, GetBackbufferServiceId()); | 14049 ScopedFramebufferBinder binder(this, GetBackbufferServiceId()); |
14050 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | 14050 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( |
14051 is_offscreen ? offscreen_size_ : surface_->GetSize()); | 14051 is_offscreen ? offscreen_size_ : surface_->GetSize()); |
14052 } | 14052 } |
14053 | 14053 |
14054 ClearScheduleCALayerState(); | 14054 ClearScheduleCALayerState(); |
14055 | 14055 |
14056 // If offscreen then don't actually SwapBuffers to the display. Just copy | 14056 // If offscreen then don't actually SwapBuffers to the display. Just copy |
14057 // the rendered frame to another frame buffer. | 14057 // the rendered frame to another frame buffer. |
14058 if (is_offscreen) { | 14058 if (is_offscreen) { |
14059 TRACE_EVENT2("gpu", "Offscreen", | 14059 TRACE_EVENT2("gpu", "Offscreen", |
(...skipping 14 matching lines...) Expand all Loading... |
14074 // Allocate the offscreen saved color texture. | 14074 // Allocate the offscreen saved color texture. |
14075 DCHECK(offscreen_saved_color_format_); | 14075 DCHECK(offscreen_saved_color_format_); |
14076 offscreen_saved_color_texture_->AllocateStorage( | 14076 offscreen_saved_color_texture_->AllocateStorage( |
14077 offscreen_size_, offscreen_saved_color_format_, false); | 14077 offscreen_size_, offscreen_saved_color_format_, false); |
14078 | 14078 |
14079 offscreen_saved_frame_buffer_->AttachRenderTexture( | 14079 offscreen_saved_frame_buffer_->AttachRenderTexture( |
14080 offscreen_saved_color_texture_.get()); | 14080 offscreen_saved_color_texture_.get()); |
14081 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { | 14081 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { |
14082 if (offscreen_saved_frame_buffer_->CheckStatus() != | 14082 if (offscreen_saved_frame_buffer_->CheckStatus() != |
14083 GL_FRAMEBUFFER_COMPLETE) { | 14083 GL_FRAMEBUFFER_COMPLETE) { |
14084 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 14084 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " |
14085 << "because offscreen saved FBO was incomplete."; | 14085 << "because offscreen saved FBO was incomplete."; |
14086 MarkContextLost(error::kUnknown); | 14086 MarkContextLost(error::kUnknown); |
14087 group_->LoseContexts(error::kUnknown); | 14087 group_->LoseContexts(error::kUnknown); |
14088 return; | 14088 return; |
14089 } | 14089 } |
14090 | 14090 |
14091 // Clear the offscreen color texture. | 14091 // Clear the offscreen color texture. |
14092 // TODO(piman): Is this still necessary? | 14092 // TODO(piman): Is this still necessary? |
14093 { | 14093 { |
14094 ScopedFrameBufferBinder binder(this, | 14094 ScopedFramebufferBinder binder(this, |
14095 offscreen_saved_frame_buffer_->id()); | 14095 offscreen_saved_frame_buffer_->id()); |
14096 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); | 14096 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); |
14097 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 14097 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
14098 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 14098 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
14099 glClear(GL_COLOR_BUFFER_BIT); | 14099 glClear(GL_COLOR_BUFFER_BIT); |
14100 RestoreClearState(); | 14100 RestoreClearState(); |
14101 } | 14101 } |
14102 } | 14102 } |
14103 } | 14103 } |
14104 | 14104 |
14105 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) | 14105 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) |
14106 return; | 14106 return; |
14107 ScopedGLErrorSuppressor suppressor( | 14107 ScopedGLErrorSuppressor suppressor( |
14108 "GLES2DecoderImpl::DoSwapBuffers", GetErrorState()); | 14108 "GLES2DecoderImpl::DoSwapBuffers", GetErrorState()); |
14109 | 14109 |
14110 if (IsOffscreenBufferMultisampled()) { | 14110 if (IsOffscreenBufferMultisampled()) { |
14111 // For multisampled buffers, resolve the frame buffer. | 14111 // For multisampled buffers, resolve the frame buffer. |
14112 ScopedResolvedFrameBufferBinder binder(this, true, false); | 14112 ScopedResolvedFramebufferBinder binder(this, true, false); |
14113 } else { | 14113 } else { |
14114 ScopedFrameBufferBinder binder(this, | 14114 ScopedFramebufferBinder binder(this, |
14115 offscreen_target_frame_buffer_->id()); | 14115 offscreen_target_frame_buffer_->id()); |
14116 | 14116 |
14117 if (offscreen_target_buffer_preserved_) { | 14117 if (offscreen_target_buffer_preserved_) { |
14118 // Copy the target frame buffer to the saved offscreen texture. | 14118 // Copy the target frame buffer to the saved offscreen texture. |
14119 offscreen_saved_color_texture_->Copy(); | 14119 offscreen_saved_color_texture_->Copy(); |
14120 } else { | 14120 } else { |
14121 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 14121 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
14122 offscreen_target_frame_buffer_->AttachRenderTexture( | 14122 offscreen_target_frame_buffer_->AttachRenderTexture( |
14123 offscreen_target_color_texture_.get()); | 14123 offscreen_target_color_texture_.get()); |
14124 offscreen_saved_frame_buffer_->AttachRenderTexture( | 14124 offscreen_saved_frame_buffer_->AttachRenderTexture( |
(...skipping 3603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17728 } | 17728 } |
17729 | 17729 |
17730 // Include the auto-generated part of this file. We split this because it means | 17730 // Include the auto-generated part of this file. We split this because it means |
17731 // we can easily edit the non-auto generated parts right here in this file | 17731 // we can easily edit the non-auto generated parts right here in this file |
17732 // instead of having to edit some template or the code generator. | 17732 // instead of having to edit some template or the code generator. |
17733 #include "base/macros.h" | 17733 #include "base/macros.h" |
17734 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17734 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17735 | 17735 |
17736 } // namespace gles2 | 17736 } // namespace gles2 |
17737 } // namespace gpu | 17737 } // namespace gpu |
OLD | NEW |