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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 static sk_sp<SkImage> ApplyImageFilter( | 658 static sk_sp<SkImage> ApplyImageFilter( |
659 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 659 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
660 ResourceProvider* resource_provider, | 660 ResourceProvider* resource_provider, |
661 const gfx::RectF& src_rect, | 661 const gfx::RectF& src_rect, |
662 const gfx::RectF& dst_rect, | 662 const gfx::RectF& dst_rect, |
663 const gfx::Vector2dF& scale, | 663 const gfx::Vector2dF& scale, |
664 sk_sp<SkImageFilter> filter, | 664 sk_sp<SkImageFilter> filter, |
665 const Resource* source_texture_resource, | 665 const Resource* source_texture_resource, |
666 SkIPoint* offset, | 666 SkIPoint* offset, |
667 SkIRect* subset, | 667 SkIRect* subset, |
668 bool flip_texture) { | 668 bool flip_texture, |
| 669 const gfx::PointF& origin) { |
669 if (!filter || !use_gr_context) | 670 if (!filter || !use_gr_context) |
670 return nullptr; | 671 return nullptr; |
671 | 672 |
672 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 673 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
673 source_texture_resource->id()); | 674 source_texture_resource->id()); |
674 | 675 |
675 sk_sp<SkImage> src_image = | 676 sk_sp<SkImage> src_image = |
676 WrapTexture(lock, use_gr_context->context(), flip_texture); | 677 WrapTexture(lock, use_gr_context->context(), flip_texture); |
677 | 678 |
678 if (!src_image) { | 679 if (!src_image) { |
679 TRACE_EVENT_INSTANT0("cc", | 680 TRACE_EVENT_INSTANT0("cc", |
680 "ApplyImageFilter wrap background texture failed", | 681 "ApplyImageFilter wrap background texture failed", |
681 TRACE_EVENT_SCOPE_THREAD); | 682 TRACE_EVENT_SCOPE_THREAD); |
682 return nullptr; | 683 return nullptr; |
683 } | 684 } |
684 | 685 |
685 SkMatrix local_matrix; | 686 SkMatrix local_matrix; |
686 local_matrix.setTranslate(-src_rect.x(), -src_rect.y()); | 687 local_matrix.setTranslate(origin.x(), origin.y()); |
687 local_matrix.postScale(scale.x(), scale.y()); | 688 local_matrix.postScale(scale.x(), scale.y()); |
| 689 local_matrix.postTranslate(-src_rect.x(), -src_rect.y()); |
688 | 690 |
689 SkIRect clip_bounds = gfx::RectFToSkRect(dst_rect).roundOut(); | 691 SkIRect clip_bounds = gfx::RectFToSkRect(dst_rect).roundOut(); |
690 clip_bounds.offset(-src_rect.x(), -src_rect.y()); | 692 clip_bounds.offset(-src_rect.x(), -src_rect.y()); |
691 filter = filter->makeWithLocalMatrix(local_matrix); | 693 filter = filter->makeWithLocalMatrix(local_matrix); |
692 SkIRect in_subset = SkIRect::MakeWH(src_rect.width(), src_rect.height()); | 694 SkIRect in_subset = SkIRect::MakeWH(src_rect.width(), src_rect.height()); |
693 sk_sp<SkImage> image = src_image->makeWithFilter(filter.get(), in_subset, | 695 sk_sp<SkImage> image = src_image->makeWithFilter(filter.get(), in_subset, |
694 clip_bounds, subset, offset); | 696 clip_bounds, subset, offset); |
695 | 697 |
696 if (!image || !image->isTextureBacked()) { | 698 if (!image || !image->isTextureBacked()) { |
697 return nullptr; | 699 return nullptr; |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 UpdateRPDQTexturesForSampling(params); | 1066 UpdateRPDQTexturesForSampling(params); |
1065 UpdateRPDQBlendMode(params); | 1067 UpdateRPDQBlendMode(params); |
1066 ChooseRPDQProgram(params); | 1068 ChooseRPDQProgram(params); |
1067 UpdateRPDQUniforms(params); | 1069 UpdateRPDQUniforms(params); |
1068 DrawRPDQ(*params); | 1070 DrawRPDQ(*params); |
1069 } | 1071 } |
1070 | 1072 |
1071 bool GLRenderer::InitializeRPDQParameters( | 1073 bool GLRenderer::InitializeRPDQParameters( |
1072 DrawRenderPassDrawQuadParams* params) { | 1074 DrawRenderPassDrawQuadParams* params) { |
1073 const RenderPassDrawQuad* quad = params->quad; | 1075 const RenderPassDrawQuad* quad = params->quad; |
1074 SkMatrix scale_matrix; | 1076 SkMatrix local_matrix; |
1075 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); | 1077 local_matrix.setTranslate(quad->filters_origin.x(), quad->filters_origin.y()); |
1076 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, scale_matrix); | 1078 local_matrix.postScale(quad->filters_scale.x(), quad->filters_scale.y()); |
| 1079 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, local_matrix); |
1077 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()), | 1080 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()), |
1078 static_cast<float>(dst_rect.y()), | 1081 static_cast<float>(dst_rect.y()), |
1079 static_cast<float>(dst_rect.width()), | 1082 static_cast<float>(dst_rect.width()), |
1080 static_cast<float>(dst_rect.height())); | 1083 static_cast<float>(dst_rect.height())); |
1081 gfx::Transform quad_rect_matrix; | 1084 gfx::Transform quad_rect_matrix; |
1082 QuadRectTransform(&quad_rect_matrix, params->quad_to_target_transform, | 1085 QuadRectTransform(&quad_rect_matrix, params->quad_to_target_transform, |
1083 params->dst_rect); | 1086 params->dst_rect); |
1084 params->contents_device_transform = | 1087 params->contents_device_transform = |
1085 params->window_matrix * params->projection_matrix * quad_rect_matrix; | 1088 params->window_matrix * params->projection_matrix * quad_rect_matrix; |
1086 params->contents_device_transform.FlattenTo2d(); | 1089 params->contents_device_transform.FlattenTo2d(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 // nothing to draw. | 1213 // nothing to draw. |
1211 if (params->dst_rect.IsEmpty()) { | 1214 if (params->dst_rect.IsEmpty()) { |
1212 return false; | 1215 return false; |
1213 } | 1216 } |
1214 SkIPoint offset; | 1217 SkIPoint offset; |
1215 SkIRect subset; | 1218 SkIRect subset; |
1216 gfx::RectF src_rect(quad->rect); | 1219 gfx::RectF src_rect(quad->rect); |
1217 params->filter_image = ApplyImageFilter( | 1220 params->filter_image = ApplyImageFilter( |
1218 ScopedUseGrContext::Create(this), resource_provider_, src_rect, | 1221 ScopedUseGrContext::Create(this), resource_provider_, src_rect, |
1219 params->dst_rect, quad->filters_scale, std::move(filter), | 1222 params->dst_rect, quad->filters_scale, std::move(filter), |
1220 params->contents_texture, &offset, &subset, params->flip_texture); | 1223 params->contents_texture, &offset, &subset, params->flip_texture, |
| 1224 quad->filters_origin); |
1221 if (!params->filter_image) | 1225 if (!params->filter_image) |
1222 return false; | 1226 return false; |
1223 params->dst_rect = | 1227 params->dst_rect = |
1224 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, | 1228 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, |
1225 subset.width(), subset.height()); | 1229 subset.width(), subset.height()); |
1226 params->src_offset.SetPoint(subset.x(), subset.y()); | 1230 params->src_offset.SetPoint(subset.x(), subset.y()); |
1227 } | 1231 } |
1228 } | 1232 } |
1229 } | 1233 } |
1230 return true; | 1234 return true; |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4026 | 4030 |
4027 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4031 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4028 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4032 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4029 sorting_context_id, gl_transform); | 4033 sorting_context_id, gl_transform); |
4030 gl_->ScheduleCALayerCHROMIUM( | 4034 gl_->ScheduleCALayerCHROMIUM( |
4031 texture_id, contents_rect, ca_layer_overlay->background_color, | 4035 texture_id, contents_rect, ca_layer_overlay->background_color, |
4032 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4036 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4033 } | 4037 } |
4034 | 4038 |
4035 } // namespace cc | 4039 } // namespace cc |
OLD | NEW |