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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 582 |
583 gl_->LineWidth(quad->width); | 583 gl_->LineWidth(quad->width); |
584 | 584 |
585 // The indices for the line are stored in the same array as the triangle | 585 // The indices for the line are stored in the same array as the triangle |
586 // indices. | 586 // indices. |
587 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); | 587 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); |
588 } | 588 } |
589 | 589 |
590 static sk_sp<SkImage> WrapTexture( | 590 static sk_sp<SkImage> WrapTexture( |
591 const ResourceProvider::ScopedReadLockGL& lock, | 591 const ResourceProvider::ScopedReadLockGL& lock, |
592 GrContext* context) { | 592 GrContext* context, |
| 593 bool flip_texture) { |
593 // Wrap a given texture in a Ganesh platform texture. | 594 // Wrap a given texture in a Ganesh platform texture. |
594 GrBackendTextureDesc backend_texture_description; | 595 GrBackendTextureDesc backend_texture_description; |
595 GrGLTextureInfo texture_info; | 596 GrGLTextureInfo texture_info; |
596 texture_info.fTarget = lock.target(); | 597 texture_info.fTarget = lock.target(); |
597 texture_info.fID = lock.texture_id(); | 598 texture_info.fID = lock.texture_id(); |
598 backend_texture_description.fWidth = lock.texture_size().width(); | 599 backend_texture_description.fWidth = lock.texture_size().width(); |
599 backend_texture_description.fHeight = lock.texture_size().height(); | 600 backend_texture_description.fHeight = lock.texture_size().height(); |
600 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; | 601 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; |
601 backend_texture_description.fTextureHandle = | 602 backend_texture_description.fTextureHandle = |
602 skia::GrGLTextureInfoToGrBackendObject(texture_info); | 603 skia::GrGLTextureInfoToGrBackendObject(texture_info); |
603 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; | 604 backend_texture_description.fOrigin = |
| 605 flip_texture ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; |
604 | 606 |
605 return SkImage::MakeFromTexture(context, backend_texture_description); | 607 return SkImage::MakeFromTexture(context, backend_texture_description); |
606 } | 608 } |
607 | 609 |
608 static sk_sp<SkImage> ApplyImageFilter( | 610 static sk_sp<SkImage> ApplyImageFilter( |
609 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 611 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
610 ResourceProvider* resource_provider, | 612 ResourceProvider* resource_provider, |
611 const gfx::RectF& src_rect, | 613 const gfx::RectF& src_rect, |
612 const gfx::RectF& dst_rect, | 614 const gfx::RectF& dst_rect, |
613 const gfx::Vector2dF& scale, | 615 const gfx::Vector2dF& scale, |
614 sk_sp<SkImageFilter> filter, | 616 sk_sp<SkImageFilter> filter, |
615 ScopedResource* source_texture_resource, | 617 const Resource* source_texture_resource, |
616 SkIPoint* offset, | 618 SkIPoint* offset, |
617 SkIRect* subset) { | 619 SkIRect* subset, |
| 620 bool flip_texture) { |
618 if (!filter || !use_gr_context) | 621 if (!filter || !use_gr_context) |
619 return nullptr; | 622 return nullptr; |
620 | 623 |
621 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 624 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
622 source_texture_resource->id()); | 625 source_texture_resource->id()); |
623 | 626 |
624 sk_sp<SkImage> src_image = WrapTexture(lock, use_gr_context->context()); | 627 sk_sp<SkImage> src_image = |
| 628 WrapTexture(lock, use_gr_context->context(), flip_texture); |
| 629 |
625 if (!src_image) { | 630 if (!src_image) { |
626 TRACE_EVENT_INSTANT0("cc", | 631 TRACE_EVENT_INSTANT0("cc", |
627 "ApplyImageFilter wrap background texture failed", | 632 "ApplyImageFilter wrap background texture failed", |
628 TRACE_EVENT_SCOPE_THREAD); | 633 TRACE_EVENT_SCOPE_THREAD); |
629 return nullptr; | 634 return nullptr; |
630 } | 635 } |
631 | 636 |
632 SkMatrix local_matrix; | 637 SkMatrix local_matrix; |
633 local_matrix.setTranslate(-src_rect.x(), -src_rect.y()); | 638 local_matrix.setTranslate(-src_rect.x(), -src_rect.y()); |
634 local_matrix.postScale(scale.x(), scale.y()); | 639 local_matrix.postScale(scale.x(), scale.y()); |
635 | 640 |
636 SkIRect clip_bounds = gfx::RectFToSkRect(dst_rect).roundOut(); | 641 SkIRect clip_bounds = gfx::RectFToSkRect(dst_rect).roundOut(); |
637 clip_bounds.offset(-src_rect.x(), -src_rect.y()); | 642 clip_bounds.offset(-src_rect.x(), -src_rect.y()); |
638 filter = filter->makeWithLocalMatrix(local_matrix); | 643 filter = filter->makeWithLocalMatrix(local_matrix); |
639 SkIRect in_subset = SkIRect::MakeWH(src_image->width(), src_image->height()); | 644 SkIRect in_subset = SkIRect::MakeWH(src_rect.width(), src_rect.height()); |
640 sk_sp<SkImage> image = src_image->makeWithFilter(filter.get(), in_subset, | 645 sk_sp<SkImage> image = src_image->makeWithFilter(filter.get(), in_subset, |
641 clip_bounds, subset, offset); | 646 clip_bounds, subset, offset); |
642 | 647 |
643 if (!image || !image->isTextureBacked()) { | 648 if (!image || !image->isTextureBacked()) { |
644 return nullptr; | 649 return nullptr; |
645 } | 650 } |
646 | 651 |
647 // Force a flush of the Skia pipeline before we switch back to the compositor | 652 // Force a flush of the Skia pipeline before we switch back to the compositor |
648 // context. | 653 // context. |
649 image->getTextureHandle(true); | 654 image->getTextureHandle(true); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 | 850 |
846 // TODO(senorblanco): background filters should be moved to the | 851 // TODO(senorblanco): background filters should be moved to the |
847 // makeWithFilter fast-path, and go back to calling ApplyImageFilter(). | 852 // makeWithFilter fast-path, and go back to calling ApplyImageFilter(). |
848 // See http://crbug.com/613233. | 853 // See http://crbug.com/613233. |
849 if (!filter || !use_gr_context) | 854 if (!filter || !use_gr_context) |
850 return nullptr; | 855 return nullptr; |
851 | 856 |
852 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 857 ResourceProvider::ScopedReadLockGL lock(resource_provider_, |
853 background_texture->id()); | 858 background_texture->id()); |
854 | 859 |
855 sk_sp<SkImage> src_image = WrapTexture(lock, use_gr_context->context()); | 860 bool flip_texture = true; |
| 861 sk_sp<SkImage> src_image = |
| 862 WrapTexture(lock, use_gr_context->context(), flip_texture); |
856 if (!src_image) { | 863 if (!src_image) { |
857 TRACE_EVENT_INSTANT0( | 864 TRACE_EVENT_INSTANT0( |
858 "cc", "ApplyBackgroundFilters wrap background texture failed", | 865 "cc", "ApplyBackgroundFilters wrap background texture failed", |
859 TRACE_EVENT_SCOPE_THREAD); | 866 TRACE_EVENT_SCOPE_THREAD); |
860 return nullptr; | 867 return nullptr; |
861 } | 868 } |
862 | 869 |
863 // Create surface to draw into. | 870 // Create surface to draw into. |
864 SkImageInfo dst_info = | 871 SkImageInfo dst_info = |
865 SkImageInfo::MakeN32Premul(rect.width(), rect.height()); | 872 SkImageInfo::MakeN32Premul(rect.width(), rect.height()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 DCHECK(did_invert); | 910 DCHECK(did_invert); |
904 bool clipped = false; | 911 bool clipped = false; |
905 gfx::QuadF local_quad = | 912 gfx::QuadF local_quad = |
906 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped); | 913 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped); |
907 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may | 914 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may |
908 // cause device_quad to become clipped. To our knowledge this scenario does | 915 // cause device_quad to become clipped. To our knowledge this scenario does |
909 // not need to be handled differently than the unclipped case. | 916 // not need to be handled differently than the unclipped case. |
910 return local_quad; | 917 return local_quad; |
911 } | 918 } |
912 | 919 |
| 920 const TileDrawQuad* GLRenderer::CanPassBeDrawnDirectly(const RenderPass* pass) { |
| 921 // Can only collapse a single tile quad. |
| 922 if (pass->quad_list.size() != 1) |
| 923 return nullptr; |
| 924 // If we need copy requests, then render pass has to exist. |
| 925 if (!pass->copy_requests.empty()) |
| 926 return nullptr; |
| 927 |
| 928 const DrawQuad* quad = *pass->quad_list.BackToFrontBegin(); |
| 929 // Hack: this could be supported by concatenating transforms, but |
| 930 // in practice if there is one quad, it is at the origin of the render pass. |
| 931 if (!quad->shared_quad_state->quad_to_target_transform.IsIdentity()) |
| 932 return nullptr; |
| 933 // The quad is expected to be the entire layer so that AA edges are correct. |
| 934 if (gfx::Rect(quad->shared_quad_state->quad_layer_bounds) != quad->rect) |
| 935 return nullptr; |
| 936 if (quad->material != DrawQuad::TILED_CONTENT) |
| 937 return nullptr; |
| 938 |
| 939 const TileDrawQuad* tile_quad = TileDrawQuad::MaterialCast(quad); |
| 940 // Hack: this could be supported by passing in a subrectangle to draw |
| 941 // render pass, although in practice if there is only one quad there |
| 942 // will be no border texels on the input. |
| 943 if (tile_quad->tex_coord_rect != gfx::RectF(tile_quad->rect)) |
| 944 return nullptr; |
| 945 // Tile quad features not supported in render pass shaders. |
| 946 if (tile_quad->swizzle_contents || tile_quad->nearest_neighbor) |
| 947 return nullptr; |
| 948 // BUG=skia:3868, Skia currently doesn't support texture rectangle inputs. |
| 949 // See also the DCHECKs about GL_TEXTURE_2D in DrawRenderPassQuad. |
| 950 GLenum target = |
| 951 resource_provider_->GetResourceTextureTarget(tile_quad->resource_id()); |
| 952 if (target != GL_TEXTURE_2D) |
| 953 return nullptr; |
| 954 #if defined(OS_MACOSX) |
| 955 // On Macs, this path can sometimes lead to all black output. |
| 956 // TODO(enne): investigate this and remove this hack. |
| 957 return nullptr; |
| 958 #endif |
| 959 |
| 960 return tile_quad; |
| 961 } |
| 962 |
913 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, | 963 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
914 const RenderPassDrawQuad* quad, | 964 const RenderPassDrawQuad* quad, |
915 const gfx::QuadF* clip_region) { | 965 const gfx::QuadF* clip_region) { |
916 ScopedResource* contents_texture = | 966 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id); |
917 render_pass_textures_[quad->render_pass_id].get(); | 967 if (bypass != render_pass_bypass_quads_.end()) { |
918 DCHECK(contents_texture); | 968 TileDrawQuad* tile_quad = &bypass->second; |
919 DCHECK(contents_texture->id()); | 969 // RGBA_8888 here is arbitrary and unused. |
| 970 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size, |
| 971 ResourceFormat::RGBA_8888); |
| 972 // The projection matrix used by GLRenderer has a flip. As tile texture |
| 973 // inputs are oriented opposite to framebuffer outputs, don't flip via |
| 974 // texture coords and let the projection matrix naturallyd o it. |
| 975 bool flip_texture = false; |
| 976 DrawRenderPassQuadInternal(frame, quad, clip_region, &tile_resource, |
| 977 flip_texture); |
| 978 } else { |
| 979 ScopedResource* contents_texture = |
| 980 render_pass_textures_[quad->render_pass_id].get(); |
| 981 DCHECK(contents_texture); |
| 982 DCHECK(contents_texture->id()); |
| 983 // See above comments about texture flipping. When the input is a |
| 984 // render pass, it needs to an extra flip to be oriented correctly. |
| 985 bool flip_texture = true; |
| 986 DrawRenderPassQuadInternal(frame, quad, clip_region, contents_texture, |
| 987 flip_texture); |
| 988 } |
| 989 } |
920 | 990 |
| 991 void GLRenderer::DrawRenderPassQuadInternal(DrawingFrame* frame, |
| 992 const RenderPassDrawQuad* quad, |
| 993 const gfx::QuadF* clip_region, |
| 994 const Resource* contents_texture, |
| 995 bool flip_texture) { |
921 SkMatrix scale_matrix; | 996 SkMatrix scale_matrix; |
922 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); | 997 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); |
923 gfx::RectF dst_rect(quad->filters.MapRect(quad->rect, scale_matrix)); | 998 gfx::RectF dst_rect(quad->filters.MapRect(quad->rect, scale_matrix)); |
924 gfx::Transform quad_rect_matrix; | 999 gfx::Transform quad_rect_matrix; |
925 QuadRectTransform(&quad_rect_matrix, | 1000 QuadRectTransform(&quad_rect_matrix, |
926 quad->shared_quad_state->quad_to_target_transform, | 1001 quad->shared_quad_state->quad_to_target_transform, |
927 dst_rect); | 1002 dst_rect); |
928 gfx::Transform contents_device_transform = | 1003 gfx::Transform contents_device_transform = |
929 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; | 1004 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; |
930 contents_device_transform.FlattenTo2d(); | 1005 contents_device_transform.FlattenTo2d(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 !use_shaders_for_blending && | 1090 !use_shaders_for_blending && |
1016 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode))); | 1091 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode))); |
1017 | 1092 |
1018 // TODO(senorblanco): Cache this value so that we don't have to do it for both | 1093 // TODO(senorblanco): Cache this value so that we don't have to do it for both |
1019 // the surface and its replica. Apply filters to the contents texture. | 1094 // the surface and its replica. Apply filters to the contents texture. |
1020 sk_sp<SkImage> filter_image; | 1095 sk_sp<SkImage> filter_image; |
1021 GLuint filter_image_id = 0; | 1096 GLuint filter_image_id = 0; |
1022 SkScalar color_matrix[20]; | 1097 SkScalar color_matrix[20]; |
1023 bool use_color_matrix = false; | 1098 bool use_color_matrix = false; |
1024 gfx::Size texture_size = contents_texture->size(); | 1099 gfx::Size texture_size = contents_texture->size(); |
1025 bool flip_texture = true; | |
1026 gfx::Point src_offset; | 1100 gfx::Point src_offset; |
1027 if (!quad->filters.IsEmpty()) { | 1101 if (!quad->filters.IsEmpty()) { |
1028 sk_sp<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 1102 sk_sp<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
1029 quad->filters, gfx::SizeF(contents_texture->size())); | 1103 quad->filters, gfx::SizeF(contents_texture->size())); |
1030 if (filter) { | 1104 if (filter) { |
1031 SkColorFilter* colorfilter_rawptr = NULL; | 1105 SkColorFilter* colorfilter_rawptr = NULL; |
1032 filter->asColorFilter(&colorfilter_rawptr); | 1106 filter->asColorFilter(&colorfilter_rawptr); |
1033 sk_sp<SkColorFilter> cf(colorfilter_rawptr); | 1107 sk_sp<SkColorFilter> cf(colorfilter_rawptr); |
1034 | 1108 |
1035 if (cf && cf->asColorMatrix(color_matrix)) { | 1109 if (cf && cf->asColorMatrix(color_matrix)) { |
(...skipping 14 matching lines...) Expand all Loading... |
1050 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); | 1124 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); |
1051 dst_rect.Intersect(local_clip.BoundingBox()); | 1125 dst_rect.Intersect(local_clip.BoundingBox()); |
1052 // If we've been fully clipped out (by crop rect or clipping), there's | 1126 // If we've been fully clipped out (by crop rect or clipping), there's |
1053 // nothing to draw. | 1127 // nothing to draw. |
1054 if (dst_rect.IsEmpty()) { | 1128 if (dst_rect.IsEmpty()) { |
1055 return; | 1129 return; |
1056 } | 1130 } |
1057 SkIPoint offset; | 1131 SkIPoint offset; |
1058 SkIRect subset; | 1132 SkIRect subset; |
1059 gfx::RectF src_rect(quad->rect); | 1133 gfx::RectF src_rect(quad->rect); |
1060 filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 1134 filter_image = ApplyImageFilter( |
1061 resource_provider_, src_rect, dst_rect, | 1135 ScopedUseGrContext::Create(this, frame), resource_provider_, |
1062 quad->filters_scale, std::move(filter), | 1136 src_rect, dst_rect, quad->filters_scale, std::move(filter), |
1063 contents_texture, &offset, &subset); | 1137 contents_texture, &offset, &subset, flip_texture); |
1064 if (!filter_image) { | 1138 if (!filter_image) |
1065 return; | 1139 return; |
1066 } | |
1067 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( | 1140 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( |
1068 filter_image->getTextureHandle(true)) | 1141 filter_image->getTextureHandle(true)) |
1069 ->fID; | 1142 ->fID; |
1070 texture_size.set_width(filter_image->width()); | 1143 texture_size.set_width(filter_image->width()); |
1071 texture_size.set_height(filter_image->height()); | 1144 texture_size.set_height(filter_image->height()); |
1072 DCHECK(filter_image_id); | 1145 DCHECK(filter_image_id); |
1073 dst_rect = | 1146 dst_rect = |
1074 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, | 1147 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, |
1075 subset.width(), subset.height()); | 1148 subset.width(), subset.height()); |
1076 src_offset.SetPoint(subset.x(), subset.y()); | 1149 src_offset.SetPoint(subset.x(), subset.y()); |
| 1150 // If the output of the filter needs to be flipped. |
1077 flip_texture = | 1151 flip_texture = |
1078 filter_image->getTexture()->origin() == kBottomLeft_GrSurfaceOrigin; | 1152 filter_image->getTexture()->origin() == kBottomLeft_GrSurfaceOrigin; |
1079 } | 1153 } |
1080 } | 1154 } |
1081 } | 1155 } |
1082 | 1156 |
1083 std::unique_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; | 1157 std::unique_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; |
1084 unsigned mask_texture_id = 0; | 1158 unsigned mask_texture_id = 0; |
1085 SamplerType mask_sampler = SAMPLER_TYPE_NA; | 1159 SamplerType mask_sampler = SAMPLER_TYPE_NA; |
1086 if (quad->mask_resource_id()) { | 1160 if (quad->mask_resource_id()) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); | 1266 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); |
1193 | 1267 |
1194 DCHECK(locations.tex_transform != -1 || IsContextLost()); | 1268 DCHECK(locations.tex_transform != -1 || IsContextLost()); |
1195 if (flip_texture) { | 1269 if (flip_texture) { |
1196 // Flip the content vertically in the shader, as the RenderPass input | 1270 // Flip the content vertically in the shader, as the RenderPass input |
1197 // texture is already oriented the same way as the framebuffer, but the | 1271 // texture is already oriented the same way as the framebuffer, but the |
1198 // projection transform does a flip. | 1272 // projection transform does a flip. |
1199 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), 1.0f - tex_rect.y(), | 1273 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), 1.0f - tex_rect.y(), |
1200 tex_rect.width(), -tex_rect.height()); | 1274 tex_rect.width(), -tex_rect.height()); |
1201 } else { | 1275 } else { |
| 1276 // Tile textures are oriented opposite the framebuffer, so can use |
| 1277 // the projection transform to do the flip. |
1202 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), tex_rect.y(), | 1278 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), tex_rect.y(), |
1203 tex_rect.width(), tex_rect.height()); | 1279 tex_rect.width(), tex_rect.height()); |
1204 } | 1280 } |
1205 | 1281 |
1206 GLint last_texture_unit = 0; | 1282 GLint last_texture_unit = 0; |
1207 if (locations.mask_sampler != -1) { | 1283 if (locations.mask_sampler != -1) { |
1208 DCHECK_NE(locations.mask_tex_coord_scale, 1); | 1284 DCHECK_NE(locations.mask_tex_coord_scale, 1); |
1209 DCHECK_NE(locations.mask_tex_coord_offset, 1); | 1285 DCHECK_NE(locations.mask_tex_coord_offset, 1); |
1210 gl_->Uniform1i(locations.mask_sampler, 1); | 1286 gl_->Uniform1i(locations.mask_sampler, 1); |
1211 | 1287 |
1212 gfx::RectF mask_uv_rect = quad->MaskUVRect(); | 1288 gfx::RectF mask_uv_rect = quad->MaskUVRect(); |
1213 if (mask_sampler != SAMPLER_TYPE_2D) { | 1289 if (mask_sampler != SAMPLER_TYPE_2D) { |
1214 mask_uv_rect.Scale(quad->mask_texture_size.width(), | 1290 mask_uv_rect.Scale(quad->mask_texture_size.width(), |
1215 quad->mask_texture_size.height()); | 1291 quad->mask_texture_size.height()); |
1216 } | 1292 } |
1217 | 1293 if (flip_texture) { |
1218 // Mask textures are oriented vertically flipped relative to the framebuffer | 1294 // Mask textures are oriented vertically flipped relative to the |
1219 // and the RenderPass contents texture, so we flip the tex coords from the | 1295 // framebuffer and the RenderPass contents texture, so we flip the tex |
1220 // RenderPass texture to find the mask texture coords. | 1296 // coords from the RenderPass texture to find the mask texture coords. |
1221 gl_->Uniform2f( | 1297 gl_->Uniform2f( |
1222 locations.mask_tex_coord_offset, mask_uv_rect.x(), | 1298 locations.mask_tex_coord_offset, mask_uv_rect.x(), |
1223 mask_uv_rect.height() / tex_rect.height() + mask_uv_rect.y()); | 1299 mask_uv_rect.height() / tex_rect.height() + mask_uv_rect.y()); |
1224 gl_->Uniform2f(locations.mask_tex_coord_scale, | 1300 gl_->Uniform2f(locations.mask_tex_coord_scale, |
1225 mask_uv_rect.width() / tex_rect.width(), | 1301 mask_uv_rect.width() / tex_rect.width(), |
1226 -mask_uv_rect.height() / tex_rect.height()); | 1302 -mask_uv_rect.height() / tex_rect.height()); |
| 1303 } else { |
| 1304 // Tile textures are oriented the same way as mask textures. |
| 1305 gl_->Uniform2f(locations.mask_tex_coord_offset, mask_uv_rect.x(), |
| 1306 mask_uv_rect.y()); |
| 1307 gl_->Uniform2f(locations.mask_tex_coord_scale, |
| 1308 mask_uv_rect.width() / tex_rect.width(), |
| 1309 mask_uv_rect.height() / tex_rect.height()); |
| 1310 } |
1227 | 1311 |
1228 last_texture_unit = 1; | 1312 last_texture_unit = 1; |
1229 } | 1313 } |
1230 | 1314 |
1231 if (locations.edge != -1) | 1315 if (locations.edge != -1) |
1232 gl_->Uniform3fv(locations.edge, 8, edge); | 1316 gl_->Uniform3fv(locations.edge, 8, edge); |
1233 | 1317 |
1234 if (locations.viewport != -1) { | 1318 if (locations.viewport != -1) { |
1235 float viewport[4] = { | 1319 float viewport[4] = { |
1236 static_cast<float>(current_window_space_viewport_.x()), | 1320 static_cast<float>(current_window_space_viewport_.x()), |
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3644 texture_id = pending_overlay_resources_.back()->GetTextureId(); | 3728 texture_id = pending_overlay_resources_.back()->GetTextureId(); |
3645 } | 3729 } |
3646 | 3730 |
3647 context_support_->ScheduleOverlayPlane( | 3731 context_support_->ScheduleOverlayPlane( |
3648 overlay.plane_z_order, overlay.transform, texture_id, | 3732 overlay.plane_z_order, overlay.transform, texture_id, |
3649 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3733 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3650 } | 3734 } |
3651 } | 3735 } |
3652 | 3736 |
3653 } // namespace cc | 3737 } // namespace cc |
OLD | NEW |