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

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

Issue 201513003: Implement InterpolationMedium to filter animated images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor ); 1020 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor );
1021 } 1021 }
1022 1022
1023 void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperat or op, RespectImageOrientationEnum shouldRespectImageOrientation) 1023 void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperat or op, RespectImageOrientationEnum shouldRespectImageOrientation)
1024 { 1024 {
1025 if (!image) 1025 if (!image)
1026 return; 1026 return;
1027 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint( ), FloatSize(image->size())), op, shouldRespectImageOrientation); 1027 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint( ), FloatSize(image->size())), op, shouldRespectImageOrientation);
1028 } 1028 }
1029 1029
1030 void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperato r op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQual ityScale) 1030 void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperato r op, RespectImageOrientationEnum shouldRespectImageOrientation, InterpolationQu ality interpolationQuality)
1031 { 1031 {
1032 if (!image) 1032 if (!image)
1033 return; 1033 return;
1034 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size ())), op, shouldRespectImageOrientation, useLowQualityScale); 1034 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size ())), op, shouldRespectImageOrientation, interpolationQuality);
1035 } 1035 }
1036 1036
1037 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageO rientation, bool useLowQualityScale) 1037 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageO rientation, InterpolationQuality interpolationQuality)
1038 { 1038 {
1039 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag eOrientation, useLowQualityScale); 1039 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag eOrientation, interpolationQuality);
1040 } 1040 }
1041 1041
1042 void GraphicsContext::drawImage(Image* image, const FloatRect& dest) 1042 void GraphicsContext::drawImage(Image* image, const FloatRect& dest)
1043 { 1043 {
1044 if (!image) 1044 if (!image)
1045 return; 1045 return;
1046 drawImage(image, dest, FloatRect(IntRect(IntPoint(), image->size()))); 1046 drawImage(image, dest, FloatRect(IntRect(IntPoint(), image->size())));
1047 } 1047 }
1048 1048
1049 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, WebBlendMode blendMode, RespectImageOrientation Enum shouldRespectImageOrientation, bool useLowQualityScale) 1049 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, WebBlendMode blendMode, RespectImageOrientation Enum shouldRespectImageOrientation, InterpolationQuality interpolationQuality)
1050 { if (paintingDisabled() || !image)
1051 return;
1052
1053 InterpolationQuality previousInterpolationQuality = InterpolationDefault;
1054
1055 if (useLowQualityScale) {
1056 previousInterpolationQuality = imageInterpolationQuality();
1057 setImageInterpolationQuality(InterpolationLow);
1058 }
1059
1060 image->draw(this, dest, src, op, blendMode, shouldRespectImageOrientation);
1061
1062 if (useLowQualityScale)
1063 setImageInterpolationQuality(previousInterpolationQuality);
1064 }
1065
1066 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons t IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, bool useLow QualityScale, WebBlendMode blendMode, const IntSize& repeatSpacing)
1067 { 1050 {
1068 if (paintingDisabled() || !image) 1051 if (paintingDisabled() || !image)
1069 return; 1052 return;
1070 1053
1071 if (useLowQualityScale) { 1054 if (interpolationQuality != InterpolationDefault) {
Stephen White 2014/03/18 17:26:43 Shouldn't this check be against imageInterpolation
Alpha Left Google 2014/03/18 22:59:13 Done.
1072 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1055 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1073 setImageInterpolationQuality(InterpolationLow); 1056 setImageInterpolationQuality(interpolationQuality);
1057 image->draw(this, dest, src, op, blendMode, shouldRespectImageOrientatio n);
1058 setImageInterpolationQuality(previousInterpolationQuality);
1059 } else {
1060 image->draw(this, dest, src, op, blendMode, shouldRespectImageOrientatio n);
1061 }
1062 }
1063
1064 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons t IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, Interpolati onQuality interpolationQuality, WebBlendMode blendMode, const IntSize& repeatSpa cing)
1065 {
1066 if (paintingDisabled() || !image)
1067 return;
1068
1069 if (interpolationQuality != InterpolationDefault) {
Stephen White 2014/03/18 17:26:43 Same here.
Alpha Left Google 2014/03/18 22:59:13 Done.
1070 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1071 setImageInterpolationQuality(interpolationQuality);
1074 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing); 1072 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing);
1075 setImageInterpolationQuality(previousInterpolationQuality); 1073 setImageInterpolationQuality(previousInterpolationQuality);
1076 } else { 1074 } else {
1077 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing); 1075 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing);
1078 } 1076 }
1079 } 1077 }
1080 1078
1081 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In tRect& srcRect, 1079 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In tRect& srcRect,
1082 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu le, CompositeOperator op, bool useLowQualityScale) 1080 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu le, CompositeOperator op, InterpolationQuality interpolationQuality)
1083 { 1081 {
1084 if (paintingDisabled() || !image) 1082 if (paintingDisabled() || !image)
1085 return; 1083 return;
1086 1084
1087 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { 1085 if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
1088 // Just do a scale. 1086 // Just do a scale.
1089 drawImage(image, dest, srcRect, op); 1087 drawImage(image, dest, srcRect, op);
1090 return; 1088 return;
1091 } 1089 }
1092 1090
1093 if (useLowQualityScale) { 1091 if (interpolationQuality != InterpolationDefault) {
Stephen White 2014/03/18 17:26:43 Same here.
Alpha Left Google 2014/03/18 22:59:13 Done.
1094 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1092 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1095 setImageInterpolationQuality(InterpolationLow); 1093 setImageInterpolationQuality(interpolationQuality);
1096 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ; 1094 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1097 setImageInterpolationQuality(previousInterpolationQuality); 1095 setImageInterpolationQuality(previousInterpolationQuality);
1098 } else { 1096 } else {
1099 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ; 1097 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1100 } 1098 }
1101 } 1099 }
1102 1100
1103 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& p, Com positeOperator op, WebBlendMode blendMode) 1101 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& p, Com positeOperator op, WebBlendMode blendMode)
1104 { 1102 {
1105 if (!image) 1103 if (!image)
1106 return; 1104 return;
1107 drawImageBuffer(image, FloatRect(IntRect(p, image->size())), FloatRect(Float Point(), FloatSize(image->size())), op, blendMode); 1105 drawImageBuffer(image, FloatRect(IntRect(p, image->size())), FloatRect(Float Point(), FloatSize(image->size())), op, blendMode);
1108 } 1106 }
1109 1107
1110 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& r, Comp ositeOperator op, WebBlendMode blendMode, bool useLowQualityScale) 1108 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& r, Comp ositeOperator op, WebBlendMode blendMode, InterpolationQuality interpolationQual ity)
1111 { 1109 {
1112 if (!image) 1110 if (!image)
1113 return; 1111 return;
1114 drawImageBuffer(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image ->size())), op, blendMode, useLowQualityScale); 1112 drawImageBuffer(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image ->size())), op, blendMode, interpolationQuality);
1115 } 1113 }
1116 1114
1117 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode) 1115 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode)
1118 { 1116 {
1119 drawImageBuffer(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(s rcRect), op, blendMode); 1117 drawImageBuffer(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(s rcRect), op, blendMode);
1120 } 1118 }
1121 1119
1122 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& dest, c onst IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode, bool useLow QualityScale) 1120 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& dest, c onst IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode, Interpolati onQuality interpolationQuality)
1123 { 1121 {
1124 drawImageBuffer(image, FloatRect(dest), FloatRect(srcRect), op, blendMode, u seLowQualityScale); 1122 drawImageBuffer(image, FloatRect(dest), FloatRect(srcRect), op, blendMode, i nterpolationQuality);
1125 } 1123 }
1126 1124
1127 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest) 1125 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest)
1128 { 1126 {
1129 if (!image) 1127 if (!image)
1130 return; 1128 return;
1131 drawImageBuffer(image, dest, FloatRect(IntRect(IntPoint(), image->size()))); 1129 drawImageBuffer(image, dest, FloatRect(IntRect(IntPoint(), image->size())));
1132 } 1130 }
1133 1131
1134 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode, bool useLow QualityScale) 1132 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode, Interpolati onQuality interpolationQuality)
1135 { 1133 {
1136 if (paintingDisabled() || !image) 1134 if (paintingDisabled() || !image)
1137 return; 1135 return;
1138 1136
1139 if (useLowQualityScale) { 1137 if (interpolationQuality != InterpolationDefault) {
Stephen White 2014/03/18 17:26:43 Same here. (Tangentially, I wonder if these functi
Alpha Left Google 2014/03/18 22:59:13 Done. Yeah I'll leave that refactoring as a separa
1140 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1138 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1141 setImageInterpolationQuality(InterpolationLow); 1139 setImageInterpolationQuality(interpolationQuality);
1142 image->draw(this, dest, src, op, blendMode, useLowQualityScale); 1140 image->draw(this, dest, src, op, blendMode, interpolationQuality);
Stephen White 2014/03/18 17:26:43 (Not new to this patch, but it seems odd that we h
Alpha Left Google 2014/03/18 22:59:13 Indeed. :(
1143 setImageInterpolationQuality(previousInterpolationQuality); 1141 setImageInterpolationQuality(previousInterpolationQuality);
1144 } else { 1142 } else {
1145 image->draw(this, dest, src, op, blendMode, useLowQualityScale); 1143 image->draw(this, dest, src, op, blendMode, interpolationQuality);
1146 } 1144 }
1147 } 1145 }
1148 1146
1149 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y) 1147 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y)
1150 { 1148 {
1151 if (paintingDisabled()) 1149 if (paintingDisabled())
1152 return; 1150 return;
1153 1151
1154 m_canvas->writePixels(info, pixels, rowBytes, x, y); 1152 m_canvas->writePixels(info, pixels, rowBytes, x, y);
1155 1153
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1913
1916 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1914 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1917 { 1915 {
1918 if (m_trackTextRegion) { 1916 if (m_trackTextRegion) {
1919 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1917 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1920 m_textRegion.join(textRect); 1918 m_textRegion.join(textRect);
1921 } 1919 }
1922 } 1920 }
1923 1921
1924 } 1922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698