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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 635 |
636 // The indices for the line are stored in the same array as the triangle | 636 // The indices for the line are stored in the same array as the triangle |
637 // indices. | 637 // indices. |
638 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); | 638 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); |
639 } | 639 } |
640 | 640 |
641 static SkBitmap ApplyImageFilter( | 641 static SkBitmap ApplyImageFilter( |
642 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 642 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
643 ResourceProvider* resource_provider, | 643 ResourceProvider* resource_provider, |
644 const gfx::Point& origin, | 644 const gfx::Point& origin, |
| 645 const gfx::Vector2dF& scale, |
645 SkImageFilter* filter, | 646 SkImageFilter* filter, |
646 ScopedResource* source_texture_resource) { | 647 ScopedResource* source_texture_resource) { |
647 if (!filter) | 648 if (!filter) |
648 return SkBitmap(); | 649 return SkBitmap(); |
649 | 650 |
650 if (!use_gr_context) | 651 if (!use_gr_context) |
651 return SkBitmap(); | 652 return SkBitmap(); |
652 | 653 |
653 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 654 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
654 source_texture_resource->id()); | 655 source_texture_resource->id()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 | 703 |
703 // Draw the source bitmap through the filter to the canvas. | 704 // Draw the source bitmap through the filter to the canvas. |
704 SkPaint paint; | 705 SkPaint paint; |
705 paint.setImageFilter(filter); | 706 paint.setImageFilter(filter); |
706 canvas.clear(SK_ColorTRANSPARENT); | 707 canvas.clear(SK_ColorTRANSPARENT); |
707 | 708 |
708 // TODO(senorblanco): in addition to the origin translation here, the canvas | 709 // TODO(senorblanco): in addition to the origin translation here, the canvas |
709 // should also be scaled to accomodate device pixel ratio and pinch zoom. See | 710 // should also be scaled to accomodate device pixel ratio and pinch zoom. See |
710 // crbug.com/281516 and crbug.com/281518. | 711 // crbug.com/281516 and crbug.com/281518. |
711 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); | 712 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); |
| 713 canvas.scale(scale.x(), scale.y()); |
712 canvas.drawSprite(source, 0, 0, &paint); | 714 canvas.drawSprite(source, 0, 0, &paint); |
713 | 715 |
714 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 716 // Flush the GrContext to ensure all buffered GL calls are drawn to the |
715 // backing store before we access and return it, and have cc begin using the | 717 // backing store before we access and return it, and have cc begin using the |
716 // GL context again. | 718 // GL context again. |
717 use_gr_context->context()->flush(); | 719 use_gr_context->context()->flush(); |
718 | 720 |
719 return device->accessBitmap(false); | 721 return device->accessBitmap(false); |
720 } | 722 } |
721 | 723 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 | 905 |
904 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 906 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
905 quad->background_filters, device_background_texture->size()); | 907 quad->background_filters, device_background_texture->size()); |
906 | 908 |
907 SkBitmap filtered_device_background; | 909 SkBitmap filtered_device_background; |
908 if (apply_background_filters) { | 910 if (apply_background_filters) { |
909 filtered_device_background = | 911 filtered_device_background = |
910 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 912 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
911 resource_provider_, | 913 resource_provider_, |
912 quad->rect.origin(), | 914 quad->rect.origin(), |
| 915 quad->filters_scale, |
913 filter.get(), | 916 filter.get(), |
914 device_background_texture.get()); | 917 device_background_texture.get()); |
915 } | 918 } |
916 *background_changed = (filtered_device_background.getTexture() != NULL); | 919 *background_changed = (filtered_device_background.getTexture() != NULL); |
917 | 920 |
918 int filtered_device_background_texture_id = 0; | 921 int filtered_device_background_texture_id = 0; |
919 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; | 922 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; |
920 if (filtered_device_background.getTexture()) { | 923 if (filtered_device_background.getTexture()) { |
921 GrTexture* texture = | 924 GrTexture* texture = |
922 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); | 925 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 | 1036 |
1034 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { | 1037 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
1035 // We have a single color matrix as a filter; apply it locally | 1038 // We have a single color matrix as a filter; apply it locally |
1036 // in the compositor. | 1039 // in the compositor. |
1037 use_color_matrix = true; | 1040 use_color_matrix = true; |
1038 } else { | 1041 } else { |
1039 filter_bitmap = | 1042 filter_bitmap = |
1040 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 1043 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
1041 resource_provider_, | 1044 resource_provider_, |
1042 quad->rect.origin(), | 1045 quad->rect.origin(), |
| 1046 quad->filters_scale, |
1043 filter.get(), | 1047 filter.get(), |
1044 contents_texture); | 1048 contents_texture); |
1045 } | 1049 } |
1046 } | 1050 } |
1047 } | 1051 } |
1048 | 1052 |
1049 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && | 1053 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && |
1050 background_texture) { | 1054 background_texture) { |
1051 filter_bitmap = | 1055 filter_bitmap = |
1052 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), | 1056 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), |
(...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3205 context_support_->ScheduleOverlayPlane( | 3209 context_support_->ScheduleOverlayPlane( |
3206 overlay.plane_z_order, | 3210 overlay.plane_z_order, |
3207 overlay.transform, | 3211 overlay.transform, |
3208 pending_overlay_resources_.back()->texture_id(), | 3212 pending_overlay_resources_.back()->texture_id(), |
3209 overlay.display_rect, | 3213 overlay.display_rect, |
3210 overlay.uv_rect); | 3214 overlay.uv_rect); |
3211 } | 3215 } |
3212 } | 3216 } |
3213 | 3217 |
3214 } // namespace cc | 3218 } // namespace cc |
OLD | NEW |