| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 capabilities_.allow_partial_texture_updates = true; | 367 capabilities_.allow_partial_texture_updates = true; |
| 368 | 368 |
| 369 capabilities_.using_image = context_caps.gpu.image; | 369 capabilities_.using_image = context_caps.gpu.image; |
| 370 | 370 |
| 371 capabilities_.using_discard_framebuffer = | 371 capabilities_.using_discard_framebuffer = |
| 372 context_caps.gpu.discard_framebuffer; | 372 context_caps.gpu.discard_framebuffer; |
| 373 | 373 |
| 374 capabilities_.allow_rasterize_on_demand = true; | 374 capabilities_.allow_rasterize_on_demand = true; |
| 375 | 375 |
| 376 use_sync_query_ = context_caps.gpu.sync_query; | 376 use_sync_query_ = context_caps.gpu.sync_query; |
| 377 use_blend_minmax_ = context_caps.gpu.blend_minmax; | |
| 378 use_blend_equation_advanced_ = context_caps.gpu.blend_equation_advanced; | 377 use_blend_equation_advanced_ = context_caps.gpu.blend_equation_advanced; |
| 379 use_blend_equation_advanced_coherent_ = | 378 use_blend_equation_advanced_coherent_ = |
| 380 context_caps.gpu.blend_equation_advanced_coherent; | 379 context_caps.gpu.blend_equation_advanced_coherent; |
| 381 | 380 |
| 382 InitializeSharedObjects(); | 381 InitializeSharedObjects(); |
| 383 } | 382 } |
| 384 | 383 |
| 385 GLRenderer::~GLRenderer() { | 384 GLRenderer::~GLRenderer() { |
| 386 while (!pending_async_read_pixels_.empty()) { | 385 while (!pending_async_read_pixels_.empty()) { |
| 387 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back(); | 386 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back(); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 731 // Flush the GrContext to ensure all buffered GL calls are drawn to the |
| 733 // backing store before we access and return it, and have cc begin using the | 732 // backing store before we access and return it, and have cc begin using the |
| 734 // GL context again. | 733 // GL context again. |
| 735 canvas->flush(); | 734 canvas->flush(); |
| 736 | 735 |
| 737 return image; | 736 return image; |
| 738 } | 737 } |
| 739 | 738 |
| 740 bool GLRenderer::CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) { | 739 bool GLRenderer::CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) { |
| 741 return use_blend_equation_advanced_ || | 740 return use_blend_equation_advanced_ || |
| 742 (use_blend_minmax_ && blend_mode == SkXfermode::kLighten_Mode) || | |
| 743 blend_mode == SkXfermode::kScreen_Mode || | 741 blend_mode == SkXfermode::kScreen_Mode || |
| 744 blend_mode == SkXfermode::kSrcOver_Mode; | 742 blend_mode == SkXfermode::kSrcOver_Mode; |
| 745 } | 743 } |
| 746 | 744 |
| 747 void GLRenderer::ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) { | 745 void GLRenderer::ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode) { |
| 748 DCHECK(CanApplyBlendModeUsingBlendFunc(blend_mode)); | 746 DCHECK(CanApplyBlendModeUsingBlendFunc(blend_mode)); |
| 749 | 747 |
| 750 // Any modes set here must be reset in RestoreBlendFuncToDefault | 748 // Any modes set here must be reset in RestoreBlendFuncToDefault |
| 751 if (use_blend_equation_advanced_) { | 749 if (use_blend_equation_advanced_) { |
| 752 GLenum equation = GL_FUNC_ADD; | 750 GLenum equation = GL_FUNC_ADD; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 equation = GL_HSL_LUMINOSITY_KHR; | 796 equation = GL_HSL_LUMINOSITY_KHR; |
| 799 break; | 797 break; |
| 800 default: | 798 default: |
| 801 return; | 799 return; |
| 802 } | 800 } |
| 803 | 801 |
| 804 GLC(gl_, gl_->BlendEquation(equation)); | 802 GLC(gl_, gl_->BlendEquation(equation)); |
| 805 } else { | 803 } else { |
| 806 if (blend_mode == SkXfermode::kScreen_Mode) { | 804 if (blend_mode == SkXfermode::kScreen_Mode) { |
| 807 GLC(gl_, gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE)); | 805 GLC(gl_, gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE)); |
| 808 } else if (blend_mode == SkXfermode::kLighten_Mode) { | |
| 809 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE)); | |
| 810 GLC(gl_, gl_->BlendEquation(GL_MAX_EXT)); | |
| 811 } | 806 } |
| 812 } | 807 } |
| 813 } | 808 } |
| 814 | 809 |
| 815 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) { | 810 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) { |
| 816 if (blend_mode == SkXfermode::kSrcOver_Mode) | 811 if (blend_mode == SkXfermode::kSrcOver_Mode) |
| 817 return; | 812 return; |
| 818 | 813 |
| 819 if (use_blend_equation_advanced_) { | 814 if (use_blend_equation_advanced_) { |
| 820 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); | 815 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); |
| 821 } else { | 816 } else { |
| 822 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 817 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 823 | |
| 824 if (blend_mode == SkXfermode::kLighten_Mode) | |
| 825 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); | |
| 826 } | 818 } |
| 827 } | 819 } |
| 828 | 820 |
| 829 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame, | 821 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame, |
| 830 const RenderPassDrawQuad* quad) { | 822 const RenderPassDrawQuad* quad) { |
| 831 if (quad->background_filters.IsEmpty()) | 823 if (quad->background_filters.IsEmpty()) |
| 832 return false; | 824 return false; |
| 833 | 825 |
| 834 // TODO(danakj): We only allow background filters on an opaque render surface | 826 // TODO(danakj): We only allow background filters on an opaque render surface |
| 835 // because other surfaces may contain translucent pixels, and the contents | 827 // because other surfaces may contain translucent pixels, and the contents |
| (...skipping 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 context_support_->ScheduleOverlayPlane( | 3350 context_support_->ScheduleOverlayPlane( |
| 3359 overlay.plane_z_order, | 3351 overlay.plane_z_order, |
| 3360 overlay.transform, | 3352 overlay.transform, |
| 3361 pending_overlay_resources_.back()->texture_id(), | 3353 pending_overlay_resources_.back()->texture_id(), |
| 3362 overlay.display_rect, | 3354 overlay.display_rect, |
| 3363 overlay.uv_rect); | 3355 overlay.uv_rect); |
| 3364 } | 3356 } |
| 3365 } | 3357 } |
| 3366 | 3358 |
| 3367 } // namespace cc | 3359 } // namespace cc |
| OLD | NEW |