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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp

Issue 2559013002: Add ColorBehavior to blink::Image draw methods (Closed)
Patch Set: Rebase Created 4 years 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 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 return; 804 return;
805 805
806 const FloatRect src = srcPtr ? *srcPtr : image->rect(); 806 const FloatRect src = srcPtr ? *srcPtr : image->rect();
807 807
808 SkPaint imagePaint = immutableState()->fillPaint(); 808 SkPaint imagePaint = immutableState()->fillPaint();
809 imagePaint.setBlendMode(op); 809 imagePaint.setBlendMode(op);
810 imagePaint.setColor(SK_ColorBLACK); 810 imagePaint.setColor(SK_ColorBLACK);
811 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); 811 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src));
812 imagePaint.setAntiAlias(shouldAntialias()); 812 imagePaint.setAntiAlias(shouldAntialias());
813 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, 813 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation,
814 Image::ClampImageToSourceRect); 814 Image::ClampImageToSourceRect, m_colorBehavior);
815 m_paintController.setImagePainted(); 815 m_paintController.setImagePainted();
816 } 816 }
817 817
818 void GraphicsContext::drawImageRRect( 818 void GraphicsContext::drawImageRRect(
819 Image* image, 819 Image* image,
820 const FloatRoundedRect& dest, 820 const FloatRoundedRect& dest,
821 const FloatRect& srcRect, 821 const FloatRect& srcRect,
822 SkBlendMode op, 822 SkBlendMode op,
823 RespectImageOrientationEnum respectOrientation) { 823 RespectImageOrientationEnum respectOrientation) {
824 if (contextDisabled() || !image) 824 if (contextDisabled() || !image)
(...skipping 15 matching lines...) Expand all
840 imagePaint.setColor(SK_ColorBLACK); 840 imagePaint.setColor(SK_ColorBLACK);
841 imagePaint.setFilterQuality( 841 imagePaint.setFilterQuality(
842 computeFilterQuality(image, dest.rect(), srcRect)); 842 computeFilterQuality(image, dest.rect(), srcRect));
843 imagePaint.setAntiAlias(shouldAntialias()); 843 imagePaint.setAntiAlias(shouldAntialias());
844 844
845 bool useShader = (visibleSrc == srcRect) && 845 bool useShader = (visibleSrc == srcRect) &&
846 (respectOrientation == DoNotRespectImageOrientation); 846 (respectOrientation == DoNotRespectImageOrientation);
847 if (useShader) { 847 if (useShader) {
848 const SkMatrix localMatrix = SkMatrix::MakeRectToRect( 848 const SkMatrix localMatrix = SkMatrix::MakeRectToRect(
849 visibleSrc, dest.rect(), SkMatrix::kFill_ScaleToFit); 849 visibleSrc, dest.rect(), SkMatrix::kFill_ScaleToFit);
850 useShader = image->applyShader(imagePaint, localMatrix); 850 useShader = image->applyShader(imagePaint, localMatrix, m_colorBehavior);
851 } 851 }
852 852
853 if (useShader) { 853 if (useShader) {
854 // Shader-based fast path. 854 // Shader-based fast path.
855 m_canvas->drawRRect(dest, imagePaint); 855 m_canvas->drawRRect(dest, imagePaint);
856 } else { 856 } else {
857 // Clip-based fallback. 857 // Clip-based fallback.
858 SkAutoCanvasRestore autoRestore(m_canvas, true); 858 SkAutoCanvasRestore autoRestore(m_canvas, true);
859 m_canvas->clipRRect(dest, imagePaint.isAntiAlias()); 859 m_canvas->clipRRect(dest, imagePaint.isAntiAlias());
860 image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation, 860 image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation,
861 Image::ClampImageToSourceRect); 861 Image::ClampImageToSourceRect, m_colorBehavior);
862 } 862 }
863 863
864 m_paintController.setImagePainted(); 864 m_paintController.setImagePainted();
865 } 865 }
866 866
867 SkFilterQuality GraphicsContext::computeFilterQuality( 867 SkFilterQuality GraphicsContext::computeFilterQuality(
868 Image* image, 868 Image* image,
869 const FloatRect& dest, 869 const FloatRect& dest,
870 const FloatRect& src) const { 870 const FloatRect& src) const {
871 InterpolationQuality resampling; 871 InterpolationQuality resampling;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 static const SkPMColor colors[] = { 1413 static const SkPMColor colors[] = {
1414 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red 1414 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red
1415 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray 1415 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray
1416 }; 1416 };
1417 1417
1418 return colors[index]; 1418 return colors[index];
1419 } 1419 }
1420 #endif 1420 #endif
1421 1421
1422 } // namespace blink 1422 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698