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

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

Issue 664803003: Update from chromium a8e7c94b1b79a0948d05a1fcfff53391d22ce37a (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 case GL_TEXTURE_RECTANGLE_ARB: 116 case GL_TEXTURE_RECTANGLE_ARB:
117 return SamplerType2DRect; 117 return SamplerType2DRect;
118 case GL_TEXTURE_EXTERNAL_OES: 118 case GL_TEXTURE_EXTERNAL_OES:
119 return SamplerTypeExternalOES; 119 return SamplerTypeExternalOES;
120 default: 120 default:
121 NOTREACHED(); 121 NOTREACHED();
122 return SamplerType2D; 122 return SamplerType2D;
123 } 123 }
124 } 124 }
125 125
126 BlendMode BlendModeFromSkXfermode(SkXfermode::Mode mode) {
127 switch (mode) {
128 case SkXfermode::kSrcOver_Mode:
129 return BlendModeNormal;
130 case SkXfermode::kOverlay_Mode:
131 return BlendModeOverlay;
132 case SkXfermode::kDarken_Mode:
133 return BlendModeDarken;
134 case SkXfermode::kLighten_Mode:
135 return BlendModeLighten;
136 case SkXfermode::kColorDodge_Mode:
137 return BlendModeColorDodge;
138 case SkXfermode::kColorBurn_Mode:
139 return BlendModeColorBurn;
140 case SkXfermode::kHardLight_Mode:
141 return BlendModeHardLight;
142 case SkXfermode::kSoftLight_Mode:
143 return BlendModeSoftLight;
144 case SkXfermode::kDifference_Mode:
145 return BlendModeDifference;
146 case SkXfermode::kExclusion_Mode:
147 return BlendModeExclusion;
148 case SkXfermode::kMultiply_Mode:
149 return BlendModeMultiply;
150 case SkXfermode::kHue_Mode:
151 return BlendModeHue;
152 case SkXfermode::kSaturation_Mode:
153 return BlendModeSaturation;
154 case SkXfermode::kColor_Mode:
155 return BlendModeColor;
156 case SkXfermode::kLuminosity_Mode:
157 return BlendModeLuminosity;
158 default:
159 NOTREACHED();
160 return BlendModeNormal;
161 }
162 }
163
126 // Smallest unit that impact anti-aliasing output. We use this to 164 // Smallest unit that impact anti-aliasing output. We use this to
127 // determine when anti-aliasing is unnecessary. 165 // determine when anti-aliasing is unnecessary.
128 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; 166 const float kAntiAliasingEpsilon = 1.0f / 1024.0f;
129 167
130 // Block or crash if the number of pending sync queries reach this high as 168 // Block or crash if the number of pending sync queries reach this high as
131 // something is seriously wrong on the service side if this happens. 169 // something is seriously wrong on the service side if this happens.
132 const size_t kMaxPendingSyncQueries = 16; 170 const size_t kMaxPendingSyncQueries = 16;
133 171
134 } // anonymous namespace 172 } // anonymous namespace
135 173
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) { 754 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) {
717 if (blend_mode == SkXfermode::kSrcOver_Mode) 755 if (blend_mode == SkXfermode::kSrcOver_Mode)
718 return; 756 return;
719 757
720 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 758 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
721 759
722 if (blend_mode == SkXfermode::kLighten_Mode) 760 if (blend_mode == SkXfermode::kLighten_Mode)
723 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); 761 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD));
724 } 762 }
725 763
726 static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop(
727 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
728 ResourceProvider* resource_provider,
729 skia::RefPtr<SkImage> source_bitmap_with_filters,
730 ScopedResource* source_texture_resource,
731 ScopedResource* background_texture_resource,
732 SkXfermode::Mode blend_mode) {
733 if (!use_gr_context)
734 return source_bitmap_with_filters;
735
736 DCHECK(background_texture_resource);
737 DCHECK(source_texture_resource);
738
739 gfx::Size source_size = source_texture_resource->size();
740 gfx::Size background_size = background_texture_resource->size();
741
742 DCHECK_LE(background_size.width(), source_size.width());
743 DCHECK_LE(background_size.height(), source_size.height());
744
745 int source_texture_with_filters_id;
746 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
747 if (source_bitmap_with_filters) {
748 DCHECK_EQ(source_size.width(), source_bitmap_with_filters->width());
749 DCHECK_EQ(source_size.height(), source_bitmap_with_filters->height());
750 GrTexture* texture =
751 reinterpret_cast<GrTexture*>(source_bitmap_with_filters->getTexture());
752 source_texture_with_filters_id = texture->getTextureHandle();
753 } else {
754 lock.reset(new ResourceProvider::ScopedReadLockGL(
755 resource_provider, source_texture_resource->id()));
756 source_texture_with_filters_id = lock->texture_id();
757 }
758
759 ResourceProvider::ScopedReadLockGL lock_background(
760 resource_provider, background_texture_resource->id());
761
762 // Wrap the source texture in a Ganesh platform texture.
763 GrBackendTextureDesc backend_texture_description;
764 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
765 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
766
767 backend_texture_description.fWidth = source_size.width();
768 backend_texture_description.fHeight = source_size.height();
769 backend_texture_description.fTextureHandle = source_texture_with_filters_id;
770 skia::RefPtr<GrTexture> source_texture =
771 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
772 backend_texture_description));
773 if (!source_texture) {
774 TRACE_EVENT_INSTANT0(
775 "cc",
776 "ApplyBlendModeWithBackdrop wrap source texture failed",
777 TRACE_EVENT_SCOPE_THREAD);
778 return skia::RefPtr<SkImage>();
779 }
780
781 backend_texture_description.fWidth = background_size.width();
782 backend_texture_description.fHeight = background_size.height();
783 backend_texture_description.fTextureHandle = lock_background.texture_id();
784 skia::RefPtr<GrTexture> background_texture =
785 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
786 backend_texture_description));
787 if (!background_texture) {
788 TRACE_EVENT_INSTANT0(
789 "cc",
790 "ApplyBlendModeWithBackdrop wrap background texture failed",
791 TRACE_EVENT_SCOPE_THREAD);
792 return skia::RefPtr<SkImage>();
793 }
794
795 SkImageInfo source_info =
796 SkImageInfo::MakeN32Premul(source_size.width(), source_size.height());
797 // Place the platform texture inside an SkBitmap.
798 SkBitmap source;
799 source.setInfo(source_info);
800 skia::RefPtr<SkGrPixelRef> source_pixel_ref =
801 skia::AdoptRef(new SkGrPixelRef(source_info, source_texture.get()));
802 source.setPixelRef(source_pixel_ref.get());
803
804 SkImageInfo background_info = SkImageInfo::MakeN32Premul(
805 background_size.width(), background_size.height());
806
807 SkBitmap background;
808 background.setInfo(background_info);
809 skia::RefPtr<SkGrPixelRef> background_pixel_ref =
810 skia::AdoptRef(new SkGrPixelRef(
811 background_info, background_texture.get()));
812 background.setPixelRef(background_pixel_ref.get());
813
814 // Create a scratch texture for backing store.
815 GrTextureDesc desc;
816 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
817 desc.fSampleCnt = 0;
818 desc.fWidth = source.width();
819 desc.fHeight = source.height();
820 desc.fConfig = kSkia8888_GrPixelConfig;
821 desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
822 skia::RefPtr<GrTexture> backing_store =
823 skia::AdoptRef(use_gr_context->context()->refScratchTexture(
824 desc, GrContext::kExact_ScratchTexMatch));
825 if (!backing_store) {
826 TRACE_EVENT_INSTANT0(
827 "cc",
828 "ApplyBlendModeWithBackdrop scratch texture allocation failed",
829 TRACE_EVENT_SCOPE_THREAD);
830 return source_bitmap_with_filters;
831 }
832
833 // Create a device and canvas using that backing store.
834 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
835 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
836 if (!surface)
837 return skia::RefPtr<SkImage>();
838 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
839
840 // Draw the source bitmap through the filter to the canvas.
841 canvas->clear(SK_ColorTRANSPARENT);
842 canvas->drawSprite(background, 0, 0);
843 SkPaint paint;
844 paint.setXfermodeMode(blend_mode);
845 canvas->drawSprite(source, 0, 0, &paint);
846
847 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot());
848 if (!image || !image->getTexture()) {
849 return skia::RefPtr<SkImage>();
850 }
851
852 // Flush the GrContext to ensure all buffered GL calls are drawn to the
853 // backing store before we access and return it, and have cc begin using the
854 // GL context again.
855 canvas->flush();
856
857 return image;
858 }
859
860 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame, 764 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame,
861 const RenderPassDrawQuad* quad) { 765 const RenderPassDrawQuad* quad) {
862 if (quad->background_filters.IsEmpty()) 766 if (quad->background_filters.IsEmpty())
863 return false; 767 return false;
864 768
865 // TODO(danakj): We only allow background filters on an opaque render surface 769 // TODO(danakj): We only allow background filters on an opaque render surface
866 // because other surfaces may contain translucent pixels, and the contents 770 // because other surfaces may contain translucent pixels, and the contents
867 // behind those translucent pixels wouldn't have the filter applied. 771 // behind those translucent pixels wouldn't have the filter applied.
868 if (frame->current_render_pass->has_transparent_background) 772 if (frame->current_render_pass->has_transparent_background)
869 return false; 773 return false;
870 774
871 // TODO(ajuma): Add support for reference filters once 775 // TODO(ajuma): Add support for reference filters once
872 // FilterOperations::GetOutsets supports reference filters. 776 // FilterOperations::GetOutsets supports reference filters.
873 if (quad->background_filters.HasReferenceFilter()) 777 if (quad->background_filters.HasReferenceFilter())
874 return false; 778 return false;
875 return true; 779 return true;
876 } 780 }
877 781
878 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad( 782 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(
879 DrawingFrame* frame, 783 DrawingFrame* frame,
880 const RenderPassDrawQuad* quad, 784 const RenderPassDrawQuad* quad,
881 const gfx::Transform& contents_device_transform) { 785 const gfx::Transform& contents_device_transform,
786 bool use_aa) {
882 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( 787 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect(
883 contents_device_transform, SharedGeometryQuad().BoundingBox())); 788 contents_device_transform, SharedGeometryQuad().BoundingBox()));
884 789
885 if (ShouldApplyBackgroundFilters(frame, quad)) { 790 if (ShouldApplyBackgroundFilters(frame, quad)) {
886 int top, right, bottom, left; 791 int top, right, bottom, left;
887 quad->background_filters.GetOutsets(&top, &right, &bottom, &left); 792 quad->background_filters.GetOutsets(&top, &right, &bottom, &left);
888 backdrop_rect.Inset(-left, -top, -right, -bottom); 793 backdrop_rect.Inset(-left, -top, -right, -bottom);
889 } 794 }
890 795
796 if (!backdrop_rect.IsEmpty() && use_aa) {
797 const int kOutsetForAntialiasing = 1;
798 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing);
799 }
800
891 backdrop_rect.Intersect( 801 backdrop_rect.Intersect(
892 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); 802 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect));
893 return backdrop_rect; 803 return backdrop_rect;
894 } 804 }
895 805
896 scoped_ptr<ScopedResource> GLRenderer::GetBackdropTexture( 806 scoped_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
897 const gfx::Rect& bounding_rect) { 807 const gfx::Rect& bounding_rect) {
898 scoped_ptr<ScopedResource> device_background_texture = 808 scoped_ptr<ScopedResource> device_background_texture =
899 ScopedResource::Create(resource_provider_); 809 ScopedResource::Create(resource_provider_);
900 // CopyTexImage2D fails when called on a texture having immutable storage. 810 // CopyTexImage2D fails when called on a texture having immutable storage.
(...skipping 24 matching lines...) Expand all
925 filter.get(), 835 filter.get(),
926 background_texture); 836 background_texture);
927 return background_with_filters; 837 return background_with_filters;
928 } 838 }
929 839
930 scoped_ptr<ScopedResource> 840 scoped_ptr<ScopedResource>
931 GLRenderer::ApplyInverseTransformForBackgroundFilters( 841 GLRenderer::ApplyInverseTransformForBackgroundFilters(
932 DrawingFrame* frame, 842 DrawingFrame* frame,
933 const RenderPassDrawQuad* quad, 843 const RenderPassDrawQuad* quad,
934 const gfx::Transform& contents_device_transform_inverse, 844 const gfx::Transform& contents_device_transform_inverse,
935 ScopedResource* device_background_texture,
936 skia::RefPtr<SkImage> filtered_device_background, 845 skia::RefPtr<SkImage> filtered_device_background,
937 const gfx::Rect& backdrop_bounding_rect) { 846 const gfx::Rect& backdrop_bounding_rect) {
938 // This method draws a background filter, which applies a filter to any pixels 847 // This method draws a background filter, which applies a filter to any pixels
939 // behind the quad and seen through its background. The algorithm works as 848 // behind the quad and seen through its background. The algorithm works as
940 // follows: 849 // follows:
941 // 1. Read the pixels in the bounding box into a buffer. 850 // 1. Read the pixels in the bounding box into a buffer.
942 // Moved to GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(). 851 // Moved to GLRenderer::GetBackdropBoundingBoxForRenderPassQuad().
943 // 2. Read the pixels in the bounding box into a buffer R. 852 // 2. Read the pixels in the bounding box into a buffer R.
944 // Moved to GLRenderer::GetBackdropTexture(). 853 // Moved to GLRenderer::GetBackdropTexture().
945 // 3. Apply the background filter to R, so that it is applied in the pixels' 854 // 3. Apply the background filter to R, so that it is applied in the pixels'
946 // coordinate space. Moved to GLRenderer::ApplyBackgroundFilters(). 855 // coordinate space. Moved to GLRenderer::ApplyBackgroundFilters().
947 // 4. Apply the quad's inverse transform to map the pixels in R into the 856 // 4. Apply the quad's inverse transform to map the pixels in R into the
948 // quad's content space. This implicitly clips R by the content bounds of the 857 // quad's content space. This implicitly clips R by the content bounds of the
949 // quad since the destination texture has bounds matching the quad's content. 858 // quad since the destination texture has bounds matching the quad's content.
950 // 5. Draw the background texture for the contents using the same transform as 859 // 5. Draw the background texture for the contents using the same transform as
951 // used to draw the contents itself. This is done without blending to replace 860 // used to draw the contents itself. This is done without blending to replace
952 // the current background pixels with the new filtered background. 861 // the current background pixels with the new filtered background.
953 // 6. Draw the contents of the quad over drop of the new background with 862 // 6. Draw the contents of the quad over drop of the new background with
954 // blending, as per usual. The filtered background pixels will show through 863 // blending, as per usual. The filtered background pixels will show through
955 // any non-opaque pixels in this draws. 864 // any non-opaque pixels in this draws.
956 // 865 //
957 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. 866 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5.
958 867
959 // TODO(danakj): When this algorithm changes, update 868 // TODO(danakj): When this algorithm changes, update
960 // LayerTreeHost::PrioritizeTextures() accordingly. 869 // LayerTreeHost::PrioritizeTextures() accordingly.
961 870
962 DCHECK(device_background_texture); 871 DCHECK(filtered_device_background);
963 872
964 int filtered_device_background_texture_id = 0; 873 GrTexture* texture = filtered_device_background->getTexture();
965 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
966 if (filtered_device_background) {
967 GrTexture* texture = filtered_device_background->getTexture();
968 filtered_device_background_texture_id = texture->getTextureHandle();
969 } else {
970 lock.reset(new ResourceProvider::ScopedReadLockGL(
971 resource_provider_, device_background_texture->id()));
972 filtered_device_background_texture_id = lock->texture_id();
973 }
974 874
975 scoped_ptr<ScopedResource> background_texture = 875 scoped_ptr<ScopedResource> background_texture =
976 ScopedResource::Create(resource_provider_); 876 ScopedResource::Create(resource_provider_);
977 background_texture->Allocate( 877 background_texture->Allocate(
978 quad->rect.size(), 878 quad->rect.size(),
979 ResourceProvider::TextureHintImmutableFramebuffer, 879 ResourceProvider::TextureHintImmutableFramebuffer,
980 RGBA_8888); 880 RGBA_8888);
981 881
982 const RenderPass* target_render_pass = frame->current_render_pass; 882 const RenderPass* target_render_pass = frame->current_render_pass;
983 bool using_background_texture = 883 bool using_background_texture =
(...skipping 13 matching lines...) Expand all
997 gl_->Clear(GL_COLOR_BUFFER_BIT); 897 gl_->Clear(GL_COLOR_BUFFER_BIT);
998 #endif 898 #endif
999 899
1000 // The background_texture is oriented the same as the frame buffer. 900 // The background_texture is oriented the same as the frame buffer.
1001 // The transform we are copying with has a vertical flip, as well as 901 // The transform we are copying with has a vertical flip, as well as
1002 // the |device_to_framebuffer_transform|, which cancel each other out. So do 902 // the |device_to_framebuffer_transform|, which cancel each other out. So do
1003 // not flip the contents in the shader to maintain orientation. 903 // not flip the contents in the shader to maintain orientation.
1004 bool flip_vertically = false; 904 bool flip_vertically = false;
1005 905
1006 CopyTextureToFramebuffer(frame, 906 CopyTextureToFramebuffer(frame,
1007 filtered_device_background_texture_id, 907 texture->getTextureHandle(),
1008 backdrop_bounding_rect, 908 backdrop_bounding_rect,
1009 device_to_framebuffer_transform, 909 device_to_framebuffer_transform,
1010 flip_vertically); 910 flip_vertically);
1011 } 911 }
1012 912
1013 UseRenderPass(frame, target_render_pass); 913 UseRenderPass(frame, target_render_pass);
1014 914
1015 if (!using_background_texture) 915 if (!using_background_texture)
1016 return nullptr; 916 return nullptr;
1017 return background_texture.Pass(); 917 return background_texture.Pass();
1018 } 918 }
1019 919
1020 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 920 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
1021 const RenderPassDrawQuad* quad) { 921 const RenderPassDrawQuad* quad) {
1022 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; 922 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
1023 SetBlendEnabled(quad->ShouldDrawWithBlending() || 923 SetBlendEnabled(
1024 (!IsDefaultBlendMode(blend_mode) && 924 CanApplyBlendModeUsingBlendFunc(blend_mode) &&
1025 CanApplyBlendModeUsingBlendFunc(blend_mode))); 925 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode)));
1026 926
1027 ScopedResource* contents_texture = 927 ScopedResource* contents_texture =
1028 render_pass_textures_.get(quad->render_pass_id); 928 render_pass_textures_.get(quad->render_pass_id);
1029 if (!contents_texture || !contents_texture->id()) 929 if (!contents_texture || !contents_texture->id())
1030 return; 930 return;
1031 931
1032 gfx::Transform quad_rect_matrix; 932 gfx::Transform quad_rect_matrix;
1033 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 933 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
1034 gfx::Transform contents_device_transform = 934 gfx::Transform contents_device_transform =
1035 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 935 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
1036 contents_device_transform.FlattenTo2d(); 936 contents_device_transform.FlattenTo2d();
1037 937
1038 // Can only draw surface if device matrix is invertible. 938 // Can only draw surface if device matrix is invertible.
1039 gfx::Transform contents_device_transform_inverse( 939 gfx::Transform contents_device_transform_inverse(
1040 gfx::Transform::kSkipInitialization); 940 gfx::Transform::kSkipInitialization);
1041 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) 941 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse))
1042 return; 942 return;
1043 943
944 bool clipped = false;
945 gfx::QuadF device_quad = MathUtil::MapQuad(
946 contents_device_transform, SharedGeometryQuad(), &clipped);
947 // Use anti-aliasing programs only when necessary.
948 bool use_aa =
949 !clipped &&
950 (settings_->force_antialiasing || !device_quad.IsRectilinear() ||
951 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
952 kAntiAliasingEpsilon));
953
1044 bool need_background_texture = !CanApplyBlendModeUsingBlendFunc(blend_mode) || 954 bool need_background_texture = !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
1045 ShouldApplyBackgroundFilters(frame, quad); 955 ShouldApplyBackgroundFilters(frame, quad);
1046 956
1047 scoped_ptr<ScopedResource> background_texture; 957 scoped_ptr<ScopedResource> background_texture;
958 skia::RefPtr<SkImage> background_image;
959 gfx::Rect background_rect;
1048 if (need_background_texture) { 960 if (need_background_texture) {
961 // Compute a bounding box around the pixels that will be visible through
962 // the quad.
963 background_rect = GetBackdropBoundingBoxForRenderPassQuad(
964 frame, quad, contents_device_transform, use_aa);
965 }
966
967 if (!background_rect.IsEmpty()) {
1049 // The pixels from the filtered background should completely replace the 968 // The pixels from the filtered background should completely replace the
1050 // current pixel values. 969 // current pixel values.
1051 bool disable_blending = blend_enabled(); 970 bool disable_blending = blend_enabled();
1052 if (disable_blending) 971 if (disable_blending)
1053 SetBlendEnabled(false); 972 SetBlendEnabled(false);
1054 973
1055 // Compute a bounding box around the pixels that will be visible through
1056 // the quad.
1057 gfx::Rect backdrop_rect = GetBackdropBoundingBoxForRenderPassQuad(
1058 frame, quad, contents_device_transform);
1059
1060 // Read the pixels in the bounding box into a buffer R. 974 // Read the pixels in the bounding box into a buffer R.
1061 scoped_ptr<ScopedResource> scoped_background_texture = 975 scoped_ptr<ScopedResource> scoped_background_texture =
1062 GetBackdropTexture(backdrop_rect); 976 GetBackdropTexture(background_rect);
1063 977
1064 skia::RefPtr<SkImage> background_with_filters; 978 skia::RefPtr<SkImage> background_with_filters;
1065 if (ShouldApplyBackgroundFilters(frame, quad)) { 979 if (ShouldApplyBackgroundFilters(frame, quad) &&
980 scoped_background_texture) {
1066 // Apply the background filters to R, so that it is applied in the pixels' 981 // Apply the background filters to R, so that it is applied in the pixels'
1067 // coordinate space. 982 // coordinate space.
1068 background_with_filters = 983 background_with_filters =
1069 ApplyBackgroundFilters(frame, quad, scoped_background_texture.get()); 984 ApplyBackgroundFilters(frame, quad, scoped_background_texture.get());
1070 } 985 }
1071 // Apply the quad's inverse transform to map the pixels in R into the 986
1072 // quad's content space. This implicitly clips R by the content bounds of 987 if (CanApplyBlendModeUsingBlendFunc(blend_mode) &&
1073 // the quad since the destination texture has bounds matching the quad's 988 background_with_filters) {
1074 // content. 989 // The background with filters will be copied to the frame buffer.
1075 background_texture = ApplyInverseTransformForBackgroundFilters( 990 // Apply the quad's inverse transform to map the pixels in R into the
1076 frame, 991 // quad's content space. This implicitly clips R by the content bounds of
1077 quad, 992 // the quad since the destination texture has bounds matching the quad's
1078 contents_device_transform_inverse, 993 // content.
1079 scoped_background_texture.get(), 994 background_texture = ApplyInverseTransformForBackgroundFilters(
1080 background_with_filters, 995 frame,
1081 backdrop_rect); 996 quad,
997 contents_device_transform_inverse,
998 background_with_filters,
999 background_rect);
1000 } else if (!CanApplyBlendModeUsingBlendFunc(blend_mode)) {
1001 if (background_with_filters) {
1002 // The background with filters will be used as backdrop for blending.
1003 background_image = background_with_filters;
1004 } else {
1005 background_texture = scoped_background_texture.Pass();
1006 }
1007 }
1082 1008
1083 if (disable_blending) 1009 if (disable_blending)
1084 SetBlendEnabled(true); 1010 SetBlendEnabled(true);
1085 } 1011 }
1086 1012
1087 // TODO(senorblanco): Cache this value so that we don't have to do it for both 1013 // TODO(senorblanco): Cache this value so that we don't have to do it for both
1088 // the surface and its replica. Apply filters to the contents texture. 1014 // the surface and its replica. Apply filters to the contents texture.
1089 skia::RefPtr<SkImage> filter_image; 1015 skia::RefPtr<SkImage> filter_image;
1090 SkScalar color_matrix[20]; 1016 SkScalar color_matrix[20];
1091 bool use_color_matrix = false; 1017 bool use_color_matrix = false;
(...skipping 17 matching lines...) Expand all
1109 filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame), 1035 filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
1110 resource_provider_, 1036 resource_provider_,
1111 quad->rect.origin(), 1037 quad->rect.origin(),
1112 quad->filters_scale, 1038 quad->filters_scale,
1113 filter.get(), 1039 filter.get(),
1114 contents_texture); 1040 contents_texture);
1115 } 1041 }
1116 } 1042 }
1117 } 1043 }
1118 1044
1119 if (background_texture) { 1045 if (background_texture && ShouldApplyBackgroundFilters(frame, quad)) {
1120 if (CanApplyBlendModeUsingBlendFunc(blend_mode)) { 1046 // Draw the background texture if it has some filters applied.
1121 // Draw the background texture if it has some filters applied. 1047 DCHECK(CanApplyBlendModeUsingBlendFunc(blend_mode));
1122 DCHECK(ShouldApplyBackgroundFilters(frame, quad)); 1048 DCHECK(background_texture->size() == quad->rect.size());
1123 DCHECK(background_texture->size() == quad->rect.size()); 1049 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1124 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1050 background_texture->id());
1125 background_texture->id());
1126 1051
1127 // The background_texture is oriented the same as the frame buffer. The 1052 // The background_texture is oriented the same as the frame buffer. The
1128 // transform we are copying with has a vertical flip, so flip the contents 1053 // transform we are copying with has a vertical flip, so flip the contents
1129 // in the shader to maintain orientation 1054 // in the shader to maintain orientation
1130 bool flip_vertically = true; 1055 bool flip_vertically = true;
1131 1056
1132 CopyTextureToFramebuffer(frame, 1057 CopyTextureToFramebuffer(frame,
1133 lock.texture_id(), 1058 lock.texture_id(),
1134 quad->rect, 1059 quad->rect,
1135 quad->quadTransform(), 1060 quad->quadTransform(),
1136 flip_vertically); 1061 flip_vertically);
1137 } else {
1138 // If blending is applied using shaders, the background texture with
1139 // filters will be used as backdrop for blending operation, so we don't
1140 // need to copy it to the frame buffer.
1141 filter_image =
1142 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame),
1143 resource_provider_,
1144 filter_image,
1145 contents_texture,
1146 background_texture.get(),
1147 quad->shared_quad_state->blend_mode);
1148 }
1149 } 1062 }
1150 1063
1151 bool clipped = false;
1152 gfx::QuadF device_quad = MathUtil::MapQuad(
1153 contents_device_transform, SharedGeometryQuad(), &clipped);
1154 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox())); 1064 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox()));
1155 LayerQuad device_layer_edges(device_quad); 1065 LayerQuad device_layer_edges(device_quad);
1156
1157 // Use anti-aliasing programs only when necessary.
1158 bool use_aa =
1159 !clipped && (!device_quad.IsRectilinear() ||
1160 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
1161 kAntiAliasingEpsilon));
1162 if (use_aa) { 1066 if (use_aa) {
1163 device_layer_bounds.InflateAntiAliasingDistance(); 1067 device_layer_bounds.InflateAntiAliasingDistance();
1164 device_layer_edges.InflateAntiAliasingDistance(); 1068 device_layer_edges.InflateAntiAliasingDistance();
1165 } 1069 }
1166 1070
1167 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; 1071 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock;
1168 unsigned mask_texture_id = 0; 1072 unsigned mask_texture_id = 0;
1169 SamplerType mask_sampler = SamplerTypeNA; 1073 SamplerType mask_sampler = SamplerTypeNA;
1170 if (quad->mask_resource_id) { 1074 if (quad->mask_resource_id) {
1171 mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL( 1075 mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 int shader_edge_location = -1; 1107 int shader_edge_location = -1;
1204 int shader_viewport_location = -1; 1108 int shader_viewport_location = -1;
1205 int shader_mask_sampler_location = -1; 1109 int shader_mask_sampler_location = -1;
1206 int shader_mask_tex_coord_scale_location = -1; 1110 int shader_mask_tex_coord_scale_location = -1;
1207 int shader_mask_tex_coord_offset_location = -1; 1111 int shader_mask_tex_coord_offset_location = -1;
1208 int shader_matrix_location = -1; 1112 int shader_matrix_location = -1;
1209 int shader_alpha_location = -1; 1113 int shader_alpha_location = -1;
1210 int shader_color_matrix_location = -1; 1114 int shader_color_matrix_location = -1;
1211 int shader_color_offset_location = -1; 1115 int shader_color_offset_location = -1;
1212 int shader_tex_transform_location = -1; 1116 int shader_tex_transform_location = -1;
1117 int shader_backdrop_location = -1;
1118 int shader_backdrop_rect_location = -1;
1119
1120 BlendMode shader_blend_mode = ((background_texture || background_image) &&
1121 !CanApplyBlendModeUsingBlendFunc(blend_mode))
1122 ? BlendModeFromSkXfermode(blend_mode)
1123 : BlendModeNormal;
1213 1124
1214 if (use_aa && mask_texture_id && !use_color_matrix) { 1125 if (use_aa && mask_texture_id && !use_color_matrix) {
1215 const RenderPassMaskProgramAA* program = 1126 const RenderPassMaskProgramAA* program =
1216 GetRenderPassMaskProgramAA(tex_coord_precision); 1127 GetRenderPassMaskProgramAA(tex_coord_precision, shader_blend_mode);
1217 SetUseProgram(program->program()); 1128 SetUseProgram(program->program());
1218 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1129 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1219 1130
1220 shader_quad_location = program->vertex_shader().quad_location(); 1131 shader_quad_location = program->vertex_shader().quad_location();
1221 shader_edge_location = program->vertex_shader().edge_location(); 1132 shader_edge_location = program->vertex_shader().edge_location();
1222 shader_viewport_location = program->vertex_shader().viewport_location(); 1133 shader_viewport_location = program->vertex_shader().viewport_location();
1223 shader_mask_sampler_location = 1134 shader_mask_sampler_location =
1224 program->fragment_shader().mask_sampler_location(); 1135 program->fragment_shader().mask_sampler_location();
1225 shader_mask_tex_coord_scale_location = 1136 shader_mask_tex_coord_scale_location =
1226 program->fragment_shader().mask_tex_coord_scale_location(); 1137 program->fragment_shader().mask_tex_coord_scale_location();
1227 shader_mask_tex_coord_offset_location = 1138 shader_mask_tex_coord_offset_location =
1228 program->fragment_shader().mask_tex_coord_offset_location(); 1139 program->fragment_shader().mask_tex_coord_offset_location();
1229 shader_matrix_location = program->vertex_shader().matrix_location(); 1140 shader_matrix_location = program->vertex_shader().matrix_location();
1230 shader_alpha_location = program->fragment_shader().alpha_location(); 1141 shader_alpha_location = program->fragment_shader().alpha_location();
1231 shader_tex_transform_location = 1142 shader_tex_transform_location =
1232 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();
1233 } else if (!use_aa && mask_texture_id && !use_color_matrix) { 1147 } else if (!use_aa && mask_texture_id && !use_color_matrix) {
1234 const RenderPassMaskProgram* program = 1148 const RenderPassMaskProgram* program =
1235 GetRenderPassMaskProgram(tex_coord_precision); 1149 GetRenderPassMaskProgram(tex_coord_precision, shader_blend_mode);
1236 SetUseProgram(program->program()); 1150 SetUseProgram(program->program());
1237 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1151 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1238 1152
1239 shader_mask_sampler_location = 1153 shader_mask_sampler_location =
1240 program->fragment_shader().mask_sampler_location(); 1154 program->fragment_shader().mask_sampler_location();
1241 shader_mask_tex_coord_scale_location = 1155 shader_mask_tex_coord_scale_location =
1242 program->fragment_shader().mask_tex_coord_scale_location(); 1156 program->fragment_shader().mask_tex_coord_scale_location();
1243 shader_mask_tex_coord_offset_location = 1157 shader_mask_tex_coord_offset_location =
1244 program->fragment_shader().mask_tex_coord_offset_location(); 1158 program->fragment_shader().mask_tex_coord_offset_location();
1245 shader_matrix_location = program->vertex_shader().matrix_location(); 1159 shader_matrix_location = program->vertex_shader().matrix_location();
1246 shader_alpha_location = program->fragment_shader().alpha_location(); 1160 shader_alpha_location = program->fragment_shader().alpha_location();
1247 shader_tex_transform_location = 1161 shader_tex_transform_location =
1248 program->vertex_shader().tex_transform_location(); 1162 program->vertex_shader().tex_transform_location();
1163 shader_backdrop_location = program->fragment_shader().backdrop_location();
1164 shader_backdrop_rect_location =
1165 program->fragment_shader().backdrop_rect_location();
1249 } else if (use_aa && !mask_texture_id && !use_color_matrix) { 1166 } else if (use_aa && !mask_texture_id && !use_color_matrix) {
1250 const RenderPassProgramAA* program = 1167 const RenderPassProgramAA* program =
1251 GetRenderPassProgramAA(tex_coord_precision); 1168 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode);
1252 SetUseProgram(program->program()); 1169 SetUseProgram(program->program());
1253 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1170 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1254 1171
1255 shader_quad_location = program->vertex_shader().quad_location(); 1172 shader_quad_location = program->vertex_shader().quad_location();
1256 shader_edge_location = program->vertex_shader().edge_location(); 1173 shader_edge_location = program->vertex_shader().edge_location();
1257 shader_viewport_location = program->vertex_shader().viewport_location(); 1174 shader_viewport_location = program->vertex_shader().viewport_location();
1258 shader_matrix_location = program->vertex_shader().matrix_location(); 1175 shader_matrix_location = program->vertex_shader().matrix_location();
1259 shader_alpha_location = program->fragment_shader().alpha_location(); 1176 shader_alpha_location = program->fragment_shader().alpha_location();
1260 shader_tex_transform_location = 1177 shader_tex_transform_location =
1261 program->vertex_shader().tex_transform_location(); 1178 program->vertex_shader().tex_transform_location();
1179 shader_backdrop_location = program->fragment_shader().backdrop_location();
1180 shader_backdrop_rect_location =
1181 program->fragment_shader().backdrop_rect_location();
1262 } else if (use_aa && mask_texture_id && use_color_matrix) { 1182 } else if (use_aa && mask_texture_id && use_color_matrix) {
1263 const RenderPassMaskColorMatrixProgramAA* program = 1183 const RenderPassMaskColorMatrixProgramAA* program =
1264 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision); 1184 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision,
1185 shader_blend_mode);
1265 SetUseProgram(program->program()); 1186 SetUseProgram(program->program());
1266 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1187 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1267 1188
1268 shader_matrix_location = program->vertex_shader().matrix_location(); 1189 shader_matrix_location = program->vertex_shader().matrix_location();
1269 shader_quad_location = program->vertex_shader().quad_location(); 1190 shader_quad_location = program->vertex_shader().quad_location();
1270 shader_tex_transform_location = 1191 shader_tex_transform_location =
1271 program->vertex_shader().tex_transform_location(); 1192 program->vertex_shader().tex_transform_location();
1272 shader_edge_location = program->vertex_shader().edge_location(); 1193 shader_edge_location = program->vertex_shader().edge_location();
1273 shader_viewport_location = program->vertex_shader().viewport_location(); 1194 shader_viewport_location = program->vertex_shader().viewport_location();
1274 shader_alpha_location = program->fragment_shader().alpha_location(); 1195 shader_alpha_location = program->fragment_shader().alpha_location();
1275 shader_mask_sampler_location = 1196 shader_mask_sampler_location =
1276 program->fragment_shader().mask_sampler_location(); 1197 program->fragment_shader().mask_sampler_location();
1277 shader_mask_tex_coord_scale_location = 1198 shader_mask_tex_coord_scale_location =
1278 program->fragment_shader().mask_tex_coord_scale_location(); 1199 program->fragment_shader().mask_tex_coord_scale_location();
1279 shader_mask_tex_coord_offset_location = 1200 shader_mask_tex_coord_offset_location =
1280 program->fragment_shader().mask_tex_coord_offset_location(); 1201 program->fragment_shader().mask_tex_coord_offset_location();
1281 shader_color_matrix_location = 1202 shader_color_matrix_location =
1282 program->fragment_shader().color_matrix_location(); 1203 program->fragment_shader().color_matrix_location();
1283 shader_color_offset_location = 1204 shader_color_offset_location =
1284 program->fragment_shader().color_offset_location(); 1205 program->fragment_shader().color_offset_location();
1206 shader_backdrop_location = program->fragment_shader().backdrop_location();
1207 shader_backdrop_rect_location =
1208 program->fragment_shader().backdrop_rect_location();
1285 } else if (use_aa && !mask_texture_id && use_color_matrix) { 1209 } else if (use_aa && !mask_texture_id && use_color_matrix) {
1286 const RenderPassColorMatrixProgramAA* program = 1210 const RenderPassColorMatrixProgramAA* program =
1287 GetRenderPassColorMatrixProgramAA(tex_coord_precision); 1211 GetRenderPassColorMatrixProgramAA(tex_coord_precision,
1212 shader_blend_mode);
1288 SetUseProgram(program->program()); 1213 SetUseProgram(program->program());
1289 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1214 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1290 1215
1291 shader_matrix_location = program->vertex_shader().matrix_location(); 1216 shader_matrix_location = program->vertex_shader().matrix_location();
1292 shader_quad_location = program->vertex_shader().quad_location(); 1217 shader_quad_location = program->vertex_shader().quad_location();
1293 shader_tex_transform_location = 1218 shader_tex_transform_location =
1294 program->vertex_shader().tex_transform_location(); 1219 program->vertex_shader().tex_transform_location();
1295 shader_edge_location = program->vertex_shader().edge_location(); 1220 shader_edge_location = program->vertex_shader().edge_location();
1296 shader_viewport_location = program->vertex_shader().viewport_location(); 1221 shader_viewport_location = program->vertex_shader().viewport_location();
1297 shader_alpha_location = program->fragment_shader().alpha_location(); 1222 shader_alpha_location = program->fragment_shader().alpha_location();
1298 shader_color_matrix_location = 1223 shader_color_matrix_location =
1299 program->fragment_shader().color_matrix_location(); 1224 program->fragment_shader().color_matrix_location();
1300 shader_color_offset_location = 1225 shader_color_offset_location =
1301 program->fragment_shader().color_offset_location(); 1226 program->fragment_shader().color_offset_location();
1227 shader_backdrop_location = program->fragment_shader().backdrop_location();
1228 shader_backdrop_rect_location =
1229 program->fragment_shader().backdrop_rect_location();
1302 } else if (!use_aa && mask_texture_id && use_color_matrix) { 1230 } else if (!use_aa && mask_texture_id && use_color_matrix) {
1303 const RenderPassMaskColorMatrixProgram* program = 1231 const RenderPassMaskColorMatrixProgram* program =
1304 GetRenderPassMaskColorMatrixProgram(tex_coord_precision); 1232 GetRenderPassMaskColorMatrixProgram(tex_coord_precision,
1233 shader_blend_mode);
1305 SetUseProgram(program->program()); 1234 SetUseProgram(program->program());
1306 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1235 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1307 1236
1308 shader_matrix_location = program->vertex_shader().matrix_location(); 1237 shader_matrix_location = program->vertex_shader().matrix_location();
1309 shader_tex_transform_location = 1238 shader_tex_transform_location =
1310 program->vertex_shader().tex_transform_location(); 1239 program->vertex_shader().tex_transform_location();
1311 shader_mask_sampler_location = 1240 shader_mask_sampler_location =
1312 program->fragment_shader().mask_sampler_location(); 1241 program->fragment_shader().mask_sampler_location();
1313 shader_mask_tex_coord_scale_location = 1242 shader_mask_tex_coord_scale_location =
1314 program->fragment_shader().mask_tex_coord_scale_location(); 1243 program->fragment_shader().mask_tex_coord_scale_location();
1315 shader_mask_tex_coord_offset_location = 1244 shader_mask_tex_coord_offset_location =
1316 program->fragment_shader().mask_tex_coord_offset_location(); 1245 program->fragment_shader().mask_tex_coord_offset_location();
1317 shader_alpha_location = program->fragment_shader().alpha_location(); 1246 shader_alpha_location = program->fragment_shader().alpha_location();
1318 shader_color_matrix_location = 1247 shader_color_matrix_location =
1319 program->fragment_shader().color_matrix_location(); 1248 program->fragment_shader().color_matrix_location();
1320 shader_color_offset_location = 1249 shader_color_offset_location =
1321 program->fragment_shader().color_offset_location(); 1250 program->fragment_shader().color_offset_location();
1251 shader_backdrop_location = program->fragment_shader().backdrop_location();
1252 shader_backdrop_rect_location =
1253 program->fragment_shader().backdrop_rect_location();
1322 } else if (!use_aa && !mask_texture_id && use_color_matrix) { 1254 } else if (!use_aa && !mask_texture_id && use_color_matrix) {
1323 const RenderPassColorMatrixProgram* program = 1255 const RenderPassColorMatrixProgram* program =
1324 GetRenderPassColorMatrixProgram(tex_coord_precision); 1256 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode);
1325 SetUseProgram(program->program()); 1257 SetUseProgram(program->program());
1326 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1258 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1327 1259
1328 shader_matrix_location = program->vertex_shader().matrix_location(); 1260 shader_matrix_location = program->vertex_shader().matrix_location();
1329 shader_tex_transform_location = 1261 shader_tex_transform_location =
1330 program->vertex_shader().tex_transform_location(); 1262 program->vertex_shader().tex_transform_location();
1331 shader_alpha_location = program->fragment_shader().alpha_location(); 1263 shader_alpha_location = program->fragment_shader().alpha_location();
1332 shader_color_matrix_location = 1264 shader_color_matrix_location =
1333 program->fragment_shader().color_matrix_location(); 1265 program->fragment_shader().color_matrix_location();
1334 shader_color_offset_location = 1266 shader_color_offset_location =
1335 program->fragment_shader().color_offset_location(); 1267 program->fragment_shader().color_offset_location();
1268 shader_backdrop_location = program->fragment_shader().backdrop_location();
1269 shader_backdrop_rect_location =
1270 program->fragment_shader().backdrop_rect_location();
1336 } else { 1271 } else {
1337 const RenderPassProgram* program = 1272 const RenderPassProgram* program =
1338 GetRenderPassProgram(tex_coord_precision); 1273 GetRenderPassProgram(tex_coord_precision, shader_blend_mode);
1339 SetUseProgram(program->program()); 1274 SetUseProgram(program->program());
1340 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1275 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1341 1276
1342 shader_matrix_location = program->vertex_shader().matrix_location(); 1277 shader_matrix_location = program->vertex_shader().matrix_location();
1343 shader_alpha_location = program->fragment_shader().alpha_location(); 1278 shader_alpha_location = program->fragment_shader().alpha_location();
1344 shader_tex_transform_location = 1279 shader_tex_transform_location =
1345 program->vertex_shader().tex_transform_location(); 1280 program->vertex_shader().tex_transform_location();
1281 shader_backdrop_location = program->fragment_shader().backdrop_location();
1282 shader_backdrop_rect_location =
1283 program->fragment_shader().backdrop_rect_location();
1346 } 1284 }
1347 float tex_scale_x = 1285 float tex_scale_x =
1348 quad->rect.width() / static_cast<float>(contents_texture->size().width()); 1286 quad->rect.width() / static_cast<float>(contents_texture->size().width());
1349 float tex_scale_y = quad->rect.height() / 1287 float tex_scale_y = quad->rect.height() /
1350 static_cast<float>(contents_texture->size().height()); 1288 static_cast<float>(contents_texture->size().height());
1351 DCHECK_LE(tex_scale_x, 1.0f); 1289 DCHECK_LE(tex_scale_x, 1.0f);
1352 DCHECK_LE(tex_scale_y, 1.0f); 1290 DCHECK_LE(tex_scale_y, 1.0f);
1353 1291
1354 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); 1292 DCHECK(shader_tex_transform_location != -1 || IsContextLost());
1355 // Flip the content vertically in the shader, as the RenderPass input 1293 // Flip the content vertically in the shader, as the RenderPass input
1356 // texture is already oriented the same way as the framebuffer, but the 1294 // texture is already oriented the same way as the framebuffer, but the
1357 // projection transform does a flip. 1295 // projection transform does a flip.
1358 GLC(gl_, 1296 GLC(gl_,
1359 gl_->Uniform4f(shader_tex_transform_location, 1297 gl_->Uniform4f(shader_tex_transform_location,
1360 0.0f, 1298 0.0f,
1361 tex_scale_y, 1299 tex_scale_y,
1362 tex_scale_x, 1300 tex_scale_x,
1363 -tex_scale_y)); 1301 -tex_scale_y));
1364 1302
1303 GLint last_texture_unit = 0;
1365 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; 1304 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock;
1366 if (shader_mask_sampler_location != -1) { 1305 if (shader_mask_sampler_location != -1) {
1367 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); 1306 DCHECK_NE(shader_mask_tex_coord_scale_location, 1);
1368 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); 1307 DCHECK_NE(shader_mask_tex_coord_offset_location, 1);
1369 DCHECK_EQ(SamplerType2D, mask_sampler); 1308 DCHECK_EQ(SamplerType2D, mask_sampler);
1370 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); 1309 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1));
1371 1310
1372 gfx::RectF mask_uv_rect = quad->MaskUVRect(); 1311 gfx::RectF mask_uv_rect = quad->MaskUVRect();
1373 1312
1374 // Mask textures are oriented vertically flipped relative to the framebuffer 1313 // Mask textures are oriented vertically flipped relative to the framebuffer
1375 // and the RenderPass contents texture, so we flip the tex coords from the 1314 // and the RenderPass contents texture, so we flip the tex coords from the
1376 // RenderPass texture to find the mask texture coords. 1315 // RenderPass texture to find the mask texture coords.
1377 GLC(gl_, 1316 GLC(gl_,
1378 gl_->Uniform2f(shader_mask_tex_coord_offset_location, 1317 gl_->Uniform2f(shader_mask_tex_coord_offset_location,
1379 mask_uv_rect.x(), 1318 mask_uv_rect.x(),
1380 mask_uv_rect.bottom())); 1319 mask_uv_rect.bottom()));
1381 GLC(gl_, 1320 GLC(gl_,
1382 gl_->Uniform2f(shader_mask_tex_coord_scale_location, 1321 gl_->Uniform2f(shader_mask_tex_coord_scale_location,
1383 mask_uv_rect.width() / tex_scale_x, 1322 mask_uv_rect.width() / tex_scale_x,
1384 -mask_uv_rect.height() / tex_scale_y)); 1323 -mask_uv_rect.height() / tex_scale_y));
1324
1325 last_texture_unit = 1;
1385 } 1326 }
1386 1327
1387 if (shader_edge_location != -1) { 1328 if (shader_edge_location != -1) {
1388 float edge[24]; 1329 float edge[24];
1389 device_layer_edges.ToFloatArray(edge); 1330 device_layer_edges.ToFloatArray(edge);
1390 device_layer_bounds.ToFloatArray(&edge[12]); 1331 device_layer_bounds.ToFloatArray(&edge[12]);
1391 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge)); 1332 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge));
1392 } 1333 }
1393 1334
1394 if (shader_viewport_location != -1) { 1335 if (shader_viewport_location != -1) {
(...skipping 15 matching lines...) Expand all
1410 } 1351 }
1411 static const float kScale = 1.0f / 255.0f; 1352 static const float kScale = 1.0f / 255.0f;
1412 if (shader_color_offset_location != -1) { 1353 if (shader_color_offset_location != -1) {
1413 float offset[4]; 1354 float offset[4];
1414 for (int i = 0; i < 4; ++i) 1355 for (int i = 0; i < 4; ++i)
1415 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; 1356 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale;
1416 1357
1417 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset)); 1358 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset));
1418 } 1359 }
1419 1360
1361 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock;
1362 if (shader_backdrop_location != -1) {
1363 DCHECK(background_texture || background_image);
1364 DCHECK_NE(shader_backdrop_location, 0);
1365 DCHECK_NE(shader_backdrop_rect_location, 0);
1366
1367 GLC(gl_, gl_->Uniform1i(shader_backdrop_location, ++last_texture_unit));
1368
1369 GLC(gl_,
1370 gl_->Uniform4f(shader_backdrop_rect_location,
1371 background_rect.x(),
1372 background_rect.y(),
1373 background_rect.width(),
1374 background_rect.height()));
1375
1376 if (background_image) {
1377 GrTexture* texture = background_image->getTexture();
1378 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit));
1379 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
1380 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
1381 } else {
1382 shader_background_sampler_lock = make_scoped_ptr(
1383 new ResourceProvider::ScopedSamplerGL(resource_provider_,
1384 background_texture->id(),
1385 GL_TEXTURE0 + last_texture_unit,
1386 GL_LINEAR));
1387 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1388 shader_background_sampler_lock->target());
1389 }
1390 }
1391
1420 // Map device space quad to surface space. contents_device_transform has no 3d 1392 // Map device space quad to surface space. contents_device_transform has no 3d
1421 // component since it was flattened, so we don't need to project. 1393 // component since it was flattened, so we don't need to project.
1422 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse, 1394 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse,
1423 device_layer_edges.ToQuadF(), 1395 device_layer_edges.ToQuadF(),
1424 &clipped); 1396 &clipped);
1425 1397
1426 SetShaderOpacity(quad->opacity(), shader_alpha_location); 1398 SetShaderOpacity(quad->opacity(), shader_alpha_location);
1427 SetShaderQuadF(surface_quad, shader_quad_location); 1399 SetShaderQuadF(surface_quad, shader_quad_location);
1428 DrawQuadGeometry( 1400 DrawQuadGeometry(
1429 frame, quad->quadTransform(), quad->rect, shader_matrix_location); 1401 frame, quad->quadTransform(), quad->rect, shader_matrix_location);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 } 2317 }
2346 2318
2347 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, 2319 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
2348 int texture_id, 2320 int texture_id,
2349 const gfx::Rect& rect, 2321 const gfx::Rect& rect,
2350 const gfx::Transform& draw_matrix, 2322 const gfx::Transform& draw_matrix,
2351 bool flip_vertically) { 2323 bool flip_vertically) {
2352 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2324 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2353 gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right()); 2325 gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right());
2354 2326
2355 const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision); 2327 const RenderPassProgram* program =
2328 GetRenderPassProgram(tex_coord_precision, BlendModeNormal);
2356 SetUseProgram(program->program()); 2329 SetUseProgram(program->program());
2357 2330
2358 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2331 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
2359 2332
2360 if (flip_vertically) { 2333 if (flip_vertically) {
2361 GLC(gl_, 2334 GLC(gl_,
2362 gl_->Uniform4f(program->vertex_shader().tex_transform_location(), 2335 gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
2363 0.f, 2336 0.f,
2364 1.f, 2337 1.f,
2365 1.f, 2338 1.f,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 if (!solid_color_program_aa_.initialized()) { 2797 if (!solid_color_program_aa_.initialized()) {
2825 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); 2798 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize");
2826 solid_color_program_aa_.Initialize(output_surface_->context_provider(), 2799 solid_color_program_aa_.Initialize(output_surface_->context_provider(),
2827 TexCoordPrecisionNA, 2800 TexCoordPrecisionNA,
2828 SamplerTypeNA); 2801 SamplerTypeNA);
2829 } 2802 }
2830 return &solid_color_program_aa_; 2803 return &solid_color_program_aa_;
2831 } 2804 }
2832 2805
2833 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( 2806 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram(
2834 TexCoordPrecision precision) { 2807 TexCoordPrecision precision,
2808 BlendMode blend_mode) {
2835 DCHECK_GE(precision, 0); 2809 DCHECK_GE(precision, 0);
2836 DCHECK_LT(precision, NumTexCoordPrecisions); 2810 DCHECK_LT(precision, NumTexCoordPrecisions);
2837 RenderPassProgram* program = &render_pass_program_[precision]; 2811 DCHECK_GE(blend_mode, 0);
2812 DCHECK_LT(blend_mode, NumBlendModes);
2813 RenderPassProgram* program = &render_pass_program_[precision][blend_mode];
2838 if (!program->initialized()) { 2814 if (!program->initialized()) {
2839 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); 2815 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize");
2840 program->Initialize( 2816 program->Initialize(output_surface_->context_provider(),
2841 output_surface_->context_provider(), precision, SamplerType2D); 2817 precision,
2818 SamplerType2D,
2819 blend_mode);
2842 } 2820 }
2843 return program; 2821 return program;
2844 } 2822 }
2845 2823
2846 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( 2824 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
2847 TexCoordPrecision precision) { 2825 TexCoordPrecision precision,
2826 BlendMode blend_mode) {
2848 DCHECK_GE(precision, 0); 2827 DCHECK_GE(precision, 0);
2849 DCHECK_LT(precision, NumTexCoordPrecisions); 2828 DCHECK_LT(precision, NumTexCoordPrecisions);
2850 RenderPassProgramAA* program = &render_pass_program_aa_[precision]; 2829 DCHECK_GE(blend_mode, 0);
2830 DCHECK_LT(blend_mode, NumBlendModes);
2831 RenderPassProgramAA* program =
2832 &render_pass_program_aa_[precision][blend_mode];
2851 if (!program->initialized()) { 2833 if (!program->initialized()) {
2852 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); 2834 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize");
2853 program->Initialize( 2835 program->Initialize(output_surface_->context_provider(),
2854 output_surface_->context_provider(), precision, SamplerType2D); 2836 precision,
2837 SamplerType2D,
2838 blend_mode);
2855 } 2839 }
2856 return program; 2840 return program;
2857 } 2841 }
2858 2842
2859 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( 2843 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
2860 TexCoordPrecision precision) { 2844 TexCoordPrecision precision,
2845 BlendMode blend_mode) {
2861 DCHECK_GE(precision, 0); 2846 DCHECK_GE(precision, 0);
2862 DCHECK_LT(precision, NumTexCoordPrecisions); 2847 DCHECK_LT(precision, NumTexCoordPrecisions);
2863 RenderPassMaskProgram* program = &render_pass_mask_program_[precision]; 2848 DCHECK_GE(blend_mode, 0);
2849 DCHECK_LT(blend_mode, NumBlendModes);
2850 RenderPassMaskProgram* program =
2851 &render_pass_mask_program_[precision][blend_mode];
2864 if (!program->initialized()) { 2852 if (!program->initialized()) {
2865 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); 2853 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize");
2866 program->Initialize( 2854 program->Initialize(output_surface_->context_provider(),
2867 output_surface_->context_provider(), precision, SamplerType2D); 2855 precision,
2856 SamplerType2D,
2857 blend_mode);
2868 } 2858 }
2869 return program; 2859 return program;
2870 } 2860 }
2871 2861
2872 const GLRenderer::RenderPassMaskProgramAA* 2862 const GLRenderer::RenderPassMaskProgramAA*
2873 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { 2863 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision,
2864 BlendMode blend_mode) {
2874 DCHECK_GE(precision, 0); 2865 DCHECK_GE(precision, 0);
2875 DCHECK_LT(precision, NumTexCoordPrecisions); 2866 DCHECK_LT(precision, NumTexCoordPrecisions);
2876 RenderPassMaskProgramAA* program = &render_pass_mask_program_aa_[precision]; 2867 DCHECK_GE(blend_mode, 0);
2868 DCHECK_LT(blend_mode, NumBlendModes);
2869 RenderPassMaskProgramAA* program =
2870 &render_pass_mask_program_aa_[precision][blend_mode];
2877 if (!program->initialized()) { 2871 if (!program->initialized()) {
2878 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); 2872 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize");
2879 program->Initialize( 2873 program->Initialize(output_surface_->context_provider(),
2880 output_surface_->context_provider(), precision, SamplerType2D); 2874 precision,
2875 SamplerType2D,
2876 blend_mode);
2881 } 2877 }
2882 return program; 2878 return program;
2883 } 2879 }
2884 2880
2885 const GLRenderer::RenderPassColorMatrixProgram* 2881 const GLRenderer::RenderPassColorMatrixProgram*
2886 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { 2882 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision,
2883 BlendMode blend_mode) {
2887 DCHECK_GE(precision, 0); 2884 DCHECK_GE(precision, 0);
2888 DCHECK_LT(precision, NumTexCoordPrecisions); 2885 DCHECK_LT(precision, NumTexCoordPrecisions);
2886 DCHECK_GE(blend_mode, 0);
2887 DCHECK_LT(blend_mode, NumBlendModes);
2889 RenderPassColorMatrixProgram* program = 2888 RenderPassColorMatrixProgram* program =
2890 &render_pass_color_matrix_program_[precision]; 2889 &render_pass_color_matrix_program_[precision][blend_mode];
2891 if (!program->initialized()) { 2890 if (!program->initialized()) {
2892 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); 2891 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize");
2893 program->Initialize( 2892 program->Initialize(output_surface_->context_provider(),
2894 output_surface_->context_provider(), precision, SamplerType2D); 2893 precision,
2894 SamplerType2D,
2895 blend_mode);
2895 } 2896 }
2896 return program; 2897 return program;
2897 } 2898 }
2898 2899
2899 const GLRenderer::RenderPassColorMatrixProgramAA* 2900 const GLRenderer::RenderPassColorMatrixProgramAA*
2900 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { 2901 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision,
2902 BlendMode blend_mode) {
2901 DCHECK_GE(precision, 0); 2903 DCHECK_GE(precision, 0);
2902 DCHECK_LT(precision, NumTexCoordPrecisions); 2904 DCHECK_LT(precision, NumTexCoordPrecisions);
2905 DCHECK_GE(blend_mode, 0);
2906 DCHECK_LT(blend_mode, NumBlendModes);
2903 RenderPassColorMatrixProgramAA* program = 2907 RenderPassColorMatrixProgramAA* program =
2904 &render_pass_color_matrix_program_aa_[precision]; 2908 &render_pass_color_matrix_program_aa_[precision][blend_mode];
2905 if (!program->initialized()) { 2909 if (!program->initialized()) {
2906 TRACE_EVENT0("cc", 2910 TRACE_EVENT0("cc",
2907 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); 2911 "GLRenderer::renderPassColorMatrixProgramAA::initialize");
2908 program->Initialize( 2912 program->Initialize(output_surface_->context_provider(),
2909 output_surface_->context_provider(), precision, SamplerType2D); 2913 precision,
2914 SamplerType2D,
2915 blend_mode);
2910 } 2916 }
2911 return program; 2917 return program;
2912 } 2918 }
2913 2919
2914 const GLRenderer::RenderPassMaskColorMatrixProgram* 2920 const GLRenderer::RenderPassMaskColorMatrixProgram*
2915 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { 2921 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
2922 BlendMode blend_mode) {
2916 DCHECK_GE(precision, 0); 2923 DCHECK_GE(precision, 0);
2917 DCHECK_LT(precision, NumTexCoordPrecisions); 2924 DCHECK_LT(precision, NumTexCoordPrecisions);
2925 DCHECK_GE(blend_mode, 0);
2926 DCHECK_LT(blend_mode, NumBlendModes);
2918 RenderPassMaskColorMatrixProgram* program = 2927 RenderPassMaskColorMatrixProgram* program =
2919 &render_pass_mask_color_matrix_program_[precision]; 2928 &render_pass_mask_color_matrix_program_[precision][blend_mode];
2920 if (!program->initialized()) { 2929 if (!program->initialized()) {
2921 TRACE_EVENT0("cc", 2930 TRACE_EVENT0("cc",
2922 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); 2931 "GLRenderer::renderPassMaskColorMatrixProgram::initialize");
2923 program->Initialize( 2932 program->Initialize(output_surface_->context_provider(),
2924 output_surface_->context_provider(), precision, SamplerType2D); 2933 precision,
2934 SamplerType2D,
2935 blend_mode);
2925 } 2936 }
2926 return program; 2937 return program;
2927 } 2938 }
2928 2939
2929 const GLRenderer::RenderPassMaskColorMatrixProgramAA* 2940 const GLRenderer::RenderPassMaskColorMatrixProgramAA*
2930 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { 2941 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
2942 BlendMode blend_mode) {
2931 DCHECK_GE(precision, 0); 2943 DCHECK_GE(precision, 0);
2932 DCHECK_LT(precision, NumTexCoordPrecisions); 2944 DCHECK_LT(precision, NumTexCoordPrecisions);
2945 DCHECK_GE(blend_mode, 0);
2946 DCHECK_LT(blend_mode, NumBlendModes);
2933 RenderPassMaskColorMatrixProgramAA* program = 2947 RenderPassMaskColorMatrixProgramAA* program =
2934 &render_pass_mask_color_matrix_program_aa_[precision]; 2948 &render_pass_mask_color_matrix_program_aa_[precision][blend_mode];
2935 if (!program->initialized()) { 2949 if (!program->initialized()) {
2936 TRACE_EVENT0("cc", 2950 TRACE_EVENT0("cc",
2937 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); 2951 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize");
2938 program->Initialize( 2952 program->Initialize(output_surface_->context_provider(),
2939 output_surface_->context_provider(), precision, SamplerType2D); 2953 precision,
2954 SamplerType2D,
2955 blend_mode);
2940 } 2956 }
2941 return program; 2957 return program;
2942 } 2958 }
2943 2959
2944 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( 2960 const GLRenderer::TileProgram* GLRenderer::GetTileProgram(
2945 TexCoordPrecision precision, 2961 TexCoordPrecision precision,
2946 SamplerType sampler) { 2962 SamplerType sampler) {
2947 DCHECK_GE(precision, 0); 2963 DCHECK_GE(precision, 0);
2948 DCHECK_LT(precision, NumTexCoordPrecisions); 2964 DCHECK_LT(precision, NumTexCoordPrecisions);
2949 DCHECK_GE(sampler, 0); 2965 DCHECK_GE(sampler, 0);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 3171
3156 for (int i = 0; i < NumTexCoordPrecisions; ++i) { 3172 for (int i = 0; i < NumTexCoordPrecisions; ++i) {
3157 for (int j = 0; j < NumSamplerTypes; ++j) { 3173 for (int j = 0; j < NumSamplerTypes; ++j) {
3158 tile_program_[i][j].Cleanup(gl_); 3174 tile_program_[i][j].Cleanup(gl_);
3159 tile_program_opaque_[i][j].Cleanup(gl_); 3175 tile_program_opaque_[i][j].Cleanup(gl_);
3160 tile_program_swizzle_[i][j].Cleanup(gl_); 3176 tile_program_swizzle_[i][j].Cleanup(gl_);
3161 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); 3177 tile_program_swizzle_opaque_[i][j].Cleanup(gl_);
3162 tile_program_aa_[i][j].Cleanup(gl_); 3178 tile_program_aa_[i][j].Cleanup(gl_);
3163 tile_program_swizzle_aa_[i][j].Cleanup(gl_); 3179 tile_program_swizzle_aa_[i][j].Cleanup(gl_);
3164 } 3180 }
3165 3181 for (int j = 0; j < NumBlendModes; j++) {
3166 render_pass_mask_program_[i].Cleanup(gl_); 3182 render_pass_mask_program_[i][j].Cleanup(gl_);
3167 render_pass_program_[i].Cleanup(gl_); 3183 render_pass_program_[i][j].Cleanup(gl_);
3168 render_pass_mask_program_aa_[i].Cleanup(gl_); 3184 render_pass_mask_program_aa_[i][j].Cleanup(gl_);
3169 render_pass_program_aa_[i].Cleanup(gl_); 3185 render_pass_program_aa_[i][j].Cleanup(gl_);
3170 render_pass_color_matrix_program_[i].Cleanup(gl_); 3186 render_pass_color_matrix_program_[i][j].Cleanup(gl_);
3171 render_pass_mask_color_matrix_program_aa_[i].Cleanup(gl_); 3187 render_pass_mask_color_matrix_program_aa_[i][j].Cleanup(gl_);
3172 render_pass_color_matrix_program_aa_[i].Cleanup(gl_); 3188 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_);
3173 render_pass_mask_color_matrix_program_[i].Cleanup(gl_); 3189 render_pass_mask_color_matrix_program_[i][j].Cleanup(gl_);
3190 }
3174 3191
3175 texture_program_[i].Cleanup(gl_); 3192 texture_program_[i].Cleanup(gl_);
3176 nonpremultiplied_texture_program_[i].Cleanup(gl_); 3193 nonpremultiplied_texture_program_[i].Cleanup(gl_);
3177 texture_background_program_[i].Cleanup(gl_); 3194 texture_background_program_[i].Cleanup(gl_);
3178 nonpremultiplied_texture_background_program_[i].Cleanup(gl_); 3195 nonpremultiplied_texture_background_program_[i].Cleanup(gl_);
3179 texture_io_surface_program_[i].Cleanup(gl_); 3196 texture_io_surface_program_[i].Cleanup(gl_);
3180 3197
3181 video_yuv_program_[i].Cleanup(gl_); 3198 video_yuv_program_[i].Cleanup(gl_);
3182 video_yuva_program_[i].Cleanup(gl_); 3199 video_yuva_program_[i].Cleanup(gl_);
3183 video_stream_texture_program_[i].Cleanup(gl_); 3200 video_stream_texture_program_[i].Cleanup(gl_);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 context_support_->ScheduleOverlayPlane( 3289 context_support_->ScheduleOverlayPlane(
3273 overlay.plane_z_order, 3290 overlay.plane_z_order,
3274 overlay.transform, 3291 overlay.transform,
3275 pending_overlay_resources_.back()->texture_id(), 3292 pending_overlay_resources_.back()->texture_id(),
3276 overlay.display_rect, 3293 overlay.display_rect,
3277 overlay.uv_rect); 3294 overlay.uv_rect);
3278 } 3295 }
3279 } 3296 }
3280 3297
3281 } // namespace cc 3298 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698