Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/backing_store.h" | 5 #include "chrome/browser/renderer_host/backing_store.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/gfx/gdi_util.h" | 8 #include "base/gfx/gdi_util.h" |
| 8 #include "chrome/browser/renderer_host/render_widget_host.h" | 9 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 10 #include "chrome/common/chrome_switches.h" | |
| 9 #include "chrome/common/transport_dib.h" | 11 #include "chrome/common/transport_dib.h" |
| 10 | 12 |
| 11 namespace { | 13 namespace { |
| 12 | 14 |
| 13 // Creates a dib conforming to the height/width/section parameters passed in. | 15 // Creates a dib conforming to the height/width/section parameters passed in. |
| 14 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { | 16 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { |
| 15 BITMAPINFOHEADER hdr; | 17 BITMAPV5HEADER hdr = {0}; |
| 16 gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); | 18 ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); |
| 19 | |
| 20 // These values are shared with gfx::PlatformDevice | |
| 21 hdr.bV5Size = sizeof(BITMAPINFOHEADER); | |
| 22 hdr.bV5Width = width; | |
| 23 hdr.bV5Height = -height; // minus means top-down bitmap | |
| 24 hdr.bV5Planes = 1; | |
| 25 hdr.bV5BitCount = color_depth; | |
| 26 hdr.bV5Compression = BI_RGB; // no compression | |
| 27 hdr.bV5SizeImage = 0; | |
| 28 hdr.bV5XPelsPerMeter = 1; | |
| 29 hdr.bV5YPelsPerMeter = 1; | |
| 30 hdr.bV5ClrUsed = 0; | |
|
M-A Ruel
2009/06/18 00:19:09
nit: Do you really want to keep the = 0?
| |
| 31 hdr.bV5ClrImportant = 0; | |
| 32 | |
| 33 if (BackingStore::ColorManagementEnabled()) { | |
| 34 hdr.bV5CSType = LCS_sRGB; | |
| 35 hdr.bV5Intent = LCS_GM_IMAGES; | |
| 36 } | |
| 37 | |
| 17 void* data = NULL; | 38 void* data = NULL; |
| 18 HANDLE dib = CreateDIBSection(dc, reinterpret_cast<BITMAPINFO*>(&hdr), | 39 HANDLE dib = CreateDIBSection(dc, reinterpret_cast<BITMAPINFO*>(&hdr), |
| 19 0, &data, NULL, 0); | 40 0, &data, NULL, 0); |
| 20 DCHECK(data); | 41 DCHECK(data); |
| 21 return dib; | 42 return dib; |
| 22 } | 43 } |
| 23 | 44 |
| 24 } // namespace | 45 } // namespace |
| 25 | 46 |
| 26 // BackingStore (Windows) ------------------------------------------------------ | 47 // BackingStore (Windows) ------------------------------------------------------ |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 46 if (original_bitmap_) { | 67 if (original_bitmap_) { |
| 47 SelectObject(hdc_, original_bitmap_); | 68 SelectObject(hdc_, original_bitmap_); |
| 48 } | 69 } |
| 49 if (backing_store_dib_) { | 70 if (backing_store_dib_) { |
| 50 DeleteObject(backing_store_dib_); | 71 DeleteObject(backing_store_dib_); |
| 51 backing_store_dib_ = NULL; | 72 backing_store_dib_ = NULL; |
| 52 } | 73 } |
| 53 DeleteDC(hdc_); | 74 DeleteDC(hdc_); |
| 54 } | 75 } |
| 55 | 76 |
| 77 // static | |
| 78 bool BackingStore::ColorManagementEnabled() { | |
| 79 static bool enabled = false; | |
|
M-A Ruel
2009/06/18 00:19:09
humm...
There's one issue I easily see is RDP ses
| |
| 80 static bool checked = false; | |
| 81 if (!checked) { | |
| 82 checked = true; | |
| 83 const CommandLine& command = *CommandLine::ForCurrentProcess(); | |
| 84 enabled = command.HasSwitch(switches::kEnableMonitorProfile); | |
| 85 } | |
| 86 return enabled; | |
| 87 } | |
| 88 | |
| 56 void BackingStore::PaintRect(base::ProcessHandle process, | 89 void BackingStore::PaintRect(base::ProcessHandle process, |
| 57 TransportDIB* bitmap, | 90 TransportDIB* bitmap, |
| 58 const gfx::Rect& bitmap_rect) { | 91 const gfx::Rect& bitmap_rect) { |
| 59 if (!backing_store_dib_) { | 92 if (!backing_store_dib_) { |
| 60 backing_store_dib_ = CreateDIB(hdc_, size_.width(), | 93 backing_store_dib_ = CreateDIB(hdc_, size_.width(), |
| 61 size_.height(), color_depth_); | 94 size_.height(), color_depth_); |
| 62 if (!backing_store_dib_) { | 95 if (!backing_store_dib_) { |
| 63 NOTREACHED(); | 96 NOTREACHED(); |
| 64 return; | 97 return; |
| 65 } | 98 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 93 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 126 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
| 94 | 127 |
| 95 // TODO(darin): this doesn't work if dx and dy are both non-zero! | 128 // TODO(darin): this doesn't work if dx and dy are both non-zero! |
| 96 DCHECK(dx == 0 || dy == 0); | 129 DCHECK(dx == 0 || dy == 0); |
| 97 | 130 |
| 98 // We expect that damaged_rect should equal bitmap_rect. | 131 // We expect that damaged_rect should equal bitmap_rect. |
| 99 DCHECK(gfx::Rect(damaged_rect) == bitmap_rect); | 132 DCHECK(gfx::Rect(damaged_rect) == bitmap_rect); |
| 100 | 133 |
| 101 PaintRect(process, bitmap, bitmap_rect); | 134 PaintRect(process, bitmap, bitmap_rect); |
| 102 } | 135 } |
| OLD | NEW |