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

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

Issue 201213002: Remove uses of SkBitmap::Config (deprecated) from core/ and platform/. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: schenney comments 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
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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // Create the pattern we'll use to draw the underline. 772 // Create the pattern we'll use to draw the underline.
773 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0; 773 int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0;
774 static SkBitmap* misspellBitmap1x[2] = { 0, 0 }; 774 static SkBitmap* misspellBitmap1x[2] = { 0, 0 };
775 static SkBitmap* misspellBitmap2x[2] = { 0, 0 }; 775 static SkBitmap* misspellBitmap2x[2] = { 0, 0 };
776 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss pellBitmap1x; 776 SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : miss pellBitmap1x;
777 if (!misspellBitmap[index]) { 777 if (!misspellBitmap[index]) {
778 #if OS(MACOSX) 778 #if OS(MACOSX)
779 // Match the artwork used by the Mac. 779 // Match the artwork used by the Mac.
780 const int rowPixels = 4 * deviceScaleFactor; 780 const int rowPixels = 4 * deviceScaleFactor;
781 const int colPixels = 3 * deviceScaleFactor; 781 const int colPixels = 3 * deviceScaleFactor;
782 misspellBitmap[index] = new SkBitmap; 782 SkBitmap bitmap;
783 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, 783 if (!bitmap.allocN32Pixels(rowPixels, colPixels))
784 rowPixels, colPixels); 784 return;
785 misspellBitmap[index]->allocPixels();
786 785
787 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); 786 bitmap.eraseARGB(0, 0, 0, 0);
788 const uint32_t transparentColor = 0x00000000; 787 const uint32_t transparentColor = 0x00000000;
789 788
790 if (deviceScaleFactor == 1) { 789 if (deviceScaleFactor == 1) {
791 const uint32_t colors[2][6] = { 790 const uint32_t colors[2][6] = {
792 { 0x2a2a0600, 0x57571000, 0xa8a81b00, 0xbfbf1f00, 0x70701200, 0xe0e02400 }, 791 { 0x2a2a0600, 0x57571000, 0xa8a81b00, 0xbfbf1f00, 0x70701200, 0xe0e02400 },
793 { 0x2a0f0f0f, 0x571e1e1e, 0xa83d3d3d, 0xbf454545, 0x70282828, 0xe0515151 } 792 { 0x2a0f0f0f, 0x571e1e1e, 0xa83d3d3d, 0xbf454545, 0x70282828, 0xe0515151 }
794 }; 793 };
795 794
796 // Pattern: a b a a b a 795 // Pattern: a b a a b a
797 // c d c c d c 796 // c d c c d c
798 // e f e e f e 797 // e f e e f e
799 for (int x = 0; x < colPixels; ++x) { 798 for (int x = 0; x < colPixels; ++x) {
800 uint32_t* row = misspellBitmap[index]->getAddr32(0, x); 799 uint32_t* row = bitmap.getAddr32(0, x);
801 row[0] = colors[index][x * 2]; 800 row[0] = colors[index][x * 2];
802 row[1] = colors[index][x * 2 + 1]; 801 row[1] = colors[index][x * 2 + 1];
803 row[2] = colors[index][x * 2]; 802 row[2] = colors[index][x * 2];
804 row[3] = transparentColor; 803 row[3] = transparentColor;
805 } 804 }
806 } else if (deviceScaleFactor == 2) { 805 } else if (deviceScaleFactor == 2) {
807 const uint32_t colors[2][18] = { 806 const uint32_t colors[2][18] = {
808 { 0x0a090101, 0x33320806, 0x55540f0a, 0x37360906, 0x6e6c120c, 0 x6e6c120c, 0x7674140d, 0x8d8b1810, 0x8d8b1810, 807 { 0x0a090101, 0x33320806, 0x55540f0a, 0x37360906, 0x6e6c120c, 0 x6e6c120c, 0x7674140d, 0x8d8b1810, 0x8d8b1810,
809 0x96941a11, 0xb3b01f15, 0xb3b01f15, 0x6d6b130c, 0xd9d62619, 0 xd9d62619, 0x19180402, 0x7c7a150e, 0xcecb2418 }, 808 0x96941a11, 0xb3b01f15, 0xb3b01f15, 0x6d6b130c, 0xd9d62619, 0 xd9d62619, 0x19180402, 0x7c7a150e, 0xcecb2418 },
810 { 0x0a020202, 0x33141414, 0x55232323, 0x37161616, 0x6e2e2e2e, 0 x6e2e2e2e, 0x76313131, 0x8d3a3a3a, 0x8d3a3a3a, 809 { 0x0a020202, 0x33141414, 0x55232323, 0x37161616, 0x6e2e2e2e, 0 x6e2e2e2e, 0x76313131, 0x8d3a3a3a, 0x8d3a3a3a,
811 0x963e3e3e, 0xb34b4b4b, 0xb34b4b4b, 0x6d2d2d2d, 0xd95b5b5b, 0 xd95b5b5b, 0x19090909, 0x7c343434, 0xce575757 } 810 0x963e3e3e, 0xb34b4b4b, 0xb34b4b4b, 0x6d2d2d2d, 0xd95b5b5b, 0 xd95b5b5b, 0x19090909, 0x7c343434, 0xce575757 }
812 }; 811 };
813 812
814 // Pattern: a b c c b a 813 // Pattern: a b c c b a
815 // d e f f e d 814 // d e f f e d
816 // g h j j h g 815 // g h j j h g
817 // k l m m l k 816 // k l m m l k
818 // n o p p o n 817 // n o p p o n
819 // q r s s r q 818 // q r s s r q
820 for (int x = 0; x < colPixels; ++x) { 819 for (int x = 0; x < colPixels; ++x) {
821 uint32_t* row = misspellBitmap[index]->getAddr32(0, x); 820 uint32_t* row = bitmap.getAddr32(0, x);
822 row[0] = colors[index][x * 3]; 821 row[0] = colors[index][x * 3];
823 row[1] = colors[index][x * 3 + 1]; 822 row[1] = colors[index][x * 3 + 1];
824 row[2] = colors[index][x * 3 + 2]; 823 row[2] = colors[index][x * 3 + 2];
825 row[3] = colors[index][x * 3 + 2]; 824 row[3] = colors[index][x * 3 + 2];
826 row[4] = colors[index][x * 3 + 1]; 825 row[4] = colors[index][x * 3 + 1];
827 row[5] = colors[index][x * 3]; 826 row[5] = colors[index][x * 3];
828 row[6] = transparentColor; 827 row[6] = transparentColor;
829 row[7] = transparentColor; 828 row[7] = transparentColor;
830 } 829 }
831 } else 830 } else
832 ASSERT_NOT_REACHED(); 831 ASSERT_NOT_REACHED();
832
833 misspellBitmap[index] = new SkBitmap(bitmap);
833 #else 834 #else
834 // We use a 2-pixel-high misspelling indicator because that seems to be 835 // We use a 2-pixel-high misspelling indicator because that seems to be
835 // what WebKit is designed for, and how much room there is in a typical 836 // what WebKit is designed for, and how much room there is in a typical
836 // page for it. 837 // page for it.
837 const int rowPixels = 32 * deviceScaleFactor; // Must be multiple of 4 f or pattern below. 838 const int rowPixels = 32 * deviceScaleFactor; // Must be multiple of 4 f or pattern below.
838 const int colPixels = 2 * deviceScaleFactor; 839 const int colPixels = 2 * deviceScaleFactor;
839 misspellBitmap[index] = new SkBitmap; 840 SkBitmap bitmap;
840 misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, rowPixels, colPixels); 841 if (!bitmap.allocN32Pixels(rowPixels, colPixels))
841 misspellBitmap[index]->allocPixels(); 842 return;
842 843
843 misspellBitmap[index]->eraseARGB(0, 0, 0, 0); 844 bitmap.eraseARGB(0, 0, 0, 0);
844 if (deviceScaleFactor == 1) 845 if (deviceScaleFactor == 1)
845 draw1xMarker(misspellBitmap[index], index); 846 draw1xMarker(&bitmap, index);
846 else if (deviceScaleFactor == 2) 847 else if (deviceScaleFactor == 2)
847 draw2xMarker(misspellBitmap[index], index); 848 draw2xMarker(&bitmap, index);
848 else 849 else
849 ASSERT_NOT_REACHED(); 850 ASSERT_NOT_REACHED();
851
852 misspellBitmap[index] = new SkBitmap(bitmap);
850 #endif 853 #endif
851 } 854 }
852 855
853 #if OS(MACOSX) 856 #if OS(MACOSX)
854 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor; 857 SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor;
855 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor; 858 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor;
856 859
857 // Make sure to draw only complete dots. 860 // Make sure to draw only complete dots.
858 int rowPixels = misspellBitmap[index]->width(); 861 int rowPixels = misspellBitmap[index]->width();
859 float widthMod = fmodf(width * deviceScaleFactor, rowPixels); 862 float widthMod = fmodf(width * deviceScaleFactor, rowPixels);
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1918
1916 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1919 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1917 { 1920 {
1918 if (m_trackTextRegion) { 1921 if (m_trackTextRegion) {
1919 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1922 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1920 m_textRegion.join(textRect); 1923 m_textRegion.join(textRect);
1921 } 1924 }
1922 } 1925 }
1923 1926
1924 } 1927 }
OLDNEW
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoderTest.cpp ('k') | Source/platform/graphics/ImageDecodingStoreTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698