diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 00:38:06 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 00:38:06 +0000 |
commit | 5f948943cc7581a276b2c4eb632af874a8fe469e (patch) | |
tree | 5e1f672ad04adb3c46dcf3ff38d2c0389209412e /chrome | |
parent | ad7a735e4d8752760050a483d9ddd7ce2014a768 (diff) | |
download | chromium_src-5f948943cc7581a276b2c4eb632af874a8fe469e.zip chromium_src-5f948943cc7581a276b2c4eb632af874a8fe469e.tar.gz chromium_src-5f948943cc7581a276b2c4eb632af874a8fe469e.tar.bz2 |
Enable off-by-default monitor color management on Windows. This is enabled via
a command-line switch.
BUG=4938
Review URL: http://codereview.chromium.org/131002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/backing_store.h | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_win.cc | 37 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_win.cc | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 2 |
5 files changed, 50 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index 0fb47ab..fd2d13b 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -52,6 +52,9 @@ class BackingStore { #if defined(OS_WIN) HDC hdc() { return hdc_; } + // Returns true if we should convert to the monitor profile when painting. + static bool ColorManagementEnabled(); + #elif defined(OS_MACOSX) skia::PlatformCanvas* canvas() { return &canvas_; } diff --git a/chrome/browser/renderer_host/backing_store_win.cc b/chrome/browser/renderer_host/backing_store_win.cc index b3a1839..54b67c6 100644 --- a/chrome/browser/renderer_host/backing_store_win.cc +++ b/chrome/browser/renderer_host/backing_store_win.cc @@ -4,16 +4,37 @@ #include "chrome/browser/renderer_host/backing_store.h" +#include "base/command_line.h" #include "base/gfx/gdi_util.h" #include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/transport_dib.h" namespace { // Creates a dib conforming to the height/width/section parameters passed in. HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { - BITMAPINFOHEADER hdr; - gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); + BITMAPV5HEADER hdr = {0}; + ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); + + // These values are shared with gfx::PlatformDevice + hdr.bV5Size = sizeof(BITMAPINFOHEADER); + hdr.bV5Width = width; + hdr.bV5Height = -height; // minus means top-down bitmap + hdr.bV5Planes = 1; + hdr.bV5BitCount = color_depth; + hdr.bV5Compression = BI_RGB; // no compression + hdr.bV5SizeImage = 0; + hdr.bV5XPelsPerMeter = 1; + hdr.bV5YPelsPerMeter = 1; + hdr.bV5ClrUsed = 0; + hdr.bV5ClrImportant = 0; + + if (BackingStore::ColorManagementEnabled()) { + hdr.bV5CSType = LCS_sRGB; + hdr.bV5Intent = LCS_GM_IMAGES; + } + void* data = NULL; HANDLE dib = CreateDIBSection(dc, reinterpret_cast<BITMAPINFO*>(&hdr), 0, &data, NULL, 0); @@ -53,6 +74,18 @@ BackingStore::~BackingStore() { DeleteDC(hdc_); } +// static +bool BackingStore::ColorManagementEnabled() { + static bool enabled = false; + static bool checked = false; + if (!checked) { + checked = true; + const CommandLine& command = *CommandLine::ForCurrentProcess(); + enabled = command.HasSwitch(switches::kEnableMonitorProfile); + } + return enabled; +} + void BackingStore::PaintRect(base::ProcessHandle process, TransportDIB* bitmap, const gfx::Rect& bitmap_rect) { diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 15bee47..e5091d6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -711,6 +711,9 @@ void RenderWidgetHostViewWin::OnPaint(HDC dc) { gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect); if (!paint_rect.IsEmpty()) { DrawResizeCorner(paint_rect, backing_store->hdc()); + bool manage_colors = BackingStore::ColorManagementEnabled(); + if (manage_colors) + SetICMMode(paint_dc.m_hDC, ICM_ON); BitBlt(paint_dc.m_hDC, paint_rect.x(), paint_rect.y(), @@ -720,6 +723,8 @@ void RenderWidgetHostViewWin::OnPaint(HDC dc) { paint_rect.x(), paint_rect.y(), SRCCOPY); + if (manage_colors) + SetICMMode(paint_dc.m_hDC, ICM_OFF); } // Fill the remaining portion of the damaged_rect with the background diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 2b3bf60..a1e8f70 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -509,4 +509,9 @@ const wchar_t kTryChromeAgain[] = L"try-chrome-again"; // gracefully. const wchar_t kFileDescriptorLimit[] = L"file-descriptor-limit"; +// On Windows, converts the page to the currently-installed monitor profile. +// This does NOT enable color management for images. The source is still assumed +// to be sRGB. +const wchar_t kEnableMonitorProfile[] = L"enable-monitor-profile"; + } // namespace switches diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 3b76100..acc60f6 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -194,6 +194,8 @@ extern const wchar_t kTryChromeAgain[]; extern const wchar_t kFileDescriptorLimit[]; +extern const wchar_t kEnableMonitorProfile[]; + } // namespace switches #endif // CHROME_COMMON_CHROME_SWITCHES_H_ |