Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 658483003: Implement mix-blend-mode in GL renderer using shaders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing antialiasing issues Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) { 720 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) {
721 if (blend_mode == SkXfermode::kSrcOver_Mode) 721 if (blend_mode == SkXfermode::kSrcOver_Mode)
722 return; 722 return;
723 723
724 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 724 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
725 725
726 if (blend_mode == SkXfermode::kLighten_Mode) 726 if (blend_mode == SkXfermode::kLighten_Mode)
727 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); 727 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
728 } 728 }
729 729
730 static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop(
731 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
732 ResourceProvider* resource_provider,
733 skia::RefPtr<SkImage> source_bitmap_with_filters,
734 ScopedResource* source_texture_resource,
735 ScopedResource* background_texture_resource,
736 SkXfermode::Mode blend_mode) {
737 if (!use_gr_context)
738 return source_bitmap_with_filters;
739
740 DCHECK(background_texture_resource);
741 DCHECK(source_texture_resource);
742
743 gfx::Size source_size = source_texture_resource->size();
744 gfx::Size background_size = background_texture_resource->size();
745
746 DCHECK_LE(background_size.width(), source_size.width());
747 DCHECK_LE(background_size.height(), source_size.height());
748
749 int source_texture_with_filters_id;
750 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
751 if (source_bitmap_with_filters) {
752 DCHECK_EQ(source_size.width(), source_bitmap_with_filters->width());
753 DCHECK_EQ(source_size.height(), source_bitmap_with_filters->height());
754 GrTexture* texture =
755 reinterpret_cast<GrTexture*>(source_bitmap_with_filters->getTexture());
756 source_texture_with_filters_id = texture->getTextureHandle();
757 } else {
758 lock.reset(new ResourceProvider::ScopedReadLockGL(
759 resource_provider, source_texture_resource->id()));
760 source_texture_with_filters_id = lock->texture_id();
761 }
762
763 ResourceProvider::ScopedReadLockGL lock_background(
764 resource_provider, background_texture_resource->id());
765
766 // Wrap the source texture in a Ganesh platform texture.
767 GrBackendTextureDesc backend_texture_description;
768 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
769 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
770
771 backend_texture_description.fWidth = source_size.width();
772 backend_texture_description.fHeight = source_size.height();
773 backend_texture_description.fTextureHandle = source_texture_with_filters_id;
774 skia::RefPtr<GrTexture> source_texture =
775 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
776 backend_texture_description));
777 if (!source_texture) {
778 TRACE_EVENT_INSTANT0(
779 "cc",
780 "ApplyBlendModeWithBackdrop wrap source texture failed",
781 TRACE_EVENT_SCOPE_THREAD);
782 return skia::RefPtr<SkImage>();
783 }
784
785 backend_texture_description.fWidth = background_size.width();
786 backend_texture_description.fHeight = background_size.height();
787 backend_texture_description.fTextureHandle = lock_background.texture_id();
788 skia::RefPtr<GrTexture> background_texture =
789 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
790 backend_texture_description));
791 if (!background_texture) {
792 TRACE_EVENT_INSTANT0(
793 "cc",
794 "ApplyBlendModeWithBackdrop wrap background texture failed",
795 TRACE_EVENT_SCOPE_THREAD);
796 return skia::RefPtr<SkImage>();
797 }
798
799 SkImageInfo source_info =
800 SkImageInfo::MakeN32Premul(source_size.width(), source_size.height());
801 // Place the platform texture inside an SkBitmap.
802 SkBitmap source;
803 source.setInfo(source_info);
804 skia::RefPtr<SkGrPixelRef> source_pixel_ref =
805 skia::AdoptRef(new SkGrPixelRef(source_info, source_texture.get()));
806 source.setPixelRef(source_pixel_ref.get());
807
808 SkImageInfo background_info = SkImageInfo::MakeN32Premul(
809 background_size.width(), background_size.height());
810
811 SkBitmap background;
812 background.setInfo(background_info);
813 skia::RefPtr<SkGrPixelRef> background_pixel_ref =
814 skia::AdoptRef(new SkGrPixelRef(
815 background_info, background_texture.get()));
816 background.setPixelRef(background_pixel_ref.get());
817
818 // Create a scratch texture for backing store.
819 GrTextureDesc desc;
820 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
821 desc.fSampleCnt = 0;
822 desc.fWidth = source.width();
823 desc.fHeight = source.height();
824 desc.fConfig = kSkia8888_GrPixelConfig;
825 desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
826 GrAutoScratchTexture scratch_texture(
827 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
828 skia::RefPtr<GrTexture> backing_store =
829 skia::AdoptRef(scratch_texture.detach());
830 if (!backing_store) {
831 TRACE_EVENT_INSTANT0(
832 "cc",
833 "ApplyBlendModeWithBackdrop scratch texture allocation failed",
834 TRACE_EVENT_SCOPE_THREAD);
835 return source_bitmap_with_filters;
836 }
837
838 // Create a device and canvas using that backing store.
839 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
840 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
841 if (!surface)
842 return skia::RefPtr<SkImage>();
843 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
844
845 // Draw the source bitmap through the filter to the canvas.
846 canvas->clear(SK_ColorTRANSPARENT);
847 canvas->drawSprite(background, 0, 0);
848 SkPaint paint;
849 paint.setXfermodeMode(blend_mode);
850 canvas->drawSprite(source, 0, 0, &paint);
851
852 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot());
853 if (!image || !image->getTexture()) {
854 return skia::RefPtr<SkImage>();
855 }
856
857 // Flush the GrContext to ensure all buffered GL calls are drawn to the
858 // backing store before we access and return it, and have cc begin using the
859 // GL context again.
860 canvas->flush();
861
862 return image;
863 }
864
865 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame, 730 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame,
866 const RenderPassDrawQuad* quad) { 731 const RenderPassDrawQuad* quad) {
867 if (quad->background_filters.IsEmpty()) 732 if (quad->background_filters.IsEmpty())
868 return false; 733 return false;
869 734
870 // TODO(danakj): We only allow background filters on an opaque render surface 735 // TODO(danakj): We only allow background filters on an opaque render surface
871 // because other surfaces may contain translucent pixels, and the contents 736 // because other surfaces may contain translucent pixels, and the contents
872 // behind those translucent pixels wouldn't have the filter applied. 737 // behind those translucent pixels wouldn't have the filter applied.
873 if (frame->current_render_pass->has_transparent_background) 738 if (frame->current_render_pass->has_transparent_background)
874 return false; 739 return false;
875 740
876 // TODO(ajuma): Add support for reference filters once 741 // TODO(ajuma): Add support for reference filters once
877 // FilterOperations::GetOutsets supports reference filters. 742 // FilterOperations::GetOutsets supports reference filters.
878 if (quad->background_filters.HasReferenceFilter()) 743 if (quad->background_filters.HasReferenceFilter())
879 return false; 744 return false;
880 return true; 745 return true;
881 } 746 }
882 747
883 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad( 748 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(
884 DrawingFrame* frame, 749 DrawingFrame* frame,
885 const RenderPassDrawQuad* quad, 750 const RenderPassDrawQuad* quad,
886 const gfx::Transform& contents_device_transform) { 751 const gfx::Transform& contents_device_transform,
752 bool use_aa) {
887 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( 753 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect(
888 contents_device_transform, SharedGeometryQuad().BoundingBox())); 754 contents_device_transform, SharedGeometryQuad().BoundingBox()));
889 755
890 if (ShouldApplyBackgroundFilters(frame, quad)) { 756 if (ShouldApplyBackgroundFilters(frame, quad)) {
891 int top, right, bottom, left; 757 int top, right, bottom, left;
892 quad->background_filters.GetOutsets(&top, &right, &bottom, &left); 758 quad->background_filters.GetOutsets(&top, &right, &bottom, &left);
893 backdrop_rect.Inset(-left, -top, -right, -bottom); 759 backdrop_rect.Inset(-left, -top, -right, -bottom);
894 } 760 }
895 761
762 if (!backdrop_rect.IsEmpty() && use_aa) {
763 const int kOutsetForAntialiasing = 1;
764 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing);
765 }
766
896 backdrop_rect.Intersect( 767 backdrop_rect.Intersect(
897 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); 768 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect));
898 return backdrop_rect; 769 return backdrop_rect;
899 } 770 }
900 771
901 scoped_ptr<ScopedResource> GLRenderer::GetBackdropTexture( 772 scoped_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
902 const gfx::Rect& bounding_rect) { 773 const gfx::Rect& bounding_rect) {
903 scoped_ptr<ScopedResource> device_background_texture = 774 scoped_ptr<ScopedResource> device_background_texture =
904 ScopedResource::Create(resource_provider_); 775 ScopedResource::Create(resource_provider_);
905 // CopyTexImage2D fails when called on a texture having immutable storage. 776 // CopyTexImage2D fails when called on a texture having immutable storage.
(...skipping 24 matching lines...) Expand all
930 filter.get(), 801 filter.get(),
931 background_texture); 802 background_texture);
932 return background_with_filters; 803 return background_with_filters;
933 } 804 }
934 805
935 scoped_ptr<ScopedResource> 806 scoped_ptr<ScopedResource>
936 GLRenderer::ApplyInverseTransformForBackgroundFilters( 807 GLRenderer::ApplyInverseTransformForBackgroundFilters(
937 DrawingFrame* frame, 808 DrawingFrame* frame,
938 const RenderPassDrawQuad* quad, 809 const RenderPassDrawQuad* quad,
939 const gfx::Transform& contents_device_transform_inverse, 810 const gfx::Transform& contents_device_transform_inverse,
940 ScopedResource* device_background_texture,
941 skia::RefPtr<SkImage> filtered_device_background, 811 skia::RefPtr<SkImage> filtered_device_background,
942 const gfx::Rect& backdrop_bounding_rect) { 812 const gfx::Rect& backdrop_bounding_rect) {
943 // This method draws a background filter, which applies a filter to any pixels 813 // This method draws a background filter, which applies a filter to any pixels
944 // behind the quad and seen through its background. The algorithm works as 814 // behind the quad and seen through its background. The algorithm works as
945 // follows: 815 // follows:
946 // 1. Read the pixels in the bounding box into a buffer. 816 // 1. Read the pixels in the bounding box into a buffer.
947 // Moved to GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(). 817 // Moved to GLRenderer::GetBackdropBoundingBoxForRenderPassQuad().
948 // 2. Read the pixels in the bounding box into a buffer R. 818 // 2. Read the pixels in the bounding box into a buffer R.
949 // Moved to GLRenderer::GetBackdropTexture(). 819 // Moved to GLRenderer::GetBackdropTexture().
950 // 3. Apply the background filter to R, so that it is applied in the pixels' 820 // 3. Apply the background filter to R, so that it is applied in the pixels'
951 // coordinate space. Moved to GLRenderer::ApplyBackgroundFilters(). 821 // coordinate space. Moved to GLRenderer::ApplyBackgroundFilters().
952 // 4. Apply the quad's inverse transform to map the pixels in R into the 822 // 4. Apply the quad's inverse transform to map the pixels in R into the
953 // quad's content space. This implicitly clips R by the content bounds of the 823 // quad's content space. This implicitly clips R by the content bounds of the
954 // quad since the destination texture has bounds matching the quad's content. 824 // quad since the destination texture has bounds matching the quad's content.
955 // 5. Draw the background texture for the contents using the same transform as 825 // 5. Draw the background texture for the contents using the same transform as
956 // used to draw the contents itself. This is done without blending to replace 826 // used to draw the contents itself. This is done without blending to replace
957 // the current background pixels with the new filtered background. 827 // the current background pixels with the new filtered background.
958 // 6. Draw the contents of the quad over drop of the new background with 828 // 6. Draw the contents of the quad over drop of the new background with
959 // blending, as per usual. The filtered background pixels will show through 829 // blending, as per usual. The filtered background pixels will show through
960 // any non-opaque pixels in this draws. 830 // any non-opaque pixels in this draws.
961 // 831 //
962 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. 832 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5.
963 833
964 // TODO(danakj): When this algorithm changes, update 834 // TODO(danakj): When this algorithm changes, update
965 // LayerTreeHost::PrioritizeTextures() accordingly. 835 // LayerTreeHost::PrioritizeTextures() accordingly.
966 836
967 DCHECK(device_background_texture); 837 DCHECK(filtered_device_background);
968 838
969 int filtered_device_background_texture_id = 0; 839 GrTexture* texture = filtered_device_background->getTexture();
970 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
971 if (filtered_device_background) {
972 GrTexture* texture = filtered_device_background->getTexture();
973 filtered_device_background_texture_id = texture->getTextureHandle();
974 } else {
975 lock.reset(new ResourceProvider::ScopedReadLockGL(
976 resource_provider_, device_background_texture->id()));
977 filtered_device_background_texture_id = lock->texture_id();
978 }
979 840
980 scoped_ptr<ScopedResource> background_texture = 841 scoped_ptr<ScopedResource> background_texture =
981 ScopedResource::Create(resource_provider_); 842 ScopedResource::Create(resource_provider_);
982 background_texture->Allocate( 843 background_texture->Allocate(
983 quad->rect.size(), 844 quad->rect.size(),
984 ResourceProvider::TextureHintImmutableFramebuffer, 845 ResourceProvider::TextureHintImmutableFramebuffer,
985 RGBA_8888); 846 RGBA_8888);
986 847
987 const RenderPass* target_render_pass = frame->current_render_pass; 848 const RenderPass* target_render_pass = frame->current_render_pass;
988 bool using_background_texture = 849 bool using_background_texture =
(...skipping 13 matching lines...) Expand all
1002 gl_->Clear(GL_COLOR_BUFFER_BIT); 863 gl_->Clear(GL_COLOR_BUFFER_BIT);
1003 #endif 864 #endif
1004 865
1005 // The background_texture is oriented the same as the frame buffer. 866 // The background_texture is oriented the same as the frame buffer.
1006 // The transform we are copying with has a vertical flip, as well as 867 // The transform we are copying with has a vertical flip, as well as
1007 // the |device_to_framebuffer_transform|, which cancel each other out. So do 868 // the |device_to_framebuffer_transform|, which cancel each other out. So do
1008 // not flip the contents in the shader to maintain orientation. 869 // not flip the contents in the shader to maintain orientation.
1009 bool flip_vertically = false; 870 bool flip_vertically = false;
1010 871
1011 CopyTextureToFramebuffer(frame, 872 CopyTextureToFramebuffer(frame,
1012 filtered_device_background_texture_id, 873 texture->getTextureHandle(),
1013 backdrop_bounding_rect, 874 backdrop_bounding_rect,
1014 device_to_framebuffer_transform, 875 device_to_framebuffer_transform,
1015 flip_vertically); 876 flip_vertically);
1016 } 877 }
1017 878
1018 UseRenderPass(frame, target_render_pass); 879 UseRenderPass(frame, target_render_pass);
1019 880
1020 if (!using_background_texture) 881 if (!using_background_texture)
1021 return nullptr; 882 return nullptr;
1022 return background_texture.Pass(); 883 return background_texture.Pass();
1023 } 884 }
1024 885
1025 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 886 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
1026 const RenderPassDrawQuad* quad) { 887 const RenderPassDrawQuad* quad) {
1027 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; 888 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
1028 SetBlendEnabled(quad->ShouldDrawWithBlending() || 889 SetBlendEnabled(
1029 (!IsDefaultBlendMode(blend_mode) && 890 CanApplyBlendModeUsingBlendFunc(blend_mode) &&
1030 CanApplyBlendModeUsingBlendFunc(blend_mode))); 891 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode)));
1031 892
1032 ScopedResource* contents_texture = 893 ScopedResource* contents_texture =
1033 render_pass_textures_.get(quad->render_pass_id); 894 render_pass_textures_.get(quad->render_pass_id);
1034 if (!contents_texture || !contents_texture->id()) 895 if (!contents_texture || !contents_texture->id())
1035 return; 896 return;
1036 897
1037 gfx::Transform quad_rect_matrix; 898 gfx::Transform quad_rect_matrix;
1038 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 899 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
1039 gfx::Transform contents_device_transform = 900 gfx::Transform contents_device_transform =
1040 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 901 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
1041 contents_device_transform.FlattenTo2d(); 902 contents_device_transform.FlattenTo2d();
1042 903
1043 // Can only draw surface if device matrix is invertible. 904 // Can only draw surface if device matrix is invertible.
1044 gfx::Transform contents_device_transform_inverse( 905 gfx::Transform contents_device_transform_inverse(
1045 gfx::Transform::kSkipInitialization); 906 gfx::Transform::kSkipInitialization);
1046 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) 907 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse))
1047 return; 908 return;
1048 909
910 bool clipped = false;
911 gfx::QuadF device_quad = MathUtil::MapQuad(
912 contents_device_transform, SharedGeometryQuad(), &clipped);
913 // Use anti-aliasing programs only when necessary.
914 bool use_aa =
915 !clipped && (!device_quad.IsRectilinear() ||
916 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
917 kAntiAliasingEpsilon));
918
1049 bool need_background_texture = !CanApplyBlendModeUsingBlendFunc(blend_mode) || 919 bool need_background_texture = !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
1050 ShouldApplyBackgroundFilters(frame, quad); 920 ShouldApplyBackgroundFilters(frame, quad);
1051 921
1052 scoped_ptr<ScopedResource> background_texture; 922 scoped_ptr<ScopedResource> background_texture;
923 skia::RefPtr<SkImage> background_image;
924 gfx::Rect background_rect;
1053 if (need_background_texture) { 925 if (need_background_texture) {
926 // Compute a bounding box around the pixels that will be visible through
927 // the quad.
928 background_rect = GetBackdropBoundingBoxForRenderPassQuad(
929 frame, quad, contents_device_transform, use_aa);
930 }
931
932 if (!background_rect.IsEmpty()) {
1054 // The pixels from the filtered background should completely replace the 933 // The pixels from the filtered background should completely replace the
1055 // current pixel values. 934 // current pixel values.
1056 bool disable_blending = blend_enabled(); 935 bool disable_blending = blend_enabled();
1057 if (disable_blending) 936 if (disable_blending)
1058 SetBlendEnabled(false); 937 SetBlendEnabled(false);
1059 938
1060 // Compute a bounding box around the pixels that will be visible through
1061 // the quad.
1062 gfx::Rect backdrop_rect = GetBackdropBoundingBoxForRenderPassQuad(
1063 frame, quad, contents_device_transform);
1064
1065 // Read the pixels in the bounding box into a buffer R. 939 // Read the pixels in the bounding box into a buffer R.
1066 scoped_ptr<ScopedResource> scoped_background_texture = 940 scoped_ptr<ScopedResource> scoped_background_texture =
1067 GetBackdropTexture(backdrop_rect); 941 GetBackdropTexture(background_rect);
1068 942
1069 skia::RefPtr<SkImage> background_with_filters; 943 skia::RefPtr<SkImage> background_with_filters;
1070 if (ShouldApplyBackgroundFilters(frame, quad)) { 944 if (ShouldApplyBackgroundFilters(frame, quad) &&
945 scoped_background_texture) {
1071 // Apply the background filters to R, so that it is applied in the pixels' 946 // Apply the background filters to R, so that it is applied in the pixels'
1072 // coordinate space. 947 // coordinate space.
1073 background_with_filters = 948 background_with_filters =
1074 ApplyBackgroundFilters(frame, quad, scoped_background_texture.get()); 949 ApplyBackgroundFilters(frame, quad, scoped_background_texture.get());
1075 } 950 }
1076 // Apply the quad's inverse transform to map the pixels in R into the 951
1077 // quad's content space. This implicitly clips R by the content bounds of 952 if (CanApplyBlendModeUsingBlendFunc(blend_mode) &&
1078 // the quad since the destination texture has bounds matching the quad's 953 background_with_filters) {
1079 // content. 954 // The background with filters will be copied to the frame buffer.
1080 background_texture = ApplyInverseTransformForBackgroundFilters( 955 // Apply the quad's inverse transform to map the pixels in R into the
1081 frame, 956 // quad's content space. This implicitly clips R by the content bounds of
1082 quad, 957 // the quad since the destination texture has bounds matching the quad's
1083 contents_device_transform_inverse, 958 // content.
1084 scoped_background_texture.get(), 959 background_texture = ApplyInverseTransformForBackgroundFilters(
1085 background_with_filters, 960 frame,
1086 backdrop_rect); 961 quad,
962 contents_device_transform_inverse,
963 background_with_filters,
964 background_rect);
965 } else if (!CanApplyBlendModeUsingBlendFunc(blend_mode)) {
966 if (background_with_filters) {
967 // The background with filters will be used as backdrop for blending.
968 background_image = background_with_filters;
969 } else {
970 background_texture = scoped_background_texture.Pass();
971 }
972 }
1087 973
1088 if (disable_blending) 974 if (disable_blending)
1089 SetBlendEnabled(true); 975 SetBlendEnabled(true);
1090 } 976 }
1091 977
1092 // TODO(senorblanco): Cache this value so that we don't have to do it for both 978 // TODO(senorblanco): Cache this value so that we don't have to do it for both
1093 // the surface and its replica. Apply filters to the contents texture. 979 // the surface and its replica. Apply filters to the contents texture.
1094 skia::RefPtr<SkImage> filter_bitmap; 980 skia::RefPtr<SkImage> filter_bitmap;
1095 SkScalar color_matrix[20]; 981 SkScalar color_matrix[20];
1096 bool use_color_matrix = false; 982 bool use_color_matrix = false;
(...skipping 18 matching lines...) Expand all
1115 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), 1001 ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
1116 resource_provider_, 1002 resource_provider_,
1117 quad->rect.origin(), 1003 quad->rect.origin(),
1118 quad->filters_scale, 1004 quad->filters_scale,
1119 filter.get(), 1005 filter.get(),
1120 contents_texture); 1006 contents_texture);
1121 } 1007 }
1122 } 1008 }
1123 } 1009 }
1124 1010
1125 if (background_texture) { 1011 if (background_texture && ShouldApplyBackgroundFilters(frame, quad)) {
1126 if (CanApplyBlendModeUsingBlendFunc(blend_mode)) { 1012 // Draw the background texture if it has some filters applied.
1127 // Draw the background texture if it has some filters applied. 1013 DCHECK(CanApplyBlendModeUsingBlendFunc(blend_mode));
1128 DCHECK(ShouldApplyBackgroundFilters(frame, quad)); 1014 DCHECK(background_texture->size() == quad->rect.size());
1129 DCHECK(background_texture->size() == quad->rect.size()); 1015 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1130 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1016 background_texture->id());
1131 background_texture->id());
1132 1017
1133 // The background_texture is oriented the same as the frame buffer. The 1018 // The background_texture is oriented the same as the frame buffer. The
1134 // transform we are copying with has a vertical flip, so flip the contents 1019 // transform we are copying with has a vertical flip, so flip the contents
1135 // in the shader to maintain orientation 1020 // in the shader to maintain orientation
1136 bool flip_vertically = true; 1021 bool flip_vertically = true;
1137 1022
1138 CopyTextureToFramebuffer(frame, 1023 CopyTextureToFramebuffer(frame,
1139 lock.texture_id(), 1024 lock.texture_id(),
1140 quad->rect, 1025 quad->rect,
1141 quad->quadTransform(), 1026 quad->quadTransform(),
1142 flip_vertically); 1027 flip_vertically);
1143 } else {
1144 // If blending is applied using shaders, the background texture with
1145 // filters will be used as backdrop for blending operation, so we don't
1146 // need to copy it to the frame buffer.
1147 filter_bitmap =
1148 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame),
1149 resource_provider_,
1150 filter_bitmap,
1151 contents_texture,
1152 background_texture.get(),
1153 quad->shared_quad_state->blend_mode);
1154 }
1155 } 1028 }
1156 1029
1157 bool clipped = false;
1158 gfx::QuadF device_quad = MathUtil::MapQuad(
1159 contents_device_transform, SharedGeometryQuad(), &clipped);
1160 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox())); 1030 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox()));
1161 LayerQuad device_layer_edges(device_quad); 1031 LayerQuad device_layer_edges(device_quad);
1162
1163 // Use anti-aliasing programs only when necessary.
1164 bool use_aa =
1165 !clipped && (!device_quad.IsRectilinear() ||
1166 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
1167 kAntiAliasingEpsilon));
1168 if (use_aa) { 1032 if (use_aa) {
1169 device_layer_bounds.InflateAntiAliasingDistance(); 1033 device_layer_bounds.InflateAntiAliasingDistance();
1170 device_layer_edges.InflateAntiAliasingDistance(); 1034 device_layer_edges.InflateAntiAliasingDistance();
1171 } 1035 }
1172 1036
1173 scoped_ptr<ResourceProvider::ScopedReadLockGL> mask_resource_lock; 1037 scoped_ptr<ResourceProvider::ScopedReadLockGL> mask_resource_lock;
1174 unsigned mask_texture_id = 0; 1038 unsigned mask_texture_id = 0;
1175 if (quad->mask_resource_id) { 1039 if (quad->mask_resource_id) {
1176 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( 1040 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL(
1177 resource_provider_, quad->mask_resource_id)); 1041 resource_provider_, quad->mask_resource_id));
(...skipping 29 matching lines...) Expand all
1207 int shader_edge_location = -1; 1071 int shader_edge_location = -1;
1208 int shader_viewport_location = -1; 1072 int shader_viewport_location = -1;
1209 int shader_mask_sampler_location = -1; 1073 int shader_mask_sampler_location = -1;
1210 int shader_mask_tex_coord_scale_location = -1; 1074 int shader_mask_tex_coord_scale_location = -1;
1211 int shader_mask_tex_coord_offset_location = -1; 1075 int shader_mask_tex_coord_offset_location = -1;
1212 int shader_matrix_location = -1; 1076 int shader_matrix_location = -1;
1213 int shader_alpha_location = -1; 1077 int shader_alpha_location = -1;
1214 int shader_color_matrix_location = -1; 1078 int shader_color_matrix_location = -1;
1215 int shader_color_offset_location = -1; 1079 int shader_color_offset_location = -1;
1216 int shader_tex_transform_location = -1; 1080 int shader_tex_transform_location = -1;
1081 int shader_backdrop_location = -1;
1082 int shader_backdrop_rect_location = -1;
1083
1084 SkXfermode::Mode shader_blend_mode =
1085 ((background_texture || background_image) &&
1086 !CanApplyBlendModeUsingBlendFunc(blend_mode))
1087 ? blend_mode
1088 : kDefaultBlendMode;
1217 1089
1218 if (use_aa && mask_texture_id && !use_color_matrix) { 1090 if (use_aa && mask_texture_id && !use_color_matrix) {
1219 const RenderPassMaskProgramAA* program = 1091 const RenderPassMaskProgramAA* program =
1220 GetRenderPassMaskProgramAA(tex_coord_precision); 1092 GetRenderPassMaskProgramAA(tex_coord_precision, shader_blend_mode);
1221 SetUseProgram(program->program()); 1093 SetUseProgram(program->program());
1222 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1094 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1223 1095
1224 shader_quad_location = program->vertex_shader().quad_location(); 1096 shader_quad_location = program->vertex_shader().quad_location();
1225 shader_edge_location = program->vertex_shader().edge_location(); 1097 shader_edge_location = program->vertex_shader().edge_location();
1226 shader_viewport_location = program->vertex_shader().viewport_location(); 1098 shader_viewport_location = program->vertex_shader().viewport_location();
1227 shader_mask_sampler_location = 1099 shader_mask_sampler_location =
1228 program->fragment_shader().mask_sampler_location(); 1100 program->fragment_shader().mask_sampler_location();
1229 shader_mask_tex_coord_scale_location = 1101 shader_mask_tex_coord_scale_location =
1230 program->fragment_shader().mask_tex_coord_scale_location(); 1102 program->fragment_shader().mask_tex_coord_scale_location();
1231 shader_mask_tex_coord_offset_location = 1103 shader_mask_tex_coord_offset_location =
1232 program->fragment_shader().mask_tex_coord_offset_location(); 1104 program->fragment_shader().mask_tex_coord_offset_location();
1233 shader_matrix_location = program->vertex_shader().matrix_location(); 1105 shader_matrix_location = program->vertex_shader().matrix_location();
1234 shader_alpha_location = program->fragment_shader().alpha_location(); 1106 shader_alpha_location = program->fragment_shader().alpha_location();
1235 shader_tex_transform_location = 1107 shader_tex_transform_location =
1236 program->vertex_shader().tex_transform_location(); 1108 program->vertex_shader().tex_transform_location();
1109 shader_backdrop_location = program->fragment_shader().backdrop_location();
1110 shader_backdrop_rect_location =
1111 program->fragment_shader().backdrop_rect_location();
1237 } else if (!use_aa && mask_texture_id && !use_color_matrix) { 1112 } else if (!use_aa && mask_texture_id && !use_color_matrix) {
1238 const RenderPassMaskProgram* program = 1113 const RenderPassMaskProgram* program =
1239 GetRenderPassMaskProgram(tex_coord_precision); 1114 GetRenderPassMaskProgram(tex_coord_precision, shader_blend_mode);
1240 SetUseProgram(program->program()); 1115 SetUseProgram(program->program());
1241 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1116 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1242 1117
1243 shader_mask_sampler_location = 1118 shader_mask_sampler_location =
1244 program->fragment_shader().mask_sampler_location(); 1119 program->fragment_shader().mask_sampler_location();
1245 shader_mask_tex_coord_scale_location = 1120 shader_mask_tex_coord_scale_location =
1246 program->fragment_shader().mask_tex_coord_scale_location(); 1121 program->fragment_shader().mask_tex_coord_scale_location();
1247 shader_mask_tex_coord_offset_location = 1122 shader_mask_tex_coord_offset_location =
1248 program->fragment_shader().mask_tex_coord_offset_location(); 1123 program->fragment_shader().mask_tex_coord_offset_location();
1249 shader_matrix_location = program->vertex_shader().matrix_location(); 1124 shader_matrix_location = program->vertex_shader().matrix_location();
1250 shader_alpha_location = program->fragment_shader().alpha_location(); 1125 shader_alpha_location = program->fragment_shader().alpha_location();
1251 shader_tex_transform_location = 1126 shader_tex_transform_location =
1252 program->vertex_shader().tex_transform_location(); 1127 program->vertex_shader().tex_transform_location();
1128 shader_backdrop_location = program->fragment_shader().backdrop_location();
1129 shader_backdrop_rect_location =
1130 program->fragment_shader().backdrop_rect_location();
1253 } else if (use_aa && !mask_texture_id && !use_color_matrix) { 1131 } else if (use_aa && !mask_texture_id && !use_color_matrix) {
1254 const RenderPassProgramAA* program = 1132 const RenderPassProgramAA* program =
1255 GetRenderPassProgramAA(tex_coord_precision); 1133 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode);
1256 SetUseProgram(program->program()); 1134 SetUseProgram(program->program());
1257 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1135 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1258 1136
1259 shader_quad_location = program->vertex_shader().quad_location(); 1137 shader_quad_location = program->vertex_shader().quad_location();
1260 shader_edge_location = program->vertex_shader().edge_location(); 1138 shader_edge_location = program->vertex_shader().edge_location();
1261 shader_viewport_location = program->vertex_shader().viewport_location(); 1139 shader_viewport_location = program->vertex_shader().viewport_location();
1262 shader_matrix_location = program->vertex_shader().matrix_location(); 1140 shader_matrix_location = program->vertex_shader().matrix_location();
1263 shader_alpha_location = program->fragment_shader().alpha_location(); 1141 shader_alpha_location = program->fragment_shader().alpha_location();
1264 shader_tex_transform_location = 1142 shader_tex_transform_location =
1265 program->vertex_shader().tex_transform_location(); 1143 program->vertex_shader().tex_transform_location();
1144 shader_backdrop_location = program->fragment_shader().backdrop_location();
1145 shader_backdrop_rect_location =
1146 program->fragment_shader().backdrop_rect_location();
1266 } else if (use_aa && mask_texture_id && use_color_matrix) { 1147 } else if (use_aa && mask_texture_id && use_color_matrix) {
1267 const RenderPassMaskColorMatrixProgramAA* program = 1148 const RenderPassMaskColorMatrixProgramAA* program =
1268 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision); 1149 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision,
1150 shader_blend_mode);
1269 SetUseProgram(program->program()); 1151 SetUseProgram(program->program());
1270 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1152 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1271 1153
1272 shader_matrix_location = program->vertex_shader().matrix_location(); 1154 shader_matrix_location = program->vertex_shader().matrix_location();
1273 shader_quad_location = program->vertex_shader().quad_location(); 1155 shader_quad_location = program->vertex_shader().quad_location();
1274 shader_tex_transform_location = 1156 shader_tex_transform_location =
1275 program->vertex_shader().tex_transform_location(); 1157 program->vertex_shader().tex_transform_location();
1276 shader_edge_location = program->vertex_shader().edge_location(); 1158 shader_edge_location = program->vertex_shader().edge_location();
1277 shader_viewport_location = program->vertex_shader().viewport_location(); 1159 shader_viewport_location = program->vertex_shader().viewport_location();
1278 shader_alpha_location = program->fragment_shader().alpha_location(); 1160 shader_alpha_location = program->fragment_shader().alpha_location();
1279 shader_mask_sampler_location = 1161 shader_mask_sampler_location =
1280 program->fragment_shader().mask_sampler_location(); 1162 program->fragment_shader().mask_sampler_location();
1281 shader_mask_tex_coord_scale_location = 1163 shader_mask_tex_coord_scale_location =
1282 program->fragment_shader().mask_tex_coord_scale_location(); 1164 program->fragment_shader().mask_tex_coord_scale_location();
1283 shader_mask_tex_coord_offset_location = 1165 shader_mask_tex_coord_offset_location =
1284 program->fragment_shader().mask_tex_coord_offset_location(); 1166 program->fragment_shader().mask_tex_coord_offset_location();
1285 shader_color_matrix_location = 1167 shader_color_matrix_location =
1286 program->fragment_shader().color_matrix_location(); 1168 program->fragment_shader().color_matrix_location();
1287 shader_color_offset_location = 1169 shader_color_offset_location =
1288 program->fragment_shader().color_offset_location(); 1170 program->fragment_shader().color_offset_location();
1171 shader_backdrop_location = program->fragment_shader().backdrop_location();
1172 shader_backdrop_rect_location =
1173 program->fragment_shader().backdrop_rect_location();
1289 } else if (use_aa && !mask_texture_id && use_color_matrix) { 1174 } else if (use_aa && !mask_texture_id && use_color_matrix) {
1290 const RenderPassColorMatrixProgramAA* program = 1175 const RenderPassColorMatrixProgramAA* program =
1291 GetRenderPassColorMatrixProgramAA(tex_coord_precision); 1176 GetRenderPassColorMatrixProgramAA(tex_coord_precision,
1177 shader_blend_mode);
1292 SetUseProgram(program->program()); 1178 SetUseProgram(program->program());
1293 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1179 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1294 1180
1295 shader_matrix_location = program->vertex_shader().matrix_location(); 1181 shader_matrix_location = program->vertex_shader().matrix_location();
1296 shader_quad_location = program->vertex_shader().quad_location(); 1182 shader_quad_location = program->vertex_shader().quad_location();
1297 shader_tex_transform_location = 1183 shader_tex_transform_location =
1298 program->vertex_shader().tex_transform_location(); 1184 program->vertex_shader().tex_transform_location();
1299 shader_edge_location = program->vertex_shader().edge_location(); 1185 shader_edge_location = program->vertex_shader().edge_location();
1300 shader_viewport_location = program->vertex_shader().viewport_location(); 1186 shader_viewport_location = program->vertex_shader().viewport_location();
1301 shader_alpha_location = program->fragment_shader().alpha_location(); 1187 shader_alpha_location = program->fragment_shader().alpha_location();
1302 shader_color_matrix_location = 1188 shader_color_matrix_location =
1303 program->fragment_shader().color_matrix_location(); 1189 program->fragment_shader().color_matrix_location();
1304 shader_color_offset_location = 1190 shader_color_offset_location =
1305 program->fragment_shader().color_offset_location(); 1191 program->fragment_shader().color_offset_location();
1192 shader_backdrop_location = program->fragment_shader().backdrop_location();
1193 shader_backdrop_rect_location =
1194 program->fragment_shader().backdrop_rect_location();
1306 } else if (!use_aa && mask_texture_id && use_color_matrix) { 1195 } else if (!use_aa && mask_texture_id && use_color_matrix) {
1307 const RenderPassMaskColorMatrixProgram* program = 1196 const RenderPassMaskColorMatrixProgram* program =
1308 GetRenderPassMaskColorMatrixProgram(tex_coord_precision); 1197 GetRenderPassMaskColorMatrixProgram(tex_coord_precision,
1198 shader_blend_mode);
1309 SetUseProgram(program->program()); 1199 SetUseProgram(program->program());
1310 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1200 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1311 1201
1312 shader_matrix_location = program->vertex_shader().matrix_location(); 1202 shader_matrix_location = program->vertex_shader().matrix_location();
1313 shader_tex_transform_location = 1203 shader_tex_transform_location =
1314 program->vertex_shader().tex_transform_location(); 1204 program->vertex_shader().tex_transform_location();
1315 shader_mask_sampler_location = 1205 shader_mask_sampler_location =
1316 program->fragment_shader().mask_sampler_location(); 1206 program->fragment_shader().mask_sampler_location();
1317 shader_mask_tex_coord_scale_location = 1207 shader_mask_tex_coord_scale_location =
1318 program->fragment_shader().mask_tex_coord_scale_location(); 1208 program->fragment_shader().mask_tex_coord_scale_location();
1319 shader_mask_tex_coord_offset_location = 1209 shader_mask_tex_coord_offset_location =
1320 program->fragment_shader().mask_tex_coord_offset_location(); 1210 program->fragment_shader().mask_tex_coord_offset_location();
1321 shader_alpha_location = program->fragment_shader().alpha_location(); 1211 shader_alpha_location = program->fragment_shader().alpha_location();
1322 shader_color_matrix_location = 1212 shader_color_matrix_location =
1323 program->fragment_shader().color_matrix_location(); 1213 program->fragment_shader().color_matrix_location();
1324 shader_color_offset_location = 1214 shader_color_offset_location =
1325 program->fragment_shader().color_offset_location(); 1215 program->fragment_shader().color_offset_location();
1216 shader_backdrop_location = program->fragment_shader().backdrop_location();
1217 shader_backdrop_rect_location =
1218 program->fragment_shader().backdrop_rect_location();
1326 } else if (!use_aa && !mask_texture_id && use_color_matrix) { 1219 } else if (!use_aa && !mask_texture_id && use_color_matrix) {
1327 const RenderPassColorMatrixProgram* program = 1220 const RenderPassColorMatrixProgram* program =
1328 GetRenderPassColorMatrixProgram(tex_coord_precision); 1221 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode);
1329 SetUseProgram(program->program()); 1222 SetUseProgram(program->program());
1330 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1223 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1331 1224
1332 shader_matrix_location = program->vertex_shader().matrix_location(); 1225 shader_matrix_location = program->vertex_shader().matrix_location();
1333 shader_tex_transform_location = 1226 shader_tex_transform_location =
1334 program->vertex_shader().tex_transform_location(); 1227 program->vertex_shader().tex_transform_location();
1335 shader_alpha_location = program->fragment_shader().alpha_location(); 1228 shader_alpha_location = program->fragment_shader().alpha_location();
1336 shader_color_matrix_location = 1229 shader_color_matrix_location =
1337 program->fragment_shader().color_matrix_location(); 1230 program->fragment_shader().color_matrix_location();
1338 shader_color_offset_location = 1231 shader_color_offset_location =
1339 program->fragment_shader().color_offset_location(); 1232 program->fragment_shader().color_offset_location();
1233 shader_backdrop_location = program->fragment_shader().backdrop_location();
1234 shader_backdrop_rect_location =
1235 program->fragment_shader().backdrop_rect_location();
1340 } else { 1236 } else {
1341 const RenderPassProgram* program = 1237 const RenderPassProgram* program =
1342 GetRenderPassProgram(tex_coord_precision); 1238 GetRenderPassProgram(tex_coord_precision, shader_blend_mode);
1343 SetUseProgram(program->program()); 1239 SetUseProgram(program->program());
1344 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1240 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1345 1241
1346 shader_matrix_location = program->vertex_shader().matrix_location(); 1242 shader_matrix_location = program->vertex_shader().matrix_location();
1347 shader_alpha_location = program->fragment_shader().alpha_location(); 1243 shader_alpha_location = program->fragment_shader().alpha_location();
1348 shader_tex_transform_location = 1244 shader_tex_transform_location =
1349 program->vertex_shader().tex_transform_location(); 1245 program->vertex_shader().tex_transform_location();
1246 shader_backdrop_location = program->fragment_shader().backdrop_location();
1247 shader_backdrop_rect_location =
1248 program->fragment_shader().backdrop_rect_location();
1350 } 1249 }
1351 float tex_scale_x = 1250 float tex_scale_x =
1352 quad->rect.width() / static_cast<float>(contents_texture->size().width()); 1251 quad->rect.width() / static_cast<float>(contents_texture->size().width());
1353 float tex_scale_y = quad->rect.height() / 1252 float tex_scale_y = quad->rect.height() /
1354 static_cast<float>(contents_texture->size().height()); 1253 static_cast<float>(contents_texture->size().height());
1355 DCHECK_LE(tex_scale_x, 1.0f); 1254 DCHECK_LE(tex_scale_x, 1.0f);
1356 DCHECK_LE(tex_scale_y, 1.0f); 1255 DCHECK_LE(tex_scale_y, 1.0f);
1357 1256
1358 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); 1257 DCHECK(shader_tex_transform_location != -1 || IsContextLost());
1359 // Flip the content vertically in the shader, as the RenderPass input 1258 // Flip the content vertically in the shader, as the RenderPass input
1360 // texture is already oriented the same way as the framebuffer, but the 1259 // texture is already oriented the same way as the framebuffer, but the
1361 // projection transform does a flip. 1260 // projection transform does a flip.
1362 GLC(gl_, 1261 GLC(gl_,
1363 gl_->Uniform4f(shader_tex_transform_location, 1262 gl_->Uniform4f(shader_tex_transform_location,
1364 0.0f, 1263 0.0f,
1365 tex_scale_y, 1264 tex_scale_y,
1366 tex_scale_x, 1265 tex_scale_x,
1367 -tex_scale_y)); 1266 -tex_scale_y));
1368 1267
1268 GLint last_texture_unit = 0;
1369 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; 1269 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock;
1370 if (shader_mask_sampler_location != -1) { 1270 if (shader_mask_sampler_location != -1) {
1371 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); 1271 DCHECK_NE(shader_mask_tex_coord_scale_location, 1);
1372 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); 1272 DCHECK_NE(shader_mask_tex_coord_offset_location, 1);
1373 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); 1273 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1));
1374 1274
1375 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x; 1275 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x;
1376 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y; 1276 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y;
1377 1277
1378 // Mask textures are oriented vertically flipped relative to the framebuffer 1278 // Mask textures are oriented vertically flipped relative to the framebuffer
1379 // and the RenderPass contents texture, so we flip the tex coords from the 1279 // and the RenderPass contents texture, so we flip the tex coords from the
1380 // RenderPass texture to find the mask texture coords. 1280 // RenderPass texture to find the mask texture coords.
1381 GLC(gl_, 1281 GLC(gl_,
1382 gl_->Uniform2f(shader_mask_tex_coord_offset_location, 1282 gl_->Uniform2f(shader_mask_tex_coord_offset_location,
1383 quad->mask_uv_rect.x(), 1283 quad->mask_uv_rect.x(),
1384 quad->mask_uv_rect.y() + quad->mask_uv_rect.height())); 1284 quad->mask_uv_rect.y() + quad->mask_uv_rect.height()));
1385 GLC(gl_, 1285 GLC(gl_,
1386 gl_->Uniform2f(shader_mask_tex_coord_scale_location, 1286 gl_->Uniform2f(shader_mask_tex_coord_scale_location,
1387 mask_tex_scale_x, 1287 mask_tex_scale_x,
1388 -mask_tex_scale_y)); 1288 -mask_tex_scale_y));
1389 shader_mask_sampler_lock = make_scoped_ptr( 1289 shader_mask_sampler_lock = make_scoped_ptr(
1390 new ResourceProvider::ScopedSamplerGL(resource_provider_, 1290 new ResourceProvider::ScopedSamplerGL(resource_provider_,
1391 quad->mask_resource_id, 1291 quad->mask_resource_id,
1392 GL_TEXTURE1, 1292 GL_TEXTURE1,
1393 GL_LINEAR)); 1293 GL_LINEAR));
1394 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1294 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1395 shader_mask_sampler_lock->target()); 1295 shader_mask_sampler_lock->target());
1296 last_texture_unit = 1;
1396 } 1297 }
1397 1298
1398 if (shader_edge_location != -1) { 1299 if (shader_edge_location != -1) {
1399 float edge[24]; 1300 float edge[24];
1400 device_layer_edges.ToFloatArray(edge); 1301 device_layer_edges.ToFloatArray(edge);
1401 device_layer_bounds.ToFloatArray(&edge[12]); 1302 device_layer_bounds.ToFloatArray(&edge[12]);
1402 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge)); 1303 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge));
1403 } 1304 }
1404 1305
1405 if (shader_viewport_location != -1) { 1306 if (shader_viewport_location != -1) {
(...skipping 15 matching lines...) Expand all
1421 } 1322 }
1422 static const float kScale = 1.0f / 255.0f; 1323 static const float kScale = 1.0f / 255.0f;
1423 if (shader_color_offset_location != -1) { 1324 if (shader_color_offset_location != -1) {
1424 float offset[4]; 1325 float offset[4];
1425 for (int i = 0; i < 4; ++i) 1326 for (int i = 0; i < 4; ++i)
1426 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; 1327 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale;
1427 1328
1428 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset)); 1329 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset));
1429 } 1330 }
1430 1331
1332 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock;
1333 if (shader_backdrop_location != -1) {
1334 DCHECK(background_texture || background_image);
1335 DCHECK_NE(shader_backdrop_location, 0);
1336 DCHECK_NE(shader_backdrop_rect_location, 0);
1337
1338 GLC(gl_, gl_->Uniform1i(shader_backdrop_location, ++last_texture_unit));
1339
1340 GLC(gl_,
1341 gl_->Uniform4f(shader_backdrop_rect_location,
1342 background_rect.x(),
1343 background_rect.y(),
1344 background_rect.width(),
1345 background_rect.height()));
1346
1347 if (background_image) {
1348 GrTexture* texture = background_image->getTexture();
1349 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit));
1350 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
1351 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
1352 } else {
1353 shader_background_sampler_lock = make_scoped_ptr(
1354 new ResourceProvider::ScopedSamplerGL(resource_provider_,
1355 background_texture->id(),
1356 GL_TEXTURE0 + last_texture_unit,
1357 GL_LINEAR));
1358 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1359 shader_background_sampler_lock->target());
1360 }
1361 }
1362
1431 // Map device space quad to surface space. contents_device_transform has no 3d 1363 // Map device space quad to surface space. contents_device_transform has no 3d
1432 // component since it was flattened, so we don't need to project. 1364 // component since it was flattened, so we don't need to project.
1433 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse, 1365 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse,
1434 device_layer_edges.ToQuadF(), 1366 device_layer_edges.ToQuadF(),
1435 &clipped); 1367 &clipped);
1436 1368
1437 SetShaderOpacity(quad->opacity(), shader_alpha_location); 1369 SetShaderOpacity(quad->opacity(), shader_alpha_location);
1438 SetShaderQuadF(surface_quad, shader_quad_location); 1370 SetShaderQuadF(surface_quad, shader_quad_location);
1439 DrawQuadGeometry( 1371 DrawQuadGeometry(
1440 frame, quad->quadTransform(), quad->rect, shader_matrix_location); 1372 frame, quad->quadTransform(), quad->rect, shader_matrix_location);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 } 2288 }
2357 2289
2358 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, 2290 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
2359 int texture_id, 2291 int texture_id,
2360 const gfx::Rect& rect, 2292 const gfx::Rect& rect,
2361 const gfx::Transform& draw_matrix, 2293 const gfx::Transform& draw_matrix,
2362 bool flip_vertically) { 2294 bool flip_vertically) {
2363 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2295 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2364 gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right()); 2296 gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right());
2365 2297
2366 const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision); 2298 const RenderPassProgram* program =
2299 GetRenderPassProgram(tex_coord_precision, kDefaultBlendMode);
2367 SetUseProgram(program->program()); 2300 SetUseProgram(program->program());
2368 2301
2369 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2302 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
2370 2303
2371 if (flip_vertically) { 2304 if (flip_vertically) {
2372 GLC(gl_, 2305 GLC(gl_,
2373 gl_->Uniform4f(program->vertex_shader().tex_transform_location(), 2306 gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
2374 0.f, 2307 0.f,
2375 1.f, 2308 1.f,
2376 1.f, 2309 1.f,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 if (!solid_color_program_aa_.initialized()) { 2768 if (!solid_color_program_aa_.initialized()) {
2836 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); 2769 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize");
2837 solid_color_program_aa_.Initialize(output_surface_->context_provider(), 2770 solid_color_program_aa_.Initialize(output_surface_->context_provider(),
2838 TexCoordPrecisionNA, 2771 TexCoordPrecisionNA,
2839 SamplerTypeNA); 2772 SamplerTypeNA);
2840 } 2773 }
2841 return &solid_color_program_aa_; 2774 return &solid_color_program_aa_;
2842 } 2775 }
2843 2776
2844 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( 2777 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram(
2845 TexCoordPrecision precision) { 2778 TexCoordPrecision precision,
2779 SkXfermode::Mode blend_mode) {
2846 DCHECK_GE(precision, 0); 2780 DCHECK_GE(precision, 0);
2847 DCHECK_LT(precision, NumTexCoordPrecisions); 2781 DCHECK_LT(precision, NumTexCoordPrecisions);
2848 RenderPassProgram* program = &render_pass_program_[precision]; 2782 int bm = index_for_blend_mode(blend_mode);
2783 RenderPassProgram* program = &render_pass_program_[precision][bm];
2849 if (!program->initialized()) { 2784 if (!program->initialized()) {
2850 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); 2785 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize");
2851 program->Initialize( 2786 program->Initialize(output_surface_->context_provider(),
2852 output_surface_->context_provider(), precision, SamplerType2D); 2787 precision,
2788 SamplerType2D,
2789 blend_mode);
2853 } 2790 }
2854 return program; 2791 return program;
2855 } 2792 }
2856 2793
2857 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( 2794 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
2858 TexCoordPrecision precision) { 2795 TexCoordPrecision precision,
2796 SkXfermode::Mode blend_mode) {
2859 DCHECK_GE(precision, 0); 2797 DCHECK_GE(precision, 0);
2860 DCHECK_LT(precision, NumTexCoordPrecisions); 2798 DCHECK_LT(precision, NumTexCoordPrecisions);
2861 RenderPassProgramAA* program = &render_pass_program_aa_[precision]; 2799 int bm = index_for_blend_mode(blend_mode);
2800 RenderPassProgramAA* program = &render_pass_program_aa_[precision][bm];
2862 if (!program->initialized()) { 2801 if (!program->initialized()) {
2863 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); 2802 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize");
2864 program->Initialize( 2803 program->Initialize(output_surface_->context_provider(),
2865 output_surface_->context_provider(), precision, SamplerType2D); 2804 precision,
2805 SamplerType2D,
2806 blend_mode);
2866 } 2807 }
2867 return program; 2808 return program;
2868 } 2809 }
2869 2810
2870 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( 2811 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
2871 TexCoordPrecision precision) { 2812 TexCoordPrecision precision,
2813 SkXfermode::Mode blend_mode) {
2872 DCHECK_GE(precision, 0); 2814 DCHECK_GE(precision, 0);
2873 DCHECK_LT(precision, NumTexCoordPrecisions); 2815 DCHECK_LT(precision, NumTexCoordPrecisions);
2874 RenderPassMaskProgram* program = &render_pass_mask_program_[precision]; 2816 int bm = index_for_blend_mode(blend_mode);
2817 RenderPassMaskProgram* program = &render_pass_mask_program_[precision][bm];
2875 if (!program->initialized()) { 2818 if (!program->initialized()) {
2876 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); 2819 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize");
2877 program->Initialize( 2820 program->Initialize(output_surface_->context_provider(),
2878 output_surface_->context_provider(), precision, SamplerType2D); 2821 precision,
2822 SamplerType2D,
2823 blend_mode);
2879 } 2824 }
2880 return program; 2825 return program;
2881 } 2826 }
2882 2827
2883 const GLRenderer::RenderPassMaskProgramAA* 2828 const GLRenderer::RenderPassMaskProgramAA*
2884 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { 2829 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision,
2830 SkXfermode::Mode blend_mode) {
2885 DCHECK_GE(precision, 0); 2831 DCHECK_GE(precision, 0);
2886 DCHECK_LT(precision, NumTexCoordPrecisions); 2832 DCHECK_LT(precision, NumTexCoordPrecisions);
2887 RenderPassMaskProgramAA* program = &render_pass_mask_program_aa_[precision]; 2833 int bm = index_for_blend_mode(blend_mode);
2834 RenderPassMaskProgramAA* program =
2835 &render_pass_mask_program_aa_[precision][bm];
2888 if (!program->initialized()) { 2836 if (!program->initialized()) {
2889 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); 2837 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize");
2890 program->Initialize( 2838 program->Initialize(output_surface_->context_provider(),
2891 output_surface_->context_provider(), precision, SamplerType2D); 2839 precision,
2840 SamplerType2D,
2841 blend_mode);
2892 } 2842 }
2893 return program; 2843 return program;
2894 } 2844 }
2895 2845
2896 const GLRenderer::RenderPassColorMatrixProgram* 2846 const GLRenderer::RenderPassColorMatrixProgram*
2897 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { 2847 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision,
2848 SkXfermode::Mode blend_mode) {
2898 DCHECK_GE(precision, 0); 2849 DCHECK_GE(precision, 0);
2899 DCHECK_LT(precision, NumTexCoordPrecisions); 2850 DCHECK_LT(precision, NumTexCoordPrecisions);
2851 int bm = index_for_blend_mode(blend_mode);
2900 RenderPassColorMatrixProgram* program = 2852 RenderPassColorMatrixProgram* program =
2901 &render_pass_color_matrix_program_[precision]; 2853 &render_pass_color_matrix_program_[precision][bm];
2902 if (!program->initialized()) { 2854 if (!program->initialized()) {
2903 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); 2855 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize");
2904 program->Initialize( 2856 program->Initialize(output_surface_->context_provider(),
2905 output_surface_->context_provider(), precision, SamplerType2D); 2857 precision,
2858 SamplerType2D,
2859 blend_mode);
2906 } 2860 }
2907 return program; 2861 return program;
2908 } 2862 }
2909 2863
2910 const GLRenderer::RenderPassColorMatrixProgramAA* 2864 const GLRenderer::RenderPassColorMatrixProgramAA*
2911 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { 2865 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision,
2866 SkXfermode::Mode blend_mode) {
2912 DCHECK_GE(precision, 0); 2867 DCHECK_GE(precision, 0);
2913 DCHECK_LT(precision, NumTexCoordPrecisions); 2868 DCHECK_LT(precision, NumTexCoordPrecisions);
2869 int bm = index_for_blend_mode(blend_mode);
2914 RenderPassColorMatrixProgramAA* program = 2870 RenderPassColorMatrixProgramAA* program =
2915 &render_pass_color_matrix_program_aa_[precision]; 2871 &render_pass_color_matrix_program_aa_[precision][bm];
2916 if (!program->initialized()) { 2872 if (!program->initialized()) {
2917 TRACE_EVENT0("cc", 2873 TRACE_EVENT0("cc",
2918 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); 2874 "GLRenderer::renderPassColorMatrixProgramAA::initialize");
2919 program->Initialize( 2875 program->Initialize(output_surface_->context_provider(),
2920 output_surface_->context_provider(), precision, SamplerType2D); 2876 precision,
2877 SamplerType2D,
2878 blend_mode);
2921 } 2879 }
2922 return program; 2880 return program;
2923 } 2881 }
2924 2882
2925 const GLRenderer::RenderPassMaskColorMatrixProgram* 2883 const GLRenderer::RenderPassMaskColorMatrixProgram*
2926 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { 2884 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
2885 SkXfermode::Mode blend_mode) {
2927 DCHECK_GE(precision, 0); 2886 DCHECK_GE(precision, 0);
2928 DCHECK_LT(precision, NumTexCoordPrecisions); 2887 DCHECK_LT(precision, NumTexCoordPrecisions);
2888 int bm = index_for_blend_mode(blend_mode);
2929 RenderPassMaskColorMatrixProgram* program = 2889 RenderPassMaskColorMatrixProgram* program =
2930 &render_pass_mask_color_matrix_program_[precision]; 2890 &render_pass_mask_color_matrix_program_[precision][bm];
2931 if (!program->initialized()) { 2891 if (!program->initialized()) {
2932 TRACE_EVENT0("cc", 2892 TRACE_EVENT0("cc",
2933 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); 2893 "GLRenderer::renderPassMaskColorMatrixProgram::initialize");
2934 program->Initialize( 2894 program->Initialize(output_surface_->context_provider(),
2935 output_surface_->context_provider(), precision, SamplerType2D); 2895 precision,
2896 SamplerType2D,
2897 blend_mode);
2936 } 2898 }
2937 return program; 2899 return program;
2938 } 2900 }
2939 2901
2940 const GLRenderer::RenderPassMaskColorMatrixProgramAA* 2902 const GLRenderer::RenderPassMaskColorMatrixProgramAA*
2941 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { 2903 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
2904 SkXfermode::Mode blend_mode) {
2942 DCHECK_GE(precision, 0); 2905 DCHECK_GE(precision, 0);
2943 DCHECK_LT(precision, NumTexCoordPrecisions); 2906 DCHECK_LT(precision, NumTexCoordPrecisions);
2907 int bm = index_for_blend_mode(blend_mode);
2944 RenderPassMaskColorMatrixProgramAA* program = 2908 RenderPassMaskColorMatrixProgramAA* program =
2945 &render_pass_mask_color_matrix_program_aa_[precision]; 2909 &render_pass_mask_color_matrix_program_aa_[precision][bm];
2946 if (!program->initialized()) { 2910 if (!program->initialized()) {
2947 TRACE_EVENT0("cc", 2911 TRACE_EVENT0("cc",
2948 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); 2912 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize");
2949 program->Initialize( 2913 program->Initialize(output_surface_->context_provider(),
2950 output_surface_->context_provider(), precision, SamplerType2D); 2914 precision,
2915 SamplerType2D,
2916 blend_mode);
2951 } 2917 }
2952 return program; 2918 return program;
2953 } 2919 }
2954 2920
2955 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( 2921 const GLRenderer::TileProgram* GLRenderer::GetTileProgram(
2956 TexCoordPrecision precision, 2922 TexCoordPrecision precision,
2957 SamplerType sampler) { 2923 SamplerType sampler) {
2958 DCHECK_GE(precision, 0); 2924 DCHECK_GE(precision, 0);
2959 DCHECK_LT(precision, NumTexCoordPrecisions); 2925 DCHECK_LT(precision, NumTexCoordPrecisions);
2960 DCHECK_GE(sampler, 0); 2926 DCHECK_GE(sampler, 0);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 3132
3167 for (int i = 0; i < NumTexCoordPrecisions; ++i) { 3133 for (int i = 0; i < NumTexCoordPrecisions; ++i) {
3168 for (int j = 0; j < NumSamplerTypes; ++j) { 3134 for (int j = 0; j < NumSamplerTypes; ++j) {
3169 tile_program_[i][j].Cleanup(gl_); 3135 tile_program_[i][j].Cleanup(gl_);
3170 tile_program_opaque_[i][j].Cleanup(gl_); 3136 tile_program_opaque_[i][j].Cleanup(gl_);
3171 tile_program_swizzle_[i][j].Cleanup(gl_); 3137 tile_program_swizzle_[i][j].Cleanup(gl_);
3172 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); 3138 tile_program_swizzle_opaque_[i][j].Cleanup(gl_);
3173 tile_program_aa_[i][j].Cleanup(gl_); 3139 tile_program_aa_[i][j].Cleanup(gl_);
3174 tile_program_swizzle_aa_[i][j].Cleanup(gl_); 3140 tile_program_swizzle_aa_[i][j].Cleanup(gl_);
3175 } 3141 }
3176 3142 for (int j = 0; j < kNumBlendModes; j++) {
3177 render_pass_mask_program_[i].Cleanup(gl_); 3143 render_pass_mask_program_[i][j].Cleanup(gl_);
3178 render_pass_program_[i].Cleanup(gl_); 3144 render_pass_program_[i][j].Cleanup(gl_);
3179 render_pass_mask_program_aa_[i].Cleanup(gl_); 3145 render_pass_mask_program_aa_[i][j].Cleanup(gl_);
3180 render_pass_program_aa_[i].Cleanup(gl_); 3146 render_pass_program_aa_[i][j].Cleanup(gl_);
3181 render_pass_color_matrix_program_[i].Cleanup(gl_); 3147 render_pass_color_matrix_program_[i][j].Cleanup(gl_);
3182 render_pass_mask_color_matrix_program_aa_[i].Cleanup(gl_); 3148 render_pass_mask_color_matrix_program_aa_[i][j].Cleanup(gl_);
3183 render_pass_color_matrix_program_aa_[i].Cleanup(gl_); 3149 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_);
3184 render_pass_mask_color_matrix_program_[i].Cleanup(gl_); 3150 render_pass_mask_color_matrix_program_[i][j].Cleanup(gl_);
3151 }
3185 3152
3186 texture_program_[i].Cleanup(gl_); 3153 texture_program_[i].Cleanup(gl_);
3187 nonpremultiplied_texture_program_[i].Cleanup(gl_); 3154 nonpremultiplied_texture_program_[i].Cleanup(gl_);
3188 texture_background_program_[i].Cleanup(gl_); 3155 texture_background_program_[i].Cleanup(gl_);
3189 nonpremultiplied_texture_background_program_[i].Cleanup(gl_); 3156 nonpremultiplied_texture_background_program_[i].Cleanup(gl_);
3190 texture_io_surface_program_[i].Cleanup(gl_); 3157 texture_io_surface_program_[i].Cleanup(gl_);
3191 3158
3192 video_yuv_program_[i].Cleanup(gl_); 3159 video_yuv_program_[i].Cleanup(gl_);
3193 video_yuva_program_[i].Cleanup(gl_); 3160 video_yuva_program_[i].Cleanup(gl_);
3194 video_stream_texture_program_[i].Cleanup(gl_); 3161 video_stream_texture_program_[i].Cleanup(gl_);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3283 context_support_->ScheduleOverlayPlane( 3250 context_support_->ScheduleOverlayPlane(
3284 overlay.plane_z_order, 3251 overlay.plane_z_order,
3285 overlay.transform, 3252 overlay.transform,
3286 pending_overlay_resources_.back()->texture_id(), 3253 pending_overlay_resources_.back()->texture_id(),
3287 overlay.display_rect, 3254 overlay.display_rect,
3288 overlay.uv_rect); 3255 overlay.uv_rect);
3289 } 3256 }
3290 } 3257 }
3291 3258
3292 } // namespace cc 3259 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698