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

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

Issue 14107015: Rename OS(DARWIN) to OS(MACOSX). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 3 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 30 matching lines...) Expand all
41 #include "third_party/skia/include/core/SkDevice.h" 41 #include "third_party/skia/include/core/SkDevice.h"
42 #include "third_party/skia/include/core/SkRRect.h" 42 #include "third_party/skia/include/core/SkRRect.h"
43 #include "third_party/skia/include/core/SkRefCnt.h" 43 #include "third_party/skia/include/core/SkRefCnt.h"
44 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 44 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
45 #include "third_party/skia/include/effects/SkCornerPathEffect.h" 45 #include "third_party/skia/include/effects/SkCornerPathEffect.h"
46 #include "third_party/skia/include/effects/SkLumaXfermode.h" 46 #include "third_party/skia/include/effects/SkLumaXfermode.h"
47 #include "weborigin/KURL.h" 47 #include "weborigin/KURL.h"
48 #include "wtf/Assertions.h" 48 #include "wtf/Assertions.h"
49 #include "wtf/MathExtras.h" 49 #include "wtf/MathExtras.h"
50 50
51 #if OS(DARWIN) 51 #if OS(MACOSX)
52 #include <ApplicationServices/ApplicationServices.h> 52 #include <ApplicationServices/ApplicationServices.h>
53 #endif 53 #endif
54 54
55 using namespace std; 55 using namespace std;
56 56
57 namespace WebCore { 57 namespace WebCore {
58 58
59 struct GraphicsContext::DeferredSaveState { 59 struct GraphicsContext::DeferredSaveState {
60 DeferredSaveState(unsigned mask, int count) : m_flags(mask), m_restoreCount( count) { } 60 DeferredSaveState(unsigned mask, int count) : m_flags(mask), m_restoreCount( count) { }
61 61
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 return; 690 return;
691 691
692 int deviceScaleFactor = m_useHighResMarker ? 2 : 1; 692 int deviceScaleFactor = m_useHighResMarker ? 2 : 1;
693 693
694 // Create the pattern we'll use to draw the underline. 694 // Create the pattern we'll use to draw the underline.
695 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0; 695 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0;
696 static SkBitmap* misspellBitmap1x[2] = { 0, 0 }; 696 static SkBitmap* misspellBitmap1x[2] = { 0, 0 };
697 static SkBitmap* misspellBitmap2x[2] = { 0, 0 }; 697 static SkBitmap* misspellBitmap2x[2] = { 0, 0 };
698 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss pellBitmap1x; 698 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss pellBitmap1x;
699 if (!misspellBitmap[index]) { 699 if (!misspellBitmap[index]) {
700 #if OS(DARWIN) 700 #if OS(MACOSX)
701 // Match the artwork used by the Mac. 701 // Match the artwork used by the Mac.
702 const int rowPixels = 4 * deviceScaleFactor; 702 const int rowPixels = 4 * deviceScaleFactor;
703 const int colPixels = 3 * deviceScaleFactor; 703 const int colPixels = 3 * deviceScaleFactor;
704 misspellBitmap[index] = new SkBitmap; 704 misspellBitmap[index] = new SkBitmap;
705 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, 705 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config,
706 rowPixels, colPixels); 706 rowPixels, colPixels);
707 misspellBitmap[index]->allocPixels(); 707 misspellBitmap[index]->allocPixels();
708 708
709 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); 709 misspellBitmap[index]->eraseARGB(0, 0, 0, 0);
710 const uint32_t transparentColor = 0x00000000; 710 const uint32_t transparentColor = 0x00000000;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); 765 misspellBitmap[index]->eraseARGB(0, 0, 0, 0);
766 if (deviceScaleFactor == 1) 766 if (deviceScaleFactor == 1)
767 draw1xMarker(misspellBitmap[index], index); 767 draw1xMarker(misspellBitmap[index], index);
768 else if (deviceScaleFactor == 2) 768 else if (deviceScaleFactor == 2)
769 draw2xMarker(misspellBitmap[index], index); 769 draw2xMarker(misspellBitmap[index], index);
770 else 770 else
771 ASSERT_NOT_REACHED(); 771 ASSERT_NOT_REACHED();
772 #endif 772 #endif
773 } 773 }
774 774
775 #if OS(DARWIN) 775 #if OS(MACOSX)
776 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor; 776 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor;
777 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor; 777 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor;
778 778
779 // Make sure to draw only complete dots. 779 // Make sure to draw only complete dots.
780 int rowPixels = misspellBitmap[index]->width(); 780 int rowPixels = misspellBitmap[index]->width();
781 float widthMod = fmodf(width * deviceScaleFactor, rowPixels); 781 float widthMod = fmodf(width * deviceScaleFactor, rowPixels);
782 if (rowPixels - widthMod > deviceScaleFactor) 782 if (rowPixels - widthMod > deviceScaleFactor)
783 width -= widthMod / deviceScaleFactor; 783 width -= widthMod / deviceScaleFactor;
784 #else 784 #else
785 SkScalar originX = WebCoreFloatToSkScalar(pt.x()); 785 SkScalar originX = WebCoreFloatToSkScalar(pt.x());
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 #endif 1701 #endif
1702 1702
1703 paint->setAntiAlias(m_state->m_shouldAntialias); 1703 paint->setAntiAlias(m_state->m_shouldAntialias);
1704 paint->setXfermode(m_state->m_xferMode.get()); 1704 paint->setXfermode(m_state->m_xferMode.get());
1705 paint->setLooper(m_state->m_looper.get()); 1705 paint->setLooper(m_state->m_looper.get());
1706 paint->setColorFilter(m_state->m_colorFilter.get()); 1706 paint->setColorFilter(m_state->m_colorFilter.get());
1707 } 1707 }
1708 1708
1709 void GraphicsContext::drawOuterPath(const SkPath& path, SkPaint& paint, int widt h) 1709 void GraphicsContext::drawOuterPath(const SkPath& path, SkPaint& paint, int widt h)
1710 { 1710 {
1711 #if OS(DARWIN) 1711 #if OS(MACOSX)
1712 paint.setAlpha(64); 1712 paint.setAlpha(64);
1713 paint.setStrokeWidth(width); 1713 paint.setStrokeWidth(width);
1714 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref(); 1714 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref();
1715 #else 1715 #else
1716 paint.setStrokeWidth(1); 1716 paint.setStrokeWidth(1);
1717 paint.setPathEffect(new SkCornerPathEffect(1))->unref(); 1717 paint.setPathEffect(new SkCornerPathEffect(1))->unref();
1718 #endif 1718 #endif
1719 drawPath(path, paint); 1719 drawPath(path, paint);
1720 } 1720 }
1721 1721
1722 void GraphicsContext::drawInnerPath(const SkPath& path, SkPaint& paint, int widt h) 1722 void GraphicsContext::drawInnerPath(const SkPath& path, SkPaint& paint, int widt h)
1723 { 1723 {
1724 #if OS(DARWIN) 1724 #if OS(MACOSX)
1725 paint.setAlpha(128); 1725 paint.setAlpha(128);
1726 paint.setStrokeWidth(width * 0.5f); 1726 paint.setStrokeWidth(width * 0.5f);
1727 drawPath(path, paint); 1727 drawPath(path, paint);
1728 #endif 1728 #endif
1729 } 1729 }
1730 1730
1731 void GraphicsContext::setRadii(SkVector* radii, IntSize topLeft, IntSize topRigh t, IntSize bottomRight, IntSize bottomLeft) 1731 void GraphicsContext::setRadii(SkVector* radii, IntSize topLeft, IntSize topRigh t, IntSize bottomRight, IntSize bottomLeft)
1732 { 1732 {
1733 radii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(topLeft.width()), 1733 radii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(topLeft.width()),
1734 SkIntToScalar(topLeft.height())); 1734 SkIntToScalar(topLeft.height()));
1735 radii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(topRight.width()), 1735 radii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(topRight.width()),
1736 SkIntToScalar(topRight.height())); 1736 SkIntToScalar(topRight.height()));
1737 radii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(bottomRight.width()), 1737 radii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(bottomRight.width()),
1738 SkIntToScalar(bottomRight.height())); 1738 SkIntToScalar(bottomRight.height()));
1739 radii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(bottomLeft.width()), 1739 radii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(bottomLeft.width()),
1740 SkIntToScalar(bottomLeft.height())); 1740 SkIntToScalar(bottomLeft.height()));
1741 } 1741 }
1742 1742
1743 #if OS(DARWIN) 1743 #if OS(MACOSX)
1744 CGColorSpaceRef deviceRGBColorSpaceRef() 1744 CGColorSpaceRef deviceRGBColorSpaceRef()
1745 { 1745 {
1746 static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB(); 1746 static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
1747 return deviceSpace; 1747 return deviceSpace;
1748 } 1748 }
1749 #else 1749 #else
1750 void GraphicsContext::draw2xMarker(SkBitmap* bitmap, int index) 1750 void GraphicsContext::draw2xMarker(SkBitmap* bitmap, int index)
1751 { 1751 {
1752 const SkPMColor lineColor = lineColors(index); 1752 const SkPMColor lineColor = lineColors(index);
1753 const SkPMColor antiColor1 = antiColors1(index); 1753 const SkPMColor antiColor1 = antiColors1(index);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 1857
1858 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1858 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1859 { 1859 {
1860 if (m_trackTextRegion) { 1860 if (m_trackTextRegion) {
1861 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1861 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1862 m_textRegion.join(textRect); 1862 m_textRegion.join(textRect);
1863 } 1863 }
1864 } 1864 }
1865 1865
1866 } 1866 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GraphicsContext.h ('k') | Source/core/platform/graphics/IntPoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698