diff options
| author | awalker@google.com <awalker@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-09 20:38:55 +0000 |
|---|---|---|
| committer | awalker@google.com <awalker@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-09 20:38:55 +0000 |
| commit | ab52947d4390b1b59aae47f5f6c16b7d537030fd (patch) | |
| tree | 3aa8a55fa87f8442a5bd8c3cafa4883ac1797c28 | |
| parent | f9ad22f0e3faea2c7a1fb9853bbf3fb768637be0 (diff) | |
| download | chromium_src-ab52947d4390b1b59aae47f5f6c16b7d537030fd.zip chromium_src-ab52947d4390b1b59aae47f5f6c16b7d537030fd.tar.gz chromium_src-ab52947d4390b1b59aae47f5f6c16b7d537030fd.tar.bz2 | |
Refactor the platform canvas unit test a bit so that it can be run on
multiple platforms. Also adjusts platfom_canvas.h and platform_device.h
so that some upper layers can include them instead of the windows
versions.
Change was originally http://codereview.chromium.org/1616, which was created in the wrong source tree. Applying approval from that issue.
Review URL: http://codereview.chromium.org/1853
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1926 0039d316-1c4b-4281-b951-d872f2087c98
| -rw-r--r-- | base/base.xcodeproj/project.pbxproj | 10 | ||||
| -rw-r--r-- | base/build/base_unittests.vcproj | 2 | ||||
| -rw-r--r-- | base/gfx/SConscript | 2 | ||||
| -rw-r--r-- | base/gfx/bitmap_platform_device.h | 13 | ||||
| -rwxr-xr-x | base/gfx/bitmap_platform_device_mac.h | 3 | ||||
| -rw-r--r-- | base/gfx/platform_canvas.h | 18 | ||||
| -rwxr-xr-x | base/gfx/platform_canvas_mac.cc | 5 | ||||
| -rw-r--r-- | base/gfx/platform_canvas_unittest.c (renamed from base/gfx/platform_canvas_unittest_win.cc) | 0 | ||||
| -rw-r--r-- | base/gfx/platform_device.h | 15 | ||||
| -rwxr-xr-x | base/gfx/platform_device_mac.h | 6 |
10 files changed, 57 insertions, 17 deletions
diff --git a/base/base.xcodeproj/project.pbxproj b/base/base.xcodeproj/project.pbxproj index 495f02f..fe90c36 100644 --- a/base/base.xcodeproj/project.pbxproj +++ b/base/base.xcodeproj/project.pbxproj @@ -140,6 +140,8 @@ AB956DFF0E5DDB6900BBE9D8 /* bitmap_platform_device_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = 829E2F940DBFD74B00819EBF /* bitmap_platform_device_mac.cc */; }; AB956E030E5DDB7A00BBE9D8 /* image_operations.cc in Sources */ = {isa = PBXBuildFile; fileRef = E48A06370E3F6C1F00172919 /* image_operations.cc */; }; AB956E0A0E5DDC0900BBE9D8 /* image_operations_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = E48A063B0E3F6C3000172919 /* image_operations_unittest.cc */; }; + ABE1BA2A0E7574D1009041DA /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABE1BA290E7574D1009041DA /* ApplicationServices.framework */; }; + ABE1BA610E75757C009041DA /* skia_utils_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABE1BA600E75757C009041DA /* skia_utils_mac.cc */; }; ABF4B98F0DC2BA6900A6E319 /* base_paths_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B98E0DC2BA6900A6E319 /* base_paths_mac.mm */; }; ABF4B99E0DC2BB6000A6E319 /* clipboard_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABF4B99D0DC2BB6000A6E319 /* clipboard_mac.mm */; }; ABF4B9AF0DC2BC6200A6E319 /* json_reader.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8254031B0D92D1F40006B936 /* json_reader.cc */; }; @@ -559,6 +561,9 @@ AB6BC1ED0E54E836006436D5 /* bitmap_platform_device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bitmap_platform_device.h; sourceTree = "<group>"; }; AB6BC1F10E54E900006436D5 /* platform_canvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_canvas.h; sourceTree = "<group>"; }; AB6BC1F50E54E97B006436D5 /* platform_device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_device.h; sourceTree = "<group>"; }; + ABE1BA0C0E756EC4009041DA /* platform_canvas_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = platform_canvas_unittest.cc; sourceTree = "<group>"; }; + ABE1BA290E7574D1009041DA /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; + ABE1BA600E75757C009041DA /* skia_utils_mac.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = skia_utils_mac.cc; sourceTree = "<group>"; }; ABF4B98E0DC2BA6900A6E319 /* base_paths_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = base_paths_mac.mm; sourceTree = "<group>"; }; ABF4B99D0DC2BB6000A6E319 /* clipboard_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = clipboard_mac.mm; sourceTree = "<group>"; }; ABF4B9B40DC2BC9F00A6E319 /* path_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = path_service.cc; sourceTree = "<group>"; }; @@ -636,6 +641,7 @@ 7B85062A0E5B556900730B43 /* libpng.a in Frameworks */, 7B4DF5350E5B6A66004D7619 /* libskia.a in Frameworks */, 7B85062F0E5B559A00730B43 /* libzlib.a in Frameworks */, + ABE1BA2A0E7574D1009041DA /* ApplicationServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -982,6 +988,7 @@ AB6BC1F10E54E900006436D5 /* platform_canvas.h */, 829E2F990DBFD76300819EBF /* platform_canvas_mac.cc */, 829E2F980DBFD76300819EBF /* platform_canvas_mac.h */, + ABE1BA0C0E756EC4009041DA /* platform_canvas_unittest.cc */, AB6BC1F50E54E97B006436D5 /* platform_device.h */, 829E2F9D0DBFD76F00819EBF /* platform_device_mac.cc */, 829E2F9C0DBFD76F00819EBF /* platform_device_mac.h */, @@ -999,6 +1006,7 @@ 825403D70D92D31D0006B936 /* size.h */, 7B8505A50E5B3FBE00730B43 /* skia_utils.cc */, 7B8505A60E5B3FBE00730B43 /* skia_utils.h */, + ABE1BA600E75757C009041DA /* skia_utils_mac.cc */, 825403DC0D92D31D0006B936 /* vector_canvas.cc */, 825403DD0D92D31D0006B936 /* vector_canvas.h */, 7B8505A80E5B3FBE00730B43 /* vector_canvas_unittest.cc */, @@ -1011,6 +1019,7 @@ 829E2FA80DBFD7D500819EBF /* Frameworks */ = { isa = PBXGroup; children = ( + ABE1BA290E7574D1009041DA /* ApplicationServices.framework */, 7B78D40D0E54FE8000609465 /* Foundation.framework */, ); name = Frameworks; @@ -1299,6 +1308,7 @@ 825403F20D92D31D0006B936 /* point.cc in Sources */, 825403F50D92D31D0006B936 /* rect.cc in Sources */, 7B8505B30E5B432200730B43 /* size.cc in Sources */, + ABE1BA610E75757C009041DA /* skia_utils_mac.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/base/build/base_unittests.vcproj b/base/build/base_unittests.vcproj index f3993da..c8db389 100644 --- a/base/build/base_unittests.vcproj +++ b/base/build/base_unittests.vcproj @@ -380,7 +380,7 @@ > </File> <File - RelativePath="..\gfx\platform_canvas_unittest_win.cc" + RelativePath="..\gfx\platform_canvas_unittest.cc" > </File> <File diff --git a/base/gfx/SConscript b/base/gfx/SConscript index b9e0d4a..57e61be 100644 --- a/base/gfx/SConscript +++ b/base/gfx/SConscript @@ -62,7 +62,7 @@ if env['PLATFORM'] == 'win32': if env['PLATFORM'] == 'win32': input_files.extend([ - 'bitmap_platform_device_win.cc', + 'bitmap_platform_device.cc', 'platform_canvas_win.cc', 'platform_device_win.cc', ]) diff --git a/base/gfx/bitmap_platform_device.h b/base/gfx/bitmap_platform_device.h index 83b74df..1efa65c 100644 --- a/base/gfx/bitmap_platform_device.h +++ b/base/gfx/bitmap_platform_device.h @@ -6,17 +6,22 @@ // that can be used by upper-level classes that just need to pass a reference // around. +#if defined(OS_WIN) +#include "base/gfx/bitmap_platform_device_win.h" +#elif defined(OS_MACOSX) +#include "base/gfx/bitmap_platform_device_mac.h" +#elif defined(OS_LINUX) +#include "base/gfx/bitmap_platform_device_linux.h" +#endif + namespace gfx { #if defined(OS_WIN) -class BitmapPlatformDeviceWin; typedef BitmapPlatformDeviceWin BitmapPlatformDevice; #elif defined(OS_MACOSX) -class BitmapPlatformDeviceMac; typedef BitmapPlatformDeviceMac BitmapPlatformDevice; #elif defined(OS_LINUX) -class BitmapPlatformDeviceLinux; typedef BitmapPlatformDeviceLinux BitmapPlatformDevice; #endif -} // namespace gfx +} diff --git a/base/gfx/bitmap_platform_device_mac.h b/base/gfx/bitmap_platform_device_mac.h index 11e1133..a22483e 100755 --- a/base/gfx/bitmap_platform_device_mac.h +++ b/base/gfx/bitmap_platform_device_mac.h @@ -65,7 +65,8 @@ class BitmapPlatformDeviceMac : public PlatformDeviceMac { virtual void DrawToContext(CGContextRef context, int x, int y, const CGRect* src_rect); virtual bool IsVectorial() { return false; } - + virtual void fixupAlphaBeforeCompositing() { }; + // Returns the color value at the specified location. This does not // consider any transforms that may be set on the device. SkColor GetColorAt(int x, int y); diff --git a/base/gfx/platform_canvas.h b/base/gfx/platform_canvas.h index d7433cd..d7442cc 100644 --- a/base/gfx/platform_canvas.h +++ b/base/gfx/platform_canvas.h @@ -8,17 +8,25 @@ #include "build/build_config.h" +#if defined(OS_WIN) +#include "base/gfx/platform_canvas_win.h" namespace gfx { -#if defined(OS_WIN) -class PlatformCanvasWin; typedef PlatformCanvasWin PlatformCanvas; + +} // namespace gfx #elif defined(OS_MACOSX) -class PlatformCanvasMac; +#include "base/gfx/platform_canvas_mac.h" +namespace gfx { + typedef PlatformCanvasMac PlatformCanvas; + +} // namespace gfx #elif defined(OS_LINUX) -class PlatformCanvasLinux; +#include "base/gfx/platform_canvas_linux.h" +namespace gfx { + typedef PlatformCanvasLinux PlatformCanvas; -#endif } // namespace gfx +#endif diff --git a/base/gfx/platform_canvas_mac.cc b/base/gfx/platform_canvas_mac.cc index afd5203..f8f0970 100755 --- a/base/gfx/platform_canvas_mac.cc +++ b/base/gfx/platform_canvas_mac.cc @@ -141,5 +141,10 @@ SkDevice* PlatformCanvasMac::createPlatformDevice(int width, return device; } +SkDevice* PlatformCanvasMac::setBitmapDevice(const SkBitmap&) { + NOTREACHED(); + return NULL; +} + } // namespace gfx diff --git a/base/gfx/platform_canvas_unittest_win.cc b/base/gfx/platform_canvas_unittest.c index a9cf2ae..a9cf2ae 100644 --- a/base/gfx/platform_canvas_unittest_win.cc +++ b/base/gfx/platform_canvas_unittest.c diff --git a/base/gfx/platform_device.h b/base/gfx/platform_device.h index 796eec8..f1c890c 100644 --- a/base/gfx/platform_device.h +++ b/base/gfx/platform_device.h @@ -6,17 +6,22 @@ // that can be used by upper-level classes that just need to pass a reference // around. -namespace gfx { +#if defined(OS_WIN) +#include "base/gfx/platform_device_win.h" +#elif defined(OS_MACOSX) +#include "base/gfx/platform_device_mac.h" +#elif defined(OS_LINUX) +#include "base/gfx/platform_device_linux.h" +#endif +namespace gfx { + #if defined(OS_WIN) -class PlatformDeviceWin; typedef PlatformDeviceWin PlatformDevice; #elif defined(OS_MACOSX) -class PlatformDeviceMac; typedef PlatformDeviceMac PlatformDevice; #elif defined(OS_LINUX) -class PlatformDeviceLinux; typedef PlatformDeviceLinux PlatformDevice; #endif - + } // namespace gfx diff --git a/base/gfx/platform_device_mac.h b/base/gfx/platform_device_mac.h index 8cd2251..69eac95 100755 --- a/base/gfx/platform_device_mac.h +++ b/base/gfx/platform_device_mac.h @@ -59,6 +59,12 @@ class PlatformDeviceMac : public SkDevice { // Returns if the preferred rendering engine is vectorial or bitmap based. virtual bool IsVectorial() = 0; + // On platforms where the native rendering API does not support rendering + // into bitmaps with a premultiplied alpha channel, this call is responsible + // for doing any fixup necessary. It is not used on the Mac, since + // CoreGraphics can handle premultiplied alpha just fine. + virtual void fixupAlphaBeforeCompositing() = 0; + // Initializes the default settings and colors in a device context. static void InitializeCGContext(CGContextRef context); |
