| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "SkRRect.h" | 52 #include "SkRRect.h" |
| 53 #include "SkShader.h" | 53 #include "SkShader.h" |
| 54 #include "SkiaUtils.h" | 54 #include "SkiaUtils.h" |
| 55 #include "skia/ext/platform_canvas.h" | 55 #include "skia/ext/platform_canvas.h" |
| 56 | 56 |
| 57 #include <math.h> | 57 #include <math.h> |
| 58 #include <wtf/Assertions.h> | 58 #include <wtf/Assertions.h> |
| 59 #include <wtf/MathExtras.h> | 59 #include <wtf/MathExtras.h> |
| 60 #include <wtf/UnusedParam.h> | 60 #include <wtf/UnusedParam.h> |
| 61 | 61 |
| 62 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 62 #if OS(DARWIN) |
| 63 #include <ApplicationServices/ApplicationServices.h> | 63 #include <ApplicationServices/ApplicationServices.h> |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 using namespace std; | 66 using namespace std; |
| 67 | 67 |
| 68 namespace WebCore { | 68 namespace WebCore { |
| 69 | 69 |
| 70 namespace { | 70 namespace { |
| 71 // Local helper functions ------------------------------------------------------ | 71 // Local helper functions ------------------------------------------------------ |
| 72 | 72 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, con
st Color& color) | 491 void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, con
st Color& color) |
| 492 { | 492 { |
| 493 // FIXME: implement | 493 // FIXME: implement |
| 494 } | 494 } |
| 495 | 495 |
| 496 static inline void drawOuterPath(PlatformContextSkia* context, const SkPath& pat
h, SkPaint& paint, int width) | 496 static inline void drawOuterPath(PlatformContextSkia* context, const SkPath& pat
h, SkPaint& paint, int width) |
| 497 { | 497 { |
| 498 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 498 #if OS(DARWIN) |
| 499 paint.setAlpha(64); | 499 paint.setAlpha(64); |
| 500 paint.setStrokeWidth(width); | 500 paint.setStrokeWidth(width); |
| 501 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref(); | 501 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref(); |
| 502 #else | 502 #else |
| 503 paint.setStrokeWidth(1); | 503 paint.setStrokeWidth(1); |
| 504 paint.setPathEffect(new SkCornerPathEffect(1))->unref(); | 504 paint.setPathEffect(new SkCornerPathEffect(1))->unref(); |
| 505 #endif | 505 #endif |
| 506 context->drawPath(path, paint); | 506 context->drawPath(path, paint); |
| 507 } | 507 } |
| 508 | 508 |
| 509 static inline void drawInnerPath(PlatformContextSkia* context, const SkPath& pat
h, SkPaint& paint, int width) | 509 static inline void drawInnerPath(PlatformContextSkia* context, const SkPath& pat
h, SkPaint& paint, int width) |
| 510 { | 510 { |
| 511 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 511 #if OS(DARWIN) |
| 512 paint.setAlpha(128); | 512 paint.setAlpha(128); |
| 513 paint.setStrokeWidth(width * 0.5f); | 513 paint.setStrokeWidth(width * 0.5f); |
| 514 context->drawPath(path, paint); | 514 context->drawPath(path, paint); |
| 515 #endif | 515 #endif |
| 516 } | 516 } |
| 517 | 517 |
| 518 static inline int getFocusRingOutset(int offset) | 518 static inline int getFocusRingOutset(int offset) |
| 519 { | 519 { |
| 520 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 520 #if OS(DARWIN) |
| 521 return offset + 2; | 521 return offset + 2; |
| 522 #else | 522 #else |
| 523 return 0; | 523 return 0; |
| 524 #endif | 524 #endif |
| 525 } | 525 } |
| 526 | 526 |
| 527 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
offset, const Color& color) | 527 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
offset, const Color& color) |
| 528 { | 528 { |
| 529 if (paintingDisabled()) | 529 if (paintingDisabled()) |
| 530 return; | 530 return; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 609 |
| 610 int deviceScaleFactor = SkScalarRoundToInt(WebCoreFloatToSkScalar(platformCo
ntext()->deviceScaleFactor())); | 610 int deviceScaleFactor = SkScalarRoundToInt(WebCoreFloatToSkScalar(platformCo
ntext()->deviceScaleFactor())); |
| 611 ASSERT(deviceScaleFactor == 1 || deviceScaleFactor == 2); | 611 ASSERT(deviceScaleFactor == 1 || deviceScaleFactor == 2); |
| 612 | 612 |
| 613 // Create the pattern we'll use to draw the underline. | 613 // Create the pattern we'll use to draw the underline. |
| 614 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0; | 614 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0; |
| 615 static SkBitmap* misspellBitmap1x[2] = { 0, 0 }; | 615 static SkBitmap* misspellBitmap1x[2] = { 0, 0 }; |
| 616 static SkBitmap* misspellBitmap2x[2] = { 0, 0 }; | 616 static SkBitmap* misspellBitmap2x[2] = { 0, 0 }; |
| 617 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss
pellBitmap1x; | 617 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss
pellBitmap1x; |
| 618 if (!misspellBitmap[index]) { | 618 if (!misspellBitmap[index]) { |
| 619 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 619 #if OS(DARWIN) |
| 620 // Match the artwork used by the Mac. | 620 // Match the artwork used by the Mac. |
| 621 const int rowPixels = 4 * deviceScaleFactor; | 621 const int rowPixels = 4 * deviceScaleFactor; |
| 622 const int colPixels = 3 * deviceScaleFactor; | 622 const int colPixels = 3 * deviceScaleFactor; |
| 623 misspellBitmap[index] = new SkBitmap; | 623 misspellBitmap[index] = new SkBitmap; |
| 624 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, | 624 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, |
| 625 rowPixels, colPixels); | 625 rowPixels, colPixels); |
| 626 misspellBitmap[index]->allocPixels(); | 626 misspellBitmap[index]->allocPixels(); |
| 627 | 627 |
| 628 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); | 628 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); |
| 629 const uint32_t transparentColor = 0x00000000; | 629 const uint32_t transparentColor = 0x00000000; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); | 684 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); |
| 685 if (deviceScaleFactor == 1) | 685 if (deviceScaleFactor == 1) |
| 686 draw1xMarker(misspellBitmap[index], index); | 686 draw1xMarker(misspellBitmap[index], index); |
| 687 else if (deviceScaleFactor == 2) | 687 else if (deviceScaleFactor == 2) |
| 688 draw2xMarker(misspellBitmap[index], index); | 688 draw2xMarker(misspellBitmap[index], index); |
| 689 else | 689 else |
| 690 ASSERT_NOT_REACHED(); | 690 ASSERT_NOT_REACHED(); |
| 691 #endif | 691 #endif |
| 692 } | 692 } |
| 693 | 693 |
| 694 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 694 #if OS(DARWIN) |
| 695 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor; | 695 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor; |
| 696 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor; | 696 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor; |
| 697 | 697 |
| 698 // Make sure to draw only complete dots. | 698 // Make sure to draw only complete dots. |
| 699 int rowPixels = misspellBitmap[index]->width(); | 699 int rowPixels = misspellBitmap[index]->width(); |
| 700 float widthMod = fmodf(width * deviceScaleFactor, rowPixels); | 700 float widthMod = fmodf(width * deviceScaleFactor, rowPixels); |
| 701 if (rowPixels - widthMod > deviceScaleFactor) | 701 if (rowPixels - widthMod > deviceScaleFactor) |
| 702 width -= widthMod / deviceScaleFactor; | 702 width -= widthMod / deviceScaleFactor; |
| 703 #else | 703 #else |
| 704 SkScalar originX = WebCoreFloatToSkScalar(pt.x()); | 704 SkScalar originX = WebCoreFloatToSkScalar(pt.x()); |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 return; | 1193 return; |
| 1194 | 1194 |
| 1195 platformContext()->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScal
ar(h)); | 1195 platformContext()->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScal
ar(h)); |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 bool GraphicsContext::isAcceleratedContext() const | 1198 bool GraphicsContext::isAcceleratedContext() const |
| 1199 { | 1199 { |
| 1200 return platformContext()->isAccelerated(); | 1200 return platformContext()->isAccelerated(); |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 1203 #if OS(DARWIN) |
| 1204 CGColorSpaceRef deviceRGBColorSpaceRef() | 1204 CGColorSpaceRef deviceRGBColorSpaceRef() |
| 1205 { | 1205 { |
| 1206 static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB(); | 1206 static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB(); |
| 1207 return deviceSpace; | 1207 return deviceSpace; |
| 1208 } | 1208 } |
| 1209 #endif | 1209 #endif |
| 1210 | 1210 |
| 1211 void GraphicsContext::platformFillEllipse(const FloatRect& ellipse) | 1211 void GraphicsContext::platformFillEllipse(const FloatRect& ellipse) |
| 1212 { | 1212 { |
| 1213 if (paintingDisabled()) | 1213 if (paintingDisabled()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1224 if (paintingDisabled()) | 1224 if (paintingDisabled()) |
| 1225 return; | 1225 return; |
| 1226 | 1226 |
| 1227 SkRect rect(ellipse); | 1227 SkRect rect(ellipse); |
| 1228 SkPaint paint; | 1228 SkPaint paint; |
| 1229 platformContext()->setupPaintForStroking(&paint, 0, 0); | 1229 platformContext()->setupPaintForStroking(&paint, 0, 0); |
| 1230 platformContext()->drawOval(rect, paint); | 1230 platformContext()->drawOval(rect, paint); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 } // namespace WebCore | 1233 } // namespace WebCore |
| OLD | NEW |