| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 skia::RefPtr<SkGpuDevice> device = | 690 skia::RefPtr<SkGpuDevice> device = |
| 690 skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget())); | 691 skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget())); |
| 691 DCHECK(device.get()); | 692 DCHECK(device.get()); |
| 692 SkCanvas canvas(device.get()); | 693 SkCanvas canvas(device.get()); |
| 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 // should also be scaled to accomodate device pixel ratio and pinch zoom. See | |
| 701 // crbug.com/281516 and crbug.com/281518. | |
| 702 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); | 700 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); |
| 701 canvas.scale(scale.x(), scale.y()); |
| 703 canvas.drawSprite(source, 0, 0, &paint); | 702 canvas.drawSprite(source, 0, 0, &paint); |
| 704 | 703 |
| 705 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 704 // 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 | 705 // backing store before we access and return it, and have cc begin using the |
| 707 // GL context again. | 706 // GL context again. |
| 708 use_gr_context->context()->flush(); | 707 use_gr_context->context()->flush(); |
| 709 | 708 |
| 710 return device->accessBitmap(false); | 709 return device->accessBitmap(false); |
| 711 } | 710 } |
| 712 | 711 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 893 |
| 895 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 894 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 896 quad->background_filters, device_background_texture->size()); | 895 quad->background_filters, device_background_texture->size()); |
| 897 | 896 |
| 898 SkBitmap filtered_device_background; | 897 SkBitmap filtered_device_background; |
| 899 if (apply_background_filters) { | 898 if (apply_background_filters) { |
| 900 filtered_device_background = | 899 filtered_device_background = |
| 901 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 900 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 902 resource_provider_, | 901 resource_provider_, |
| 903 quad->rect.origin(), | 902 quad->rect.origin(), |
| 903 quad->filters_scale, |
| 904 filter.get(), | 904 filter.get(), |
| 905 device_background_texture.get()); | 905 device_background_texture.get()); |
| 906 } | 906 } |
| 907 *background_changed = (filtered_device_background.getTexture() != NULL); | 907 *background_changed = (filtered_device_background.getTexture() != NULL); |
| 908 | 908 |
| 909 int filtered_device_background_texture_id = 0; | 909 int filtered_device_background_texture_id = 0; |
| 910 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; | 910 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; |
| 911 if (filtered_device_background.getTexture()) { | 911 if (filtered_device_background.getTexture()) { |
| 912 GrTexture* texture = | 912 GrTexture* texture = |
| 913 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); | 913 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 | 1024 |
| 1025 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { | 1025 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
| 1026 // We have a single color matrix as a filter; apply it locally | 1026 // We have a single color matrix as a filter; apply it locally |
| 1027 // in the compositor. | 1027 // in the compositor. |
| 1028 use_color_matrix = true; | 1028 use_color_matrix = true; |
| 1029 } else { | 1029 } else { |
| 1030 filter_bitmap = | 1030 filter_bitmap = |
| 1031 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 1031 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 1032 resource_provider_, | 1032 resource_provider_, |
| 1033 quad->rect.origin(), | 1033 quad->rect.origin(), |
| 1034 quad->filters_scale, |
| 1034 filter.get(), | 1035 filter.get(), |
| 1035 contents_texture); | 1036 contents_texture); |
| 1036 } | 1037 } |
| 1037 } | 1038 } |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && | 1041 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && |
| 1041 background_texture) { | 1042 background_texture) { |
| 1042 filter_bitmap = | 1043 filter_bitmap = |
| 1043 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), | 1044 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 context_support_->ScheduleOverlayPlane( | 3197 context_support_->ScheduleOverlayPlane( |
| 3197 overlay.plane_z_order, | 3198 overlay.plane_z_order, |
| 3198 overlay.transform, | 3199 overlay.transform, |
| 3199 pending_overlay_resources_.back()->texture_id(), | 3200 pending_overlay_resources_.back()->texture_id(), |
| 3200 overlay.display_rect, | 3201 overlay.display_rect, |
| 3201 overlay.uv_rect); | 3202 overlay.uv_rect); |
| 3202 } | 3203 } |
| 3203 } | 3204 } |
| 3204 | 3205 |
| 3205 } // namespace cc | 3206 } // namespace cc |
| OLD | NEW |