| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/backing_store_win.h" | 5 #include "content/browser/renderer_host/backing_store_win.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
| 12 #include "ui/gfx/gdi_util.h" | 12 #include "ui/gfx/gdi_util.h" |
| 13 #include "ui/surface/transport_dib.h" | 13 #include "ui/surface/transport_dib.h" |
| 14 | 14 |
| 15 namespace content { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Creates a dib conforming to the height/width/section parameters passed in. | 18 // Creates a dib conforming to the height/width/section parameters passed in. |
| 18 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { | 19 HANDLE CreateDIB(HDC dc, int width, int height, int color_depth) { |
| 19 BITMAPV5HEADER hdr = {0}; | 20 BITMAPV5HEADER hdr = {0}; |
| 20 ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); | 21 ZeroMemory(&hdr, sizeof(BITMAPV5HEADER)); |
| 21 | 22 |
| 22 // These values are shared with gfx::PlatformDevice | 23 // These values are shared with gfx::PlatformDevice |
| 23 hdr.bV5Size = sizeof(BITMAPINFOHEADER); | 24 hdr.bV5Size = sizeof(BITMAPINFOHEADER); |
| 24 hdr.bV5Width = width; | 25 hdr.bV5Width = width; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 rv = StretchDIBits(hdc, | 63 rv = StretchDIBits(hdc, |
| 63 dest_x, dest_y, dest_w, dest_h, | 64 dest_x, dest_y, dest_w, dest_h, |
| 64 src_x, bottom_up_src_y, src_w, src_h, | 65 src_x, bottom_up_src_y, src_w, src_h, |
| 65 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); | 66 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); |
| 66 } | 67 } |
| 67 DCHECK(rv != GDI_ERROR); | 68 DCHECK(rv != GDI_ERROR); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace | 71 } // namespace |
| 71 | 72 |
| 72 BackingStoreWin::BackingStoreWin(content::RenderWidgetHost* widget, | 73 BackingStoreWin::BackingStoreWin(RenderWidgetHost* widget, |
| 73 const gfx::Size& size) | 74 const gfx::Size& size) |
| 74 : BackingStore(widget, size), | 75 : BackingStore(widget, size), |
| 75 backing_store_dib_(NULL), | 76 backing_store_dib_(NULL), |
| 76 original_bitmap_(NULL) { | 77 original_bitmap_(NULL) { |
| 77 HDC screen_dc = ::GetDC(NULL); | 78 HDC screen_dc = ::GetDC(NULL); |
| 78 color_depth_ = ::GetDeviceCaps(screen_dc, BITSPIXEL); | 79 color_depth_ = ::GetDeviceCaps(screen_dc, BITSPIXEL); |
| 79 // Color depths less than 16 bpp require a palette to be specified. Instead, | 80 // Color depths less than 16 bpp require a palette to be specified. Instead, |
| 80 // we specify the desired color depth as 16 which lets the OS to come up | 81 // we specify the desired color depth as 16 which lets the OS to come up |
| 81 // with an approximation. | 82 // with an approximation. |
| 82 if (color_depth_ < 16) | 83 if (color_depth_ < 16) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 107 enabled = command.HasSwitch(switches::kEnableMonitorProfile); | 108 enabled = command.HasSwitch(switches::kEnableMonitorProfile); |
| 108 } | 109 } |
| 109 return enabled; | 110 return enabled; |
| 110 } | 111 } |
| 111 | 112 |
| 112 size_t BackingStoreWin::MemorySize() { | 113 size_t BackingStoreWin::MemorySize() { |
| 113 return size().GetArea() * (color_depth_ / 8); | 114 return size().GetArea() * (color_depth_ / 8); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void BackingStoreWin::PaintToBackingStore( | 117 void BackingStoreWin::PaintToBackingStore( |
| 117 content::RenderProcessHost* process, | 118 RenderProcessHost* process, |
| 118 TransportDIB::Id bitmap, | 119 TransportDIB::Id bitmap, |
| 119 const gfx::Rect& bitmap_rect, | 120 const gfx::Rect& bitmap_rect, |
| 120 const std::vector<gfx::Rect>& copy_rects, | 121 const std::vector<gfx::Rect>& copy_rects, |
| 121 float scale_factor, | 122 float scale_factor, |
| 122 const base::Closure& completion_callback, | 123 const base::Closure& completion_callback, |
| 123 bool* scheduled_completion_callback) { | 124 bool* scheduled_completion_callback) { |
| 124 *scheduled_completion_callback = false; | 125 *scheduled_completion_callback = false; |
| 125 if (!backing_store_dib_) { | 126 if (!backing_store_dib_) { |
| 126 backing_store_dib_ = CreateDIB(hdc_, size().width(), | 127 backing_store_dib_ = CreateDIB(hdc_, size().width(), |
| 127 size().height(), color_depth_); | 128 size().height(), color_depth_); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 172 |
| 172 void BackingStoreWin::ScrollBackingStore(int dx, int dy, | 173 void BackingStoreWin::ScrollBackingStore(int dx, int dy, |
| 173 const gfx::Rect& clip_rect, | 174 const gfx::Rect& clip_rect, |
| 174 const gfx::Size& view_size) { | 175 const gfx::Size& view_size) { |
| 175 RECT damaged_rect, r = clip_rect.ToRECT(); | 176 RECT damaged_rect, r = clip_rect.ToRECT(); |
| 176 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 177 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
| 177 | 178 |
| 178 // TODO(darin): this doesn't work if dx and dy are both non-zero! | 179 // TODO(darin): this doesn't work if dx and dy are both non-zero! |
| 179 DCHECK(dx == 0 || dy == 0); | 180 DCHECK(dx == 0 || dy == 0); |
| 180 } | 181 } |
| 182 |
| 183 } // namespace content |
| OLD | NEW |