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

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

Issue 16357011: Remove support for -webkit-color-correction (which we've never supported on (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: resolve merge conflicts, obey brace style changes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return; 183 return;
184 184
185 canvas()->endCommentGroup(); 185 canvas()->endCommentGroup();
186 186
187 ASSERT(m_annotationCount > 0); 187 ASSERT(m_annotationCount > 0);
188 #if !ASSERT_DISABLED 188 #if !ASSERT_DISABLED
189 --m_annotationCount; 189 --m_annotationCount;
190 #endif 190 #endif
191 } 191 }
192 192
193 void GraphicsContext::setStrokeColor(const Color& color, ColorSpace colorSpace) 193 void GraphicsContext::setStrokeColor(const Color& color)
194 { 194 {
195 m_state->m_strokeColor = color; 195 m_state->m_strokeColor = color;
196 m_state->m_strokeColorSpace = colorSpace;
197 m_state->m_strokeGradient.clear(); 196 m_state->m_strokeGradient.clear();
198 m_state->m_strokePattern.clear(); 197 m_state->m_strokePattern.clear();
199 } 198 }
200 199
201 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) 200 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
202 { 201 {
203 if (paintingDisabled()) 202 if (paintingDisabled())
204 return; 203 return;
205 204
206 ASSERT(pattern); 205 ASSERT(pattern);
207 if (!pattern) { 206 if (!pattern) {
208 setStrokeColor(Color::black, ColorSpaceDeviceRGB); 207 setStrokeColor(Color::black);
209 return; 208 return;
210 } 209 }
211 m_state->m_strokeGradient.clear(); 210 m_state->m_strokeGradient.clear();
212 m_state->m_strokePattern = pattern; 211 m_state->m_strokePattern = pattern;
213 } 212 }
214 213
215 void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient) 214 void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
216 { 215 {
217 if (paintingDisabled()) 216 if (paintingDisabled())
218 return; 217 return;
219 218
220 ASSERT(gradient); 219 ASSERT(gradient);
221 if (!gradient) { 220 if (!gradient) {
222 setStrokeColor(Color::black, ColorSpaceDeviceRGB); 221 setStrokeColor(Color::black);
223 return; 222 return;
224 } 223 }
225 m_state->m_strokeGradient = gradient; 224 m_state->m_strokeGradient = gradient;
226 m_state->m_strokePattern.clear(); 225 m_state->m_strokePattern.clear();
227 } 226 }
228 227
229 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) 228 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
230 { 229 {
231 // FIXME: This is lifted directly off SkiaSupport, lines 49-74 230 // FIXME: This is lifted directly off SkiaSupport, lines 49-74
232 // so it is not guaranteed to work correctly. 231 // so it is not guaranteed to work correctly.
(...skipping 10 matching lines...) Expand all
243 SkScalar* intervals = new SkScalar[count]; 242 SkScalar* intervals = new SkScalar[count];
244 243
245 for (unsigned i = 0; i < count; i++) 244 for (unsigned i = 0; i < count; i++)
246 intervals[i] = dashes[i % dashLength]; 245 intervals[i] = dashes[i % dashLength];
247 246
248 setDashPathEffect(new SkDashPathEffect(intervals, count, dashOffset)); 247 setDashPathEffect(new SkDashPathEffect(intervals, count, dashOffset));
249 248
250 delete[] intervals; 249 delete[] intervals;
251 } 250 }
252 251
253 void GraphicsContext::setFillColor(const Color& color, ColorSpace colorSpace) 252 void GraphicsContext::setFillColor(const Color& color)
254 { 253 {
255 m_state->m_fillColor = color; 254 m_state->m_fillColor = color;
256 m_state->m_fillColorSpace = colorSpace;
257 m_state->m_fillGradient.clear(); 255 m_state->m_fillGradient.clear();
258 m_state->m_fillPattern.clear(); 256 m_state->m_fillPattern.clear();
259 } 257 }
260 258
261 void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern) 259 void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
262 { 260 {
263 if (paintingDisabled()) 261 if (paintingDisabled())
264 return; 262 return;
265 263
266 ASSERT(pattern); 264 ASSERT(pattern);
267 if (!pattern) { 265 if (!pattern) {
268 setFillColor(Color::black, ColorSpaceDeviceRGB); 266 setFillColor(Color::black);
269 return; 267 return;
270 } 268 }
271 m_state->m_fillGradient.clear(); 269 m_state->m_fillGradient.clear();
272 m_state->m_fillPattern = pattern; 270 m_state->m_fillPattern = pattern;
273 } 271 }
274 272
275 void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient) 273 void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
276 { 274 {
277 if (paintingDisabled()) 275 if (paintingDisabled())
278 return; 276 return;
279 277
280 ASSERT(gradient); 278 ASSERT(gradient);
281 if (!gradient) { 279 if (!gradient) {
282 setFillColor(Color::black, ColorSpaceDeviceRGB); 280 setFillColor(Color::black);
283 return; 281 return;
284 } 282 }
285 m_state->m_fillGradient = gradient; 283 m_state->m_fillGradient = gradient;
286 m_state->m_fillPattern.clear(); 284 m_state->m_fillPattern.clear();
287 } 285 }
288 286
289 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color & color, DrawLooper::ShadowAlphaMode shadowAlphaMode) 287 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color & color, DrawLooper::ShadowAlphaMode shadowAlphaMode)
290 { 288 {
291 if (paintingDisabled()) 289 if (paintingDisabled())
292 return; 290 return;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 948
951 bidiRun = bidiRun->next(); 949 bidiRun = bidiRun->next();
952 // FIXME: Have Font::drawText return the width of what it drew so that w e don't have to re-measure here. 950 // FIXME: Have Font::drawText return the width of what it drew so that w e don't have to re-measure here.
953 if (bidiRun) 951 if (bidiRun)
954 currPoint.move(font.width(subrun), 0); 952 currPoint.move(font.width(subrun), 0);
955 } 953 }
956 954
957 bidiRuns.deleteRuns(); 955 bidiRuns.deleteRuns();
958 } 956 }
959 957
960 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const FloatPoint& point, int h, const Color& backgroundColor, ColorSpace colorS pace, int from, int to) 958 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const FloatPoint& point, int h, const Color& backgroundColor, int from, int to)
961 { 959 {
962 if (paintingDisabled()) 960 if (paintingDisabled())
963 return; 961 return;
964 962
965 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor , colorSpace); 963 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor );
966 } 964 }
967 965
968 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op, RespectImageOrientationEnum shouldRespectImag eOrientation) 966 void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperat or op, RespectImageOrientationEnum shouldRespectImageOrientation)
969 { 967 {
970 if (!image) 968 if (!image)
971 return; 969 return;
972 drawImage(image, styleColorSpace, FloatRect(IntRect(p, image->size())), Floa tRect(FloatPoint(), FloatSize(image->size())), op, shouldRespectImageOrientation ); 970 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint( ), FloatSize(image->size())), op, shouldRespectImageOrientation);
973 } 971 }
974 972
975 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, RespectImageOrientationEnum shouldRespectImage Orientation, bool useLowQualityScale) 973 void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperato r op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQual ityScale)
976 { 974 {
977 if (!image) 975 if (!image)
978 return; 976 return;
979 drawImage(image, styleColorSpace, FloatRect(r), FloatRect(FloatPoint(), Floa tSize(image->size())), op, shouldRespectImageOrientation, useLowQualityScale); 977 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size ())), op, shouldRespectImageOrientation, useLowQualityScale);
980 } 978 }
981 979
982 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, RespectImageOrient ationEnum shouldRespectImageOrientation) 980 void GraphicsContext::drawImage(Image* image, const IntPoint& dest, const IntRec t& srcRect, CompositeOperator op, RespectImageOrientationEnum shouldRespectImage Orientation)
983 { 981 {
984 drawImage(image, styleColorSpace, FloatRect(IntRect(dest, srcRect.size())), FloatRect(srcRect), op, shouldRespectImageOrientation); 982 drawImage(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(srcRect ), op, shouldRespectImageOrientation);
985 } 983 }
986 984
987 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, RespectImageOrienta tionEnum shouldRespectImageOrientation, bool useLowQualityScale) 985 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageO rientation, bool useLowQualityScale)
988 { 986 {
989 drawImage(image, styleColorSpace, dest, src, op, BlendModeNormal, shouldResp ectImageOrientation, useLowQualityScale); 987 drawImage(image, dest, src, op, BlendModeNormal, shouldRespectImageOrientati on, useLowQualityScale);
990 } 988 }
991 989
992 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest) 990 void GraphicsContext::drawImage(Image* image, const FloatRect& dest)
993 { 991 {
994 if (!image) 992 if (!image)
995 return; 993 return;
996 drawImage(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image- >size()))); 994 drawImage(image, dest, FloatRect(IntRect(IntPoint(), image->size())));
997 } 995 }
998 996
999 void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMode blendMode , RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityS cale) 997 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, CompositeOperator op, BlendMode blendMode, RespectImageOrientationEnu m shouldRespectImageOrientation, bool useLowQualityScale)
1000 { if (paintingDisabled() || !image) 998 { if (paintingDisabled() || !image)
1001 return; 999 return;
1002 1000
1003 InterpolationQuality previousInterpolationQuality = InterpolationDefault; 1001 InterpolationQuality previousInterpolationQuality = InterpolationDefault;
1004 1002
1005 if (useLowQualityScale) { 1003 if (useLowQualityScale) {
1006 previousInterpolationQuality = imageInterpolationQuality(); 1004 previousInterpolationQuality = imageInterpolationQuality();
1007 setImageInterpolationQuality(InterpolationLow); 1005 setImageInterpolationQuality(InterpolationLow);
1008 } 1006 }
1009 1007
1010 image->draw(this, dest, src, styleColorSpace, op, blendMode, shouldRespectIm ageOrientation); 1008 image->draw(this, dest, src, op, blendMode, shouldRespectImageOrientation);
1011 1009
1012 if (useLowQualityScale) 1010 if (useLowQualityScale)
1013 setImageInterpolationQuality(previousInterpolationQuality); 1011 setImageInterpolationQuality(previousInterpolationQuality);
1014 } 1012 }
1015 1013
1016 void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, c onst IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, Compo siteOperator op, bool useLowQualityScale, BlendMode blendMode) 1014 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons t IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, bool useLow QualityScale, BlendMode blendMode)
1017 { 1015 {
1018 if (paintingDisabled() || !image) 1016 if (paintingDisabled() || !image)
1019 return; 1017 return;
1020 1018
1021 if (useLowQualityScale) { 1019 if (useLowQualityScale) {
1022 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1020 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1023 setImageInterpolationQuality(InterpolationLow); 1021 setImageInterpolationQuality(InterpolationLow);
1024 image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op , blendMode); 1022 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode);
1025 setImageInterpolationQuality(previousInterpolationQuality); 1023 setImageInterpolationQuality(previousInterpolationQuality);
1026 } else 1024 } else {
1027 image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op , blendMode); 1025 image->drawTiled(this, destRect, srcPoint, tileSize, op, blendMode);
1026 }
1028 } 1027 }
1029 1028
1030 void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, c onst IntRect& dest, const IntRect& srcRect, 1029 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In tRect& srcRect,
1031 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu le, CompositeOperator op, bool useLowQualityScale) 1030 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu le, CompositeOperator op, bool useLowQualityScale)
1032 { 1031 {
1033 if (paintingDisabled() || !image) 1032 if (paintingDisabled() || !image)
1034 return; 1033 return;
1035 1034
1036 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { 1035 if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
1037 // Just do a scale. 1036 // Just do a scale.
1038 drawImage(image, styleColorSpace, dest, srcRect, op); 1037 drawImage(image, dest, srcRect, op);
1039 return; 1038 return;
1040 } 1039 }
1041 1040
1042 if (useLowQualityScale) { 1041 if (useLowQualityScale) {
1043 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1042 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1044 setImageInterpolationQuality(InterpolationLow); 1043 setImageInterpolationQuality(InterpolationLow);
1045 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, sty leColorSpace, op); 1044 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1046 setImageInterpolationQuality(previousInterpolationQuality); 1045 setImageInterpolationQuality(previousInterpolationQuality);
1047 } else 1046 } else {
1048 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, sty leColorSpace, op); 1047 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op) ;
1048 }
1049 } 1049 }
1050 1050
1051 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const IntPoint& p, CompositeOperator op, BlendMode blendMode) 1051 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& p, Com positeOperator op, BlendMode blendMode)
1052 { 1052 {
1053 if (!image) 1053 if (!image)
1054 return; 1054 return;
1055 drawImageBuffer(image, styleColorSpace, FloatRect(IntRect(p, image->logicalS ize())), FloatRect(FloatPoint(), FloatSize(image->logicalSize())), op, blendMode ); 1055 drawImageBuffer(image, FloatRect(IntRect(p, image->logicalSize())), FloatRec t(FloatPoint(), FloatSize(image->logicalSize())), op, blendMode);
1056 } 1056 }
1057 1057
1058 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const IntRect& r, CompositeOperator op, BlendMode blendMode, bool useLowQu alityScale) 1058 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& r, Comp ositeOperator op, BlendMode blendMode, bool useLowQualityScale)
1059 { 1059 {
1060 if (!image) 1060 if (!image)
1061 return; 1061 return;
1062 drawImageBuffer(image, styleColorSpace, FloatRect(r), FloatRect(FloatPoint() , FloatSize(image->logicalSize())), op, blendMode, useLowQualityScale); 1062 drawImageBuffer(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image ->logicalSize())), op, blendMode, useLowQualityScale);
1063 } 1063 }
1064 1064
1065 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, BlendM ode blendMode) 1065 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, BlendMode blendMode)
1066 { 1066 {
1067 drawImageBuffer(image, styleColorSpace, FloatRect(IntRect(dest, srcRect.size ())), FloatRect(srcRect), op, blendMode); 1067 drawImageBuffer(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(s rcRect), op, blendMode);
1068 } 1068 }
1069 1069
1070 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, BlendMo de blendMode, bool useLowQualityScale) 1070 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const IntRect& dest, c onst IntRect& srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQua lityScale)
1071 { 1071 {
1072 drawImageBuffer(image, styleColorSpace, FloatRect(dest), FloatRect(srcRect), op, blendMode, useLowQualityScale); 1072 drawImageBuffer(image, FloatRect(dest), FloatRect(srcRect), op, blendMode, u seLowQualityScale);
1073 } 1073 }
1074 1074
1075 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const FloatRect& dest) 1075 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest)
1076 { 1076 {
1077 if (!image) 1077 if (!image)
1078 return; 1078 return;
1079 drawImageBuffer(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image->logicalSize()))); 1079 drawImageBuffer(image, dest, FloatRect(IntRect(IntPoint(), image->logicalSiz e())));
1080 } 1080 }
1081 1081
1082 void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS pace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMo de blendMode, bool useLowQualityScale) 1082 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMode blendMode, bool useLowQua lityScale)
1083 { 1083 {
1084 if (paintingDisabled() || !image) 1084 if (paintingDisabled() || !image)
1085 return; 1085 return;
1086 1086
1087 if (useLowQualityScale) { 1087 if (useLowQualityScale) {
1088 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality(); 1088 InterpolationQuality previousInterpolationQuality = imageInterpolationQu ality();
1089 setImageInterpolationQuality(InterpolationLow); 1089 setImageInterpolationQuality(InterpolationLow);
1090 image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQuali tyScale); 1090 image->draw(this, dest, src, op, blendMode, useLowQualityScale);
1091 setImageInterpolationQuality(previousInterpolationQuality); 1091 setImageInterpolationQuality(previousInterpolationQuality);
1092 } else 1092 } else {
1093 image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQuali tyScale); 1093 image->draw(this, dest, src, op, blendMode, useLowQualityScale);
1094 }
1094 } 1095 }
1095 1096
1096 void GraphicsContext::writePixels(const SkBitmap& bitmap, int x, int y, SkCanvas ::Config8888 config8888) 1097 void GraphicsContext::writePixels(const SkBitmap& bitmap, int x, int y, SkCanvas ::Config8888 config8888)
1097 { 1098 {
1098 if (paintingDisabled()) 1099 if (paintingDisabled())
1099 return; 1100 return;
1100 1101
1101 m_canvas->writePixels(bitmap, x, y, config8888); 1102 m_canvas->writePixels(bitmap, x, y, config8888);
1102 1103
1103 if (m_trackOpaqueRegion) { 1104 if (m_trackOpaqueRegion) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 if (paintingDisabled()) 1240 if (paintingDisabled())
1240 return; 1241 return;
1241 1242
1242 SkRect r = rect; 1243 SkRect r = rect;
1243 1244
1244 SkPaint paint; 1245 SkPaint paint;
1245 setupPaintForFilling(&paint); 1246 setupPaintForFilling(&paint);
1246 drawRect(r, paint); 1247 drawRect(r, paint);
1247 } 1248 }
1248 1249
1249 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS pace colorSpace) 1250 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
1250 { 1251 {
1251 if (paintingDisabled()) 1252 if (paintingDisabled())
1252 return; 1253 return;
1253 1254
1254 SkRect r = rect; 1255 SkRect r = rect;
1255 SkPaint paint; 1256 SkPaint paint;
1256 setupPaintCommon(&paint); 1257 setupPaintCommon(&paint);
1257 paint.setColor(color.rgb()); 1258 paint.setColor(color.rgb());
1258 drawRect(r, paint); 1259 drawRect(r, paint);
1259 } 1260 }
1260 1261
1261 void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef t, const IntSize& topRight, 1262 void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef t, const IntSize& topRight,
1262 const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, C olorSpace colorSpace) 1263 const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
1263 { 1264 {
1264 if (paintingDisabled()) 1265 if (paintingDisabled())
1265 return; 1266 return;
1266 1267
1267 if (topLeft.width() + topRight.width() > rect.width() 1268 if (topLeft.width() + topRight.width() > rect.width()
1268 || bottomLeft.width() + bottomRight.width() > rect.width() 1269 || bottomLeft.width() + bottomRight.width() > rect.width()
1269 || topLeft.height() + bottomLeft.height() > rect.height() 1270 || topLeft.height() + bottomLeft.height() > rect.height()
1270 || topRight.height() + bottomRight.height() > rect.height()) { 1271 || topRight.height() + bottomRight.height() > rect.height()) {
1271 // Not all the radii fit, return a rect. This matches the behavior of 1272 // Not all the radii fit, return a rect. This matches the behavior of
1272 // Path::createRoundedRectangle. Without this we attempt to draw a round 1273 // Path::createRoundedRectangle. Without this we attempt to draw a round
1273 // shadow for a square box. 1274 // shadow for a square box.
1274 fillRect(rect, color, colorSpace); 1275 fillRect(rect, color);
1275 return; 1276 return;
1276 } 1277 }
1277 1278
1278 SkVector radii[4]; 1279 SkVector radii[4];
1279 setRadii(radii, topLeft, topRight, bottomRight, bottomLeft); 1280 setRadii(radii, topLeft, topRight, bottomRight, bottomLeft);
1280 1281
1281 SkRRect rr; 1282 SkRRect rr;
1282 rr.setRectRadii(rect, radii); 1283 rr.setRectRadii(rect, radii);
1283 1284
1284 SkPaint paint; 1285 SkPaint paint;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1538
1538 const SkMatrix& m = getTotalMatrix(); 1539 const SkMatrix& m = getTotalMatrix();
1539 return AffineTransform(SkScalarToDouble(m.getScaleX()), 1540 return AffineTransform(SkScalarToDouble(m.getScaleX()),
1540 SkScalarToDouble(m.getSkewY()), 1541 SkScalarToDouble(m.getSkewY()),
1541 SkScalarToDouble(m.getSkewX()), 1542 SkScalarToDouble(m.getSkewX()),
1542 SkScalarToDouble(m.getScaleY()), 1543 SkScalarToDouble(m.getScaleY()),
1543 SkScalarToDouble(m.getTranslateX()), 1544 SkScalarToDouble(m.getTranslateX()),
1544 SkScalarToDouble(m.getTranslateY())); 1545 SkScalarToDouble(m.getTranslateY()));
1545 } 1546 }
1546 1547
1547 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS pace styleColorSpace, CompositeOperator op) 1548 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, Compos iteOperator op)
1548 { 1549 {
1549 if (paintingDisabled()) 1550 if (paintingDisabled())
1550 return; 1551 return;
1551 1552
1552 CompositeOperator previousOperator = compositeOperation(); 1553 CompositeOperator previousOperator = compositeOperation();
1553 setCompositeOperation(op); 1554 setCompositeOperation(op);
1554 fillRect(rect, color, styleColorSpace); 1555 fillRect(rect, color);
1555 setCompositeOperation(previousOperator); 1556 setCompositeOperation(previousOperator);
1556 } 1557 }
1557 1558
1558 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& colo r, ColorSpace colorSpace) 1559 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& colo r)
1559 { 1560 {
1560 if (rect.isRounded()) 1561 if (rect.isRounded())
1561 fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRig ht(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); 1562 fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRig ht(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color);
1562 else 1563 else
1563 fillRect(rect.rect(), color, colorSpace); 1564 fillRect(rect.rect(), color);
1564 } 1565 }
1565 1566
1566 void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded Rect& roundedHoleRect, const Color& color, ColorSpace colorSpace) 1567 void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded Rect& roundedHoleRect, const Color& color)
1567 { 1568 {
1568 if (paintingDisabled()) 1569 if (paintingDisabled())
1569 return; 1570 return;
1570 1571
1571 Path path; 1572 Path path;
1572 path.addRect(rect); 1573 path.addRect(rect);
1573 1574
1574 if (!roundedHoleRect.radii().isZero()) 1575 if (!roundedHoleRect.radii().isZero())
1575 path.addRoundedRect(roundedHoleRect); 1576 path.addRoundedRect(roundedHoleRect);
1576 else 1577 else
1577 path.addRect(roundedHoleRect.rect()); 1578 path.addRect(roundedHoleRect.rect());
1578 1579
1579 WindRule oldFillRule = fillRule(); 1580 WindRule oldFillRule = fillRule();
1580 Color oldFillColor = fillColor(); 1581 Color oldFillColor = fillColor();
1581 ColorSpace oldFillColorSpace = fillColorSpace(); 1582
1582
1583 setFillRule(RULE_EVENODD); 1583 setFillRule(RULE_EVENODD);
1584 setFillColor(color, colorSpace); 1584 setFillColor(color);
1585 1585
1586 fillPath(path); 1586 fillPath(path);
1587 1587
1588 setFillRule(oldFillRule); 1588 setFillRule(oldFillRule);
1589 setFillColor(oldFillColor, oldFillColorSpace); 1589 setFillColor(oldFillColor);
1590 } 1590 }
1591 1591
1592 void GraphicsContext::clearRect(const FloatRect& rect) 1592 void GraphicsContext::clearRect(const FloatRect& rect)
1593 { 1593 {
1594 if (paintingDisabled()) 1594 if (paintingDisabled())
1595 return; 1595 return;
1596 1596
1597 SkRect r = rect; 1597 SkRect r = rect;
1598 SkPaint paint; 1598 SkPaint paint;
1599 setupPaintForFilling(&paint); 1599 setupPaintForFilling(&paint);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 1637
1638 PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& s ize, bool hasAlpha) const 1638 PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& s ize, bool hasAlpha) const
1639 { 1639 {
1640 // Make the buffer larger if the context's transform is scaling it so we nee d a higher 1640 // Make the buffer larger if the context's transform is scaling it so we nee d a higher
1641 // resolution than one pixel per unit. Also set up a corresponding scale fac tor on the 1641 // resolution than one pixel per unit. Also set up a corresponding scale fac tor on the
1642 // graphics context. 1642 // graphics context.
1643 1643
1644 AffineTransform transform = getCTM(DefinitelyIncludeDeviceScale); 1644 AffineTransform transform = getCTM(DefinitelyIncludeDeviceScale);
1645 IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale())) , static_cast<int>(ceil(size.height() * transform.yScale()))); 1645 IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale())) , static_cast<int>(ceil(size.height() * transform.yScale())));
1646 1646
1647 OwnPtr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceDeviceRGB, this, hasAlpha); 1647 OwnPtr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, this, hasAlpha);
1648 if (!buffer) 1648 if (!buffer)
1649 return nullptr; 1649 return nullptr;
1650 1650
1651 buffer->context()->scale(FloatSize(static_cast<float>(scaledSize.width()) / size.width(), 1651 buffer->context()->scale(FloatSize(static_cast<float>(scaledSize.width()) / size.width(),
1652 static_cast<float>(scaledSize.height()) / size.height())); 1652 static_cast<float>(scaledSize.height()) / size.height()));
1653 1653
1654 return buffer.release(); 1654 return buffer.release();
1655 } 1655 }
1656 1656
1657 bool GraphicsContext::isCompatibleWithBuffer(ImageBuffer* buffer) const 1657 bool GraphicsContext::isCompatibleWithBuffer(ImageBuffer* buffer) const
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 1894
1895 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1895 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1896 { 1896 {
1897 if (m_trackTextRegion) { 1897 if (m_trackTextRegion) {
1898 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1898 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1899 m_textRegion.join(textRect); 1899 m_textRegion.join(textRect);
1900 } 1900 }
1901 } 1901 }
1902 1902
1903 } 1903 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GraphicsContext.h ('k') | Source/core/platform/graphics/GraphicsContextState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698