| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 // The indices for the line are stored in the same array as the triangle | 627 // The indices for the line are stored in the same array as the triangle |
| 628 // indices. | 628 // indices. |
| 629 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); | 629 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); |
| 630 } | 630 } |
| 631 | 631 |
| 632 static SkBitmap ApplyImageFilter( | 632 static SkBitmap ApplyImageFilter( |
| 633 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 633 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
| 634 ResourceProvider* resource_provider, | 634 ResourceProvider* resource_provider, |
| 635 const gfx::Point& origin, | 635 const gfx::Point& origin, |
| 636 const gfx::Vector2dF& scale, |
| 636 SkImageFilter* filter, | 637 SkImageFilter* filter, |
| 637 ScopedResource* source_texture_resource) { | 638 ScopedResource* source_texture_resource) { |
| 638 if (!filter) | 639 if (!filter) |
| 639 return SkBitmap(); | 640 return SkBitmap(); |
| 640 | 641 |
| 641 if (!use_gr_context) | 642 if (!use_gr_context) |
| 642 return SkBitmap(); | 643 return SkBitmap(); |
| 643 | 644 |
| 644 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 645 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
| 645 source_texture_resource->id()); | 646 source_texture_resource->id()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 694 |
| 694 // Draw the source bitmap through the filter to the canvas. | 695 // Draw the source bitmap through the filter to the canvas. |
| 695 SkPaint paint; | 696 SkPaint paint; |
| 696 paint.setImageFilter(filter); | 697 paint.setImageFilter(filter); |
| 697 canvas.clear(SK_ColorTRANSPARENT); | 698 canvas.clear(SK_ColorTRANSPARENT); |
| 698 | 699 |
| 699 // TODO(senorblanco): in addition to the origin translation here, the canvas | 700 // TODO(senorblanco): in addition to the origin translation here, the canvas |
| 700 // should also be scaled to accomodate device pixel ratio and pinch zoom. See | 701 // should also be scaled to accomodate device pixel ratio and pinch zoom. See |
| 701 // crbug.com/281516 and crbug.com/281518. | 702 // crbug.com/281516 and crbug.com/281518. |
| 702 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); | 703 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); |
| 704 canvas.scale(scale.x(), scale.y()); |
| 703 canvas.drawSprite(source, 0, 0, &paint); | 705 canvas.drawSprite(source, 0, 0, &paint); |
| 704 | 706 |
| 705 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 707 // Flush the GrContext to ensure all buffered GL calls are drawn to the |
| 706 // backing store before we access and return it, and have cc begin using the | 708 // backing store before we access and return it, and have cc begin using the |
| 707 // GL context again. | 709 // GL context again. |
| 708 use_gr_context->context()->flush(); | 710 use_gr_context->context()->flush(); |
| 709 | 711 |
| 710 return device->accessBitmap(false); | 712 return device->accessBitmap(false); |
| 711 } | 713 } |
| 712 | 714 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 896 |
| 895 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 897 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 896 quad->background_filters, device_background_texture->size()); | 898 quad->background_filters, device_background_texture->size()); |
| 897 | 899 |
| 898 SkBitmap filtered_device_background; | 900 SkBitmap filtered_device_background; |
| 899 if (apply_background_filters) { | 901 if (apply_background_filters) { |
| 900 filtered_device_background = | 902 filtered_device_background = |
| 901 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 903 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 902 resource_provider_, | 904 resource_provider_, |
| 903 quad->rect.origin(), | 905 quad->rect.origin(), |
| 906 quad->filters_scale, |
| 904 filter.get(), | 907 filter.get(), |
| 905 device_background_texture.get()); | 908 device_background_texture.get()); |
| 906 } | 909 } |
| 907 *background_changed = (filtered_device_background.getTexture() != NULL); | 910 *background_changed = (filtered_device_background.getTexture() != NULL); |
| 908 | 911 |
| 909 int filtered_device_background_texture_id = 0; | 912 int filtered_device_background_texture_id = 0; |
| 910 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; | 913 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; |
| 911 if (filtered_device_background.getTexture()) { | 914 if (filtered_device_background.getTexture()) { |
| 912 GrTexture* texture = | 915 GrTexture* texture = |
| 913 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); | 916 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 | 1027 |
| 1025 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { | 1028 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
| 1026 // We have a single color matrix as a filter; apply it locally | 1029 // We have a single color matrix as a filter; apply it locally |
| 1027 // in the compositor. | 1030 // in the compositor. |
| 1028 use_color_matrix = true; | 1031 use_color_matrix = true; |
| 1029 } else { | 1032 } else { |
| 1030 filter_bitmap = | 1033 filter_bitmap = |
| 1031 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 1034 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 1032 resource_provider_, | 1035 resource_provider_, |
| 1033 quad->rect.origin(), | 1036 quad->rect.origin(), |
| 1037 quad->filters_scale, |
| 1034 filter.get(), | 1038 filter.get(), |
| 1035 contents_texture); | 1039 contents_texture); |
| 1036 } | 1040 } |
| 1037 } | 1041 } |
| 1038 } | 1042 } |
| 1039 | 1043 |
| 1040 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && | 1044 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && |
| 1041 background_texture) { | 1045 background_texture) { |
| 1042 filter_bitmap = | 1046 filter_bitmap = |
| 1043 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), | 1047 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3195 context_support_->ScheduleOverlayPlane( | 3199 context_support_->ScheduleOverlayPlane( |
| 3196 overlay.plane_z_order, | 3200 overlay.plane_z_order, |
| 3197 overlay.transform, | 3201 overlay.transform, |
| 3198 pending_overlay_resources_.back()->texture_id(), | 3202 pending_overlay_resources_.back()->texture_id(), |
| 3199 overlay.display_rect, | 3203 overlay.display_rect, |
| 3200 overlay.uv_rect); | 3204 overlay.uv_rect); |
| 3201 } | 3205 } |
| 3202 } | 3206 } |
| 3203 | 3207 |
| 3204 } // namespace cc | 3208 } // namespace cc |
| OLD | NEW |