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

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: only ode change 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)
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);
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)
1038 { 1038 {
1039 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag eOrientation, useLowQualityScale); 1039 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag eOrientation);
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)
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;
1053 image->draw(this, dest, src, op, blendMode, shouldRespectImageOrientation);
1054 }
1070 1055
1071 if (useLowQualityScale) { 1056 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons t IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, WebBlendMod e blendMode, const IntSize& repeatSpacing)
1072 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1057 {
1073 setImageInterpolationQuality(InterpolationLow); 1058 if (paintingDisabled() || !image)
1074 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing); 1059 return;
1075 setImageInterpolationQuality(previousInterpolationQuality); 1060 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repeatSp acing);
1076 } else {
1077 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode, repe atSpacing);
1078 }
1079 } 1061 }
1080 1062
1081 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In tRect& srcRect, 1063 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) 1064 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu le, CompositeOperator op)
1083 { 1065 {
1084 if (paintingDisabled() || !image) 1066 if (paintingDisabled() || !image)
1085 return; 1067 return;
1086 1068
1087 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { 1069 if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
1088 // Just do a scale. 1070 // Just do a scale.
1089 drawImage(image, dest, srcRect, op); 1071 drawImage(image, dest, srcRect, op);
1090 return; 1072 return;
1091 } 1073 }
1092 1074
1093 if (useLowQualityScale) { 1075 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op);
1094 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1095 setImageInterpolationQuality(InterpolationLow);
1096 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1097 setImageInterpolationQuality(previousInterpolationQuality);
1098 } else {
1099 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1100 }
1101 } 1076 }
1102 1077
1103 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& p, Com positeOperator op, WebBlendMode blendMode) 1078 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& p, Com positeOperator op, WebBlendMode blendMode)
1104 { 1079 {
1105 if (!image) 1080 if (!image)
1106 return; 1081 return;
1107 drawImageBuffer(image, FloatRect(IntRect(p, image->size())), FloatRect(Float Point(), FloatSize(image->size())), op, blendMode); 1082 drawImageBuffer(image, FloatRect(IntRect(p, image->size())), FloatRect(Float Point(), FloatSize(image->size())), op, blendMode);
1108 } 1083 }
1109 1084
1110 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& r, Comp ositeOperator op, WebBlendMode blendMode, bool useLowQualityScale) 1085 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& r, Comp ositeOperator op, WebBlendMode blendMode)
1111 { 1086 {
1112 if (!image) 1087 if (!image)
1113 return; 1088 return;
1114 drawImageBuffer(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image ->size())), op, blendMode, useLowQualityScale); 1089 drawImageBuffer(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image ->size())), op, blendMode);
1115 } 1090 }
1116 1091
1117 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode) 1092 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode)
1118 { 1093 {
1119 drawImageBuffer(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(s rcRect), op, blendMode); 1094 drawImageBuffer(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(s rcRect), op, blendMode);
1120 } 1095 }
1121 1096
1122 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& dest, c onst IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode, bool useLow QualityScale) 1097 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& dest, c onst IntRect& srcRect, CompositeOperator op, WebBlendMode blendMode)
1123 { 1098 {
1124 drawImageBuffer(image, FloatRect(dest), FloatRect(srcRect), op, blendMode, u seLowQualityScale); 1099 drawImageBuffer(image, FloatRect(dest), FloatRect(srcRect), op, blendMode);
1125 } 1100 }
1126 1101
1127 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest) 1102 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest)
1128 { 1103 {
1129 if (!image) 1104 if (!image)
1130 return; 1105 return;
1131 drawImageBuffer(image, dest, FloatRect(IntRect(IntPoint(), image->size()))); 1106 drawImageBuffer(image, dest, FloatRect(IntRect(IntPoint(), image->size())));
1132 } 1107 }
1133 1108
1134 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode, bool useLow QualityScale) 1109 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode)
1135 { 1110 {
1136 if (paintingDisabled() || !image) 1111 if (paintingDisabled() || !image)
1137 return; 1112 return;
1138 1113 image->draw(this, dest, src, op, blendMode);
1139 if (useLowQualityScale) {
1140 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1141 setImageInterpolationQuality(InterpolationLow);
1142 image->draw(this, dest, src, op, blendMode, useLowQualityScale);
1143 setImageInterpolationQuality(previousInterpolationQuality);
1144 } else {
1145 image->draw(this, dest, src, op, blendMode, useLowQualityScale);
1146 }
1147 } 1114 }
1148 1115
1149 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y) 1116 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y)
1150 { 1117 {
1151 if (paintingDisabled()) 1118 if (paintingDisabled())
1152 return; 1119 return;
1153 1120
1154 m_canvas->writePixels(info, pixels, rowBytes, x, y); 1121 m_canvas->writePixels(info, pixels, rowBytes, x, y);
1155 1122
1156 if (m_trackOpaqueRegion) { 1123 if (m_trackOpaqueRegion) {
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1882
1916 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1883 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1917 { 1884 {
1918 if (m_trackTextRegion) { 1885 if (m_trackTextRegion) {
1919 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1886 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1920 m_textRegion.join(textRect); 1887 m_textRegion.join(textRect);
1921 } 1888 }
1922 } 1889 }
1923 1890
1924 } 1891 }
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | Source/platform/graphics/GraphicsContextState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698