diff options
-rw-r--r-- | chrome/browser/renderer_host/backing_store.cc | 217 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store.h | 260 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_win.cc | 244 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 6 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 4 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 12 | ||||
-rw-r--r-- | chrome/renderer/render_widget.cc | 5 | ||||
-rwxr-xr-x | skia/ext/platform_canvas_mac.cc | 3 | ||||
-rwxr-xr-x | skia/ext/platform_canvas_mac.h | 4 | ||||
-rw-r--r-- | skia/ext/platform_canvas_win.cc | 2 | ||||
-rw-r--r-- | skia/ext/platform_canvas_win.h | 4 |
11 files changed, 380 insertions, 381 deletions
diff --git a/chrome/browser/renderer_host/backing_store.cc b/chrome/browser/renderer_host/backing_store.cc index 28d47bc..9cff6aa7 100644 --- a/chrome/browser/renderer_host/backing_store.cc +++ b/chrome/browser/renderer_host/backing_store.cc @@ -1,109 +1,108 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/renderer_host/backing_store.h"
-
-class RenderWidgetHost;
-
-namespace {
-
-typedef OwningMRUCache<RenderWidgetHost*, BackingStore*> BackingStoreCache;
-static BackingStoreCache* cache = NULL;
-
-// Returns the size of the backing store cache.
-// TODO(iyengar) Make this dynamic, i.e. based on the available resources
-// on the machine.
-static int GetBackingStoreCacheSize() {
- const int kMaxSize = 5;
- return kMaxSize;
-}
-
-// Creates the backing store for the host based on the dimensions passed in.
-// Removes the existing backing store if there is one.
-BackingStore* CreateBackingStore(RenderWidgetHost* host,
- const gfx::Rect& backing_store_rect) {
- BackingStoreManager::RemoveBackingStore(host);
-
- BackingStore* backing_store = new BackingStore(backing_store_rect.size());
- int backing_store_cache_size = GetBackingStoreCacheSize();
- if (backing_store_cache_size > 0) {
- if (!cache)
- cache = new BackingStoreCache(backing_store_cache_size);
- cache->Put(host, backing_store);
- }
- return backing_store;
-}
-
-} // namespace
-
-// BackingStoreManager ---------------------------------------------------------
-
-// static
-BackingStore* BackingStoreManager::GetBackingStore(
- RenderWidgetHost* host,
- const gfx::Size& desired_size) {
- BackingStore* backing_store = Lookup(host);
- if (backing_store) {
- // If we already have a backing store, then make sure it is the correct
- // size.
- if (backing_store->size() == desired_size)
- return backing_store;
- backing_store = NULL;
- }
-
- return backing_store;
-}
-
-// static
-BackingStore* BackingStoreManager::PrepareBackingStore(
- RenderWidgetHost* host,
- const gfx::Rect& backing_store_rect,
- base::ProcessHandle process_handle,
- HANDLE bitmap_section,
- const gfx::Rect& bitmap_rect,
- bool* needs_full_paint) {
- BackingStore* backing_store = GetBackingStore(host,
- backing_store_rect.size());
- if (!backing_store) {
- // We need to get Webkit to generate a new paint here, as we
- // don't have a previous snapshot.
- if (bitmap_rect != backing_store_rect) {
- DCHECK(needs_full_paint != NULL);
- *needs_full_paint = true;
- }
- backing_store = CreateBackingStore(host, backing_store_rect);
- }
-
- DCHECK(backing_store != NULL);
- backing_store->PaintRect(process_handle, bitmap_section, bitmap_rect);
- return backing_store;
-}
-
-// static
-BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) {
- if (cache) {
- BackingStoreCache::iterator it = cache->Peek(host);
- if (it != cache->end())
- return it->second;
- }
- return NULL;
-}
-
-// static
-void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) {
- if (!cache)
- return;
-
- BackingStoreCache::iterator it = cache->Peek(host);
- if (it == cache->end())
- return;
-
- cache->Erase(it);
-
- if (cache->empty()) {
- delete cache;
- cache = NULL;
- }
-}
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/renderer_host/backing_store.h" + +class RenderWidgetHost; + +namespace { + +typedef OwningMRUCache<RenderWidgetHost*, BackingStore*> BackingStoreCache; +static BackingStoreCache* cache = NULL; + +// Returns the size of the backing store cache. +// TODO(iyengar) Make this dynamic, i.e. based on the available resources +// on the machine. +static int GetBackingStoreCacheSize() { + const int kMaxSize = 5; + return kMaxSize; +} + +// Creates the backing store for the host based on the dimensions passed in. +// Removes the existing backing store if there is one. +BackingStore* CreateBackingStore(RenderWidgetHost* host, + const gfx::Rect& backing_store_rect) { + BackingStoreManager::RemoveBackingStore(host); + + BackingStore* backing_store = new BackingStore(backing_store_rect.size()); + int backing_store_cache_size = GetBackingStoreCacheSize(); + if (backing_store_cache_size > 0) { + if (!cache) + cache = new BackingStoreCache(backing_store_cache_size); + cache->Put(host, backing_store); + } + return backing_store; +} + +} // namespace + +// BackingStoreManager --------------------------------------------------------- + +// static +BackingStore* BackingStoreManager::GetBackingStore( + RenderWidgetHost* host, + const gfx::Size& desired_size) { + BackingStore* backing_store = Lookup(host); + if (backing_store) { + // If we already have a backing store, then make sure it is the correct + // size. + if (backing_store->size() == desired_size) + return backing_store; + backing_store = NULL; + } + + return backing_store; +} + +// static +BackingStore* BackingStoreManager::PrepareBackingStore( + RenderWidgetHost* host, + const gfx::Rect& backing_store_rect, + base::ProcessHandle process_handle, + HANDLE bitmap_section, + const gfx::Rect& bitmap_rect, + bool* needs_full_paint) { + BackingStore* backing_store = GetBackingStore(host, + backing_store_rect.size()); + if (!backing_store) { + // We need to get Webkit to generate a new paint here, as we + // don't have a previous snapshot. + if (bitmap_rect != backing_store_rect) { + DCHECK(needs_full_paint != NULL); + *needs_full_paint = true; + } + backing_store = CreateBackingStore(host, backing_store_rect); + } + + DCHECK(backing_store != NULL); + backing_store->PaintRect(process_handle, bitmap_section, bitmap_rect); + return backing_store; +} + +// static +BackingStore* BackingStoreManager::Lookup(RenderWidgetHost* host) { + if (cache) { + BackingStoreCache::iterator it = cache->Peek(host); + if (it != cache->end()) + return it->second; + } + return NULL; +} + +// static +void BackingStoreManager::RemoveBackingStore(RenderWidgetHost* host) { + if (!cache) + return; + + BackingStoreCache::iterator it = cache->Peek(host); + if (it == cache->end()) + return; + + cache->Erase(it); + + if (cache->empty()) { + delete cache; + cache = NULL; + } +} diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index 07ed517..eddb4c4 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -1,130 +1,130 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_
-#define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_
-
-#include "base/basictypes.h"
-#include "base/gfx/rect.h"
-#include "base/gfx/size.h"
-#include "base/process.h"
-#include "build/build_config.h"
-#include "chrome/common/mru_cache.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#endif
-
-class RenderWidgetHost;
-
-// BackingStore ----------------------------------------------------------------
-
-// Represents a backing store for the pixels in a RenderWidgetHost.
-class BackingStore {
- public:
- BackingStore(const gfx::Size& size);
- ~BackingStore();
-
- const gfx::Size& size() { return size_; }
-
-#if defined(OS_WIN)
- HDC hdc() { return hdc_; }
-#endif
-
- // Paints the bitmap from the renderer onto the backing store.
- // TODO(port): The HANDLE is a shared section on Windows. Abstract this.
- bool PaintRect(base::ProcessHandle process,
- HANDLE bitmap_section,
- const gfx::Rect& bitmap_rect);
-
- // Scrolls the given rect in the backing store, replacing the given region
- // identified by |bitmap_rect| by the bitmap in the file identified by the
- // given file handle.
- // TODO(port): The HANDLE is a shared section on Windows. Abstract this.
- void ScrollRect(base::ProcessHandle process,
- HANDLE bitmap, const gfx::Rect& bitmap_rect,
- int dx, int dy,
- const gfx::Rect& clip_rect,
- const gfx::Size& view_size);
-
- private:
- // The size of the backing store.
- gfx::Size size_;
-
-#if defined(OS_WIN)
- // Creates a dib conforming to the height/width/section parameters passed
- // in. The use_os_color_depth parameter controls whether we use the color
- // depth to create an appropriate dib or not.
- HANDLE CreateDIB(HDC dc,
- int width, int height,
- bool use_os_color_depth,
- HANDLE section);
-
- // The backing store dc.
- HDC hdc_;
-
- // Handle to the backing store dib.
- HANDLE backing_store_dib_;
-
- // Handle to the original bitmap in the dc.
- HANDLE original_bitmap_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(BackingStore);
-};
-
-// BackingStoreManager ---------------------------------------------------------
-
-// This class manages backing stores in the browsr. Every RenderWidgetHost is
-// associated with a backing store which it requests from this class. The
-// hosts don't maintain any references to the backing stores. These backing
-// stores are maintained in a cache which can be trimmed as needed.
-class BackingStoreManager {
- public:
- // Returns a backing store which matches the desired dimensions.
- //
- // backing_store_rect
- // The desired backing store dimensions.
- // Returns a pointer to the backing store on success, NULL on failure.
- static BackingStore* GetBackingStore(RenderWidgetHost* host,
- const gfx::Size& desired_size);
-
- // Returns a backing store which is fully ready for consumption, i.e. the
- // bitmap from the renderer has been copied into the backing store dc, or the
- // bitmap in the backing store dc references the renderer bitmap.
- //
- // backing_store_rect
- // The desired backing store dimensions.
- // process_handle
- // The renderer process handle.
- // bitmap_section
- // The bitmap section from the renderer.
- // bitmap_rect
- // The rect to be painted into the backing store
- // needs_full_paint
- // Set if we need to send out a request to paint the view
- // to the renderer.
- // TODO(port): The HANDLE is a shared section on Windows. Abstract this.
- static BackingStore* PrepareBackingStore(RenderWidgetHost* host,
- const gfx::Rect& backing_store_rect,
- base::ProcessHandle process_handle,
- HANDLE bitmap_section,
- const gfx::Rect& bitmap_rect,
- bool* needs_full_paint);
-
- // Returns a matching backing store for the host.
- // Returns NULL if we fail to find one.
- static BackingStore* Lookup(RenderWidgetHost* host);
-
- // Removes the backing store for the host.
- static void RemoveBackingStore(RenderWidgetHost* host);
-
- private:
- // Not intended for instantiation.
- BackingStoreManager() {}
-
- DISALLOW_COPY_AND_ASSIGN(BackingStoreManager);
-};
-
-#endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ +#define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ + +#include "base/basictypes.h" +#include "base/gfx/rect.h" +#include "base/gfx/size.h" +#include "base/process.h" +#include "build/build_config.h" +#include "chrome/common/mru_cache.h" + +#if defined(OS_WIN) +#include <windows.h> +#endif + +class RenderWidgetHost; + +// BackingStore ---------------------------------------------------------------- + +// Represents a backing store for the pixels in a RenderWidgetHost. +class BackingStore { + public: + explicit BackingStore(const gfx::Size& size); + ~BackingStore(); + + const gfx::Size& size() { return size_; } + +#if defined(OS_WIN) + HDC hdc() { return hdc_; } +#endif + + // Paints the bitmap from the renderer onto the backing store. + // TODO(port): The HANDLE is a shared section on Windows. Abstract this. + bool PaintRect(base::ProcessHandle process, + HANDLE bitmap_section, + const gfx::Rect& bitmap_rect); + + // Scrolls the given rect in the backing store, replacing the given region + // identified by |bitmap_rect| by the bitmap in the file identified by the + // given file handle. + // TODO(port): The HANDLE is a shared section on Windows. Abstract this. + void ScrollRect(base::ProcessHandle process, + HANDLE bitmap, const gfx::Rect& bitmap_rect, + int dx, int dy, + const gfx::Rect& clip_rect, + const gfx::Size& view_size); + + private: + // The size of the backing store. + gfx::Size size_; + +#if defined(OS_WIN) + // Creates a dib conforming to the height/width/section parameters passed + // in. The use_os_color_depth parameter controls whether we use the color + // depth to create an appropriate dib or not. + HANDLE CreateDIB(HDC dc, + int width, int height, + bool use_os_color_depth, + HANDLE section); + + // The backing store dc. + HDC hdc_; + + // Handle to the backing store dib. + HANDLE backing_store_dib_; + + // Handle to the original bitmap in the dc. + HANDLE original_bitmap_; +#endif + + DISALLOW_COPY_AND_ASSIGN(BackingStore); +}; + +// BackingStoreManager --------------------------------------------------------- + +// This class manages backing stores in the browsr. Every RenderWidgetHost is +// associated with a backing store which it requests from this class. The +// hosts don't maintain any references to the backing stores. These backing +// stores are maintained in a cache which can be trimmed as needed. +class BackingStoreManager { + public: + // Returns a backing store which matches the desired dimensions. + // + // backing_store_rect + // The desired backing store dimensions. + // Returns a pointer to the backing store on success, NULL on failure. + static BackingStore* GetBackingStore(RenderWidgetHost* host, + const gfx::Size& desired_size); + + // Returns a backing store which is fully ready for consumption, i.e. the + // bitmap from the renderer has been copied into the backing store dc, or the + // bitmap in the backing store dc references the renderer bitmap. + // + // backing_store_rect + // The desired backing store dimensions. + // process_handle + // The renderer process handle. + // bitmap_section + // The bitmap section from the renderer. + // bitmap_rect + // The rect to be painted into the backing store + // needs_full_paint + // Set if we need to send out a request to paint the view + // to the renderer. + // TODO(port): The HANDLE is a shared section on Windows. Abstract this. + static BackingStore* PrepareBackingStore(RenderWidgetHost* host, + const gfx::Rect& backing_store_rect, + base::ProcessHandle process_handle, + HANDLE bitmap_section, + const gfx::Rect& bitmap_rect, + bool* needs_full_paint); + + // Returns a matching backing store for the host. + // Returns NULL if we fail to find one. + static BackingStore* Lookup(RenderWidgetHost* host); + + // Removes the backing store for the host. + static void RemoveBackingStore(RenderWidgetHost* host); + + private: + // Not intended for instantiation. + BackingStoreManager() {} + + DISALLOW_COPY_AND_ASSIGN(BackingStoreManager); +}; + +#endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ diff --git a/chrome/browser/renderer_host/backing_store_win.cc b/chrome/browser/renderer_host/backing_store_win.cc index 9c8df95..0a09d2e 100644 --- a/chrome/browser/renderer_host/backing_store_win.cc +++ b/chrome/browser/renderer_host/backing_store_win.cc @@ -1,122 +1,122 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/renderer_host/backing_store.h"
-
-#include "base/gfx/gdi_util.h"
-#include "chrome/browser/renderer_host/render_widget_host.h"
-#include "chrome/common/win_util.h"
-
-// BackingStore (Windows) ------------------------------------------------------
-
-BackingStore::BackingStore(const gfx::Size& size)
- : size_(size),
- backing_store_dib_(NULL),
- original_bitmap_(NULL) {
- HDC screen_dc = ::GetDC(NULL);
- hdc_ = CreateCompatibleDC(screen_dc);
- ReleaseDC(NULL, screen_dc);
-}
-
-BackingStore::~BackingStore() {
- DCHECK(hdc_);
-
- DeleteDC(hdc_);
-
- if (backing_store_dib_) {
- DeleteObject(backing_store_dib_);
- backing_store_dib_ = NULL;
- }
-}
-
-bool BackingStore::PaintRect(base::ProcessHandle process,
- HANDLE bitmap_section,
- const gfx::Rect& bitmap_rect) {
- // The bitmap received is valid only in the renderer process.
- HANDLE valid_bitmap =
- win_util::GetSectionFromProcess(bitmap_section, process, false);
- if (!valid_bitmap)
- return false;
-
- if (!backing_store_dib_) {
- backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true,
- NULL);
- DCHECK(backing_store_dib_ != NULL);
- original_bitmap_ = SelectObject(hdc_, backing_store_dib_);
- }
-
- // TODO(darin): protect against integer overflow
- DWORD size = 4 * bitmap_rect.width() * bitmap_rect.height();
- void* backing_store_data = MapViewOfFile(valid_bitmap, FILE_MAP_READ, 0, 0,
- size);
- // These values are shared with gfx::PlatformDevice
- BITMAPINFOHEADER hdr;
- gfx::CreateBitmapHeader(bitmap_rect.width(), bitmap_rect.height(), &hdr);
- // Account for a bitmap_rect that exceeds the bounds of our view
- gfx::Rect view_rect(0, 0, size_.width(), size_.height());
- gfx::Rect paint_rect = view_rect.Intersect(bitmap_rect);
-
- StretchDIBits(hdc_,
- paint_rect.x(),
- paint_rect.y(),
- paint_rect.width(),
- paint_rect.height(),
- 0, 0, // source x,y
- paint_rect.width(),
- paint_rect.height(),
- backing_store_data,
- reinterpret_cast<BITMAPINFO*>(&hdr),
- DIB_RGB_COLORS,
- SRCCOPY);
-
- UnmapViewOfFile(backing_store_data);
- CloseHandle(valid_bitmap);
- return true;
-}
-
-void BackingStore::ScrollRect(base::ProcessHandle process,
- HANDLE bitmap, const gfx::Rect& bitmap_rect,
- int dx, int dy,
- const gfx::Rect& clip_rect,
- const gfx::Size& view_size) {
- RECT damaged_rect, r = clip_rect.ToRECT();
- ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect);
-
- // TODO(darin): this doesn't work if dx and dy are both non-zero!
- DCHECK(dx == 0 || dy == 0);
-
- // We expect that damaged_rect should equal bitmap_rect.
- DCHECK(gfx::Rect(damaged_rect) == bitmap_rect);
-
- PaintRect(process, bitmap, bitmap_rect);
-}
-
-HANDLE BackingStore::CreateDIB(HDC dc,
- int width, int height,
- bool use_system_color_depth,
- HANDLE section) {
- BITMAPINFOHEADER hdr;
-
- if (use_system_color_depth) {
- HDC screen_dc = ::GetDC(NULL);
- int color_depth = GetDeviceCaps(screen_dc, BITSPIXEL);
- ::ReleaseDC(NULL, screen_dc);
-
- // Color depths less than 16 bpp require a palette to be specified in the
- // BITMAPINFO structure passed to CreateDIBSection. Instead of creating
- // the palette, we specify the desired color depth as 16 which allows the
- // OS to come up with an approximation. Tested this with 8bpp.
- if (color_depth < 16)
- color_depth = 16;
-
- gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr);
- } else {
- gfx::CreateBitmapHeader(width, height, &hdr);
- }
- void* data = NULL;
- HANDLE dib =
- CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr),
- 0, &data, section, 0);
- return dib;
-}
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/renderer_host/backing_store.h" + +#include "base/gfx/gdi_util.h" +#include "chrome/browser/renderer_host/render_widget_host.h" +#include "chrome/common/win_util.h" + +// BackingStore (Windows) ------------------------------------------------------ + +BackingStore::BackingStore(const gfx::Size& size) + : size_(size), + backing_store_dib_(NULL), + original_bitmap_(NULL) { + HDC screen_dc = ::GetDC(NULL); + hdc_ = CreateCompatibleDC(screen_dc); + ReleaseDC(NULL, screen_dc); +} + +BackingStore::~BackingStore() { + DCHECK(hdc_); + + DeleteDC(hdc_); + + if (backing_store_dib_) { + DeleteObject(backing_store_dib_); + backing_store_dib_ = NULL; + } +} + +bool BackingStore::PaintRect(base::ProcessHandle process, + HANDLE bitmap_section, + const gfx::Rect& bitmap_rect) { + // The bitmap received is valid only in the renderer process. + HANDLE valid_bitmap = + win_util::GetSectionFromProcess(bitmap_section, process, false); + if (!valid_bitmap) + return false; + + if (!backing_store_dib_) { + backing_store_dib_ = CreateDIB(hdc_, size_.width(), size_.height(), true, + NULL); + DCHECK(backing_store_dib_ != NULL); + original_bitmap_ = SelectObject(hdc_, backing_store_dib_); + } + + // TODO(darin): protect against integer overflow + DWORD size = 4 * bitmap_rect.width() * bitmap_rect.height(); + void* backing_store_data = MapViewOfFile(valid_bitmap, FILE_MAP_READ, 0, 0, + size); + // These values are shared with gfx::PlatformDevice + BITMAPINFOHEADER hdr; + gfx::CreateBitmapHeader(bitmap_rect.width(), bitmap_rect.height(), &hdr); + // Account for a bitmap_rect that exceeds the bounds of our view + gfx::Rect view_rect(0, 0, size_.width(), size_.height()); + gfx::Rect paint_rect = view_rect.Intersect(bitmap_rect); + + StretchDIBits(hdc_, + paint_rect.x(), + paint_rect.y(), + paint_rect.width(), + paint_rect.height(), + 0, 0, // source x,y + paint_rect.width(), + paint_rect.height(), + backing_store_data, + reinterpret_cast<BITMAPINFO*>(&hdr), + DIB_RGB_COLORS, + SRCCOPY); + + UnmapViewOfFile(backing_store_data); + CloseHandle(valid_bitmap); + return true; +} + +void BackingStore::ScrollRect(base::ProcessHandle process, + HANDLE bitmap, const gfx::Rect& bitmap_rect, + int dx, int dy, + const gfx::Rect& clip_rect, + const gfx::Size& view_size) { + RECT damaged_rect, r = clip_rect.ToRECT(); + ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); + + // TODO(darin): this doesn't work if dx and dy are both non-zero! + DCHECK(dx == 0 || dy == 0); + + // We expect that damaged_rect should equal bitmap_rect. + DCHECK(gfx::Rect(damaged_rect) == bitmap_rect); + + PaintRect(process, bitmap, bitmap_rect); +} + +HANDLE BackingStore::CreateDIB(HDC dc, + int width, int height, + bool use_system_color_depth, + HANDLE section) { + BITMAPINFOHEADER hdr; + + if (use_system_color_depth) { + HDC screen_dc = ::GetDC(NULL); + int color_depth = GetDeviceCaps(screen_dc, BITSPIXEL); + ::ReleaseDC(NULL, screen_dc); + + // Color depths less than 16 bpp require a palette to be specified in the + // BITMAPINFO structure passed to CreateDIBSection. Instead of creating + // the palette, we specify the desired color depth as 16 which allows the + // OS to come up with an approximation. Tested this with 8bpp. + if (color_depth < 16) + color_depth = 16; + + gfx::CreateBitmapHeaderWithColorDepth(width, height, color_depth, &hdr); + } else { + gfx::CreateBitmapHeader(width, height, &hdr); + } + void* data = NULL; + HANDLE dib = + CreateDIBSection(hdc_, reinterpret_cast<BITMAPINFO*>(&hdr), + 0, &data, section, 0); + return dib; +} diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 281c61b..5914c74 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -194,11 +194,11 @@ BackingStore* RenderWidgetHost::GetBackingStore() { DCHECK(!is_hidden_) << "GetBackingStore called while hidden!"; // We might have a cached backing store that we can reuse! - BackingStore* backing_store = + BackingStore* backing_store = BackingStoreManager::GetBackingStore(this, current_size_); // If we fail to find a backing store in the cache, send out a request // to the renderer to paint the view if required. - if (!backing_store && !repaint_ack_pending_ && !resize_ack_pending_ && + if (!backing_store && !repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { repaint_start_time_ = TimeTicks::Now(); repaint_ack_pending_ = true; @@ -562,7 +562,7 @@ void RenderWidgetHost::PaintBackingStoreRect(HANDLE bitmap, gfx::Rect view_rect(0, 0, view_size.width(), view_size.height()); bool needs_full_paint = false; - BackingStore* backing_store = + BackingStore* backing_store = BackingStoreManager::PrepareBackingStore(this, view_rect, process_->process().handle(), bitmap, bitmap_rect, diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index fa459a6..dd756d7 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -558,9 +558,9 @@ struct ParamTraits<ContextNode> { static void Log(const param_type& p, std::wstring* l) { std::wstring event = L""; - if (!p.type) + if (!p.type) { event.append(L"NONE"); - else { + } else { event.append(L"("); if (p.type & ContextNode::PAGE) event.append(L"PAGE|"); diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index c03a110..70ed328 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -389,7 +389,7 @@ IPC_BEGIN_MESSAGES(View, 1) ViewHostMsg_Accessibility_Out_Params /* output parameters */) - // Requests the renderer to clear cashed accessibility information. Takes an + // Requests the renderer to clear cashed accessibility information. Takes an // id to clear a specific hashmap entry, and a bool; true clears all, false // does not. IPC_MESSAGE_ROUTED2(ViewMsg_ClearAccessibilityInfo, @@ -404,7 +404,7 @@ IPC_BEGIN_MESSAGES(View, 1) // Get html data by serializing all frames of current page with lists // which contain all resource links that have local copy. IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, - std::vector<std::wstring> /* urls which have local copy */, + std::vector<std::wstring> /* urls that have local copy */, std::vector<std::wstring> /* paths of local copy */, std::wstring /* local directory path */) @@ -450,9 +450,9 @@ IPC_BEGIN_MESSAGES(View, 1) gfx::Size /* The view size to be repainted */) #ifdef CHROME_PERSONALIZATION - IPC_MESSAGE_ROUTED2(ViewMsg_PersonalizationEvent, + IPC_MESSAGE_ROUTED2(ViewMsg_PersonalizationEvent, std::string /* event name */, - std::string /* event arguments */) + std::string /* event arguments */) #endif // Posts a message to the renderer. IPC_MESSAGE_ROUTED2(ViewMsg_HandleMessageFromExternalHost, @@ -576,8 +576,8 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) // TODO(darin): use a UTF-8 string to reduce data size IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateTitle, int32, std::wstring) - // Change the encoding name of the page in UI when the page has detected proper - // encoding name. + // Change the encoding name of the page in UI when the page has detected + // proper encoding name. IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateEncoding, std::wstring /* new encoding name */) diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 5d3fa3c..b63b655 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -655,9 +655,10 @@ void RenderWidget::GetRootWindowRect(WebWidget* webwidget, gfx::Rect* rect) { Send(new ViewHostMsg_GetRootWindowRect(routing_id_, host_window_, rect)); } -void RenderWidget::GetRootWindowResizerRect(WebWidget* webwidget, +void RenderWidget::GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect) { - Send(new ViewHostMsg_GetRootWindowResizerRect(routing_id_, host_window_, rect)); + Send(new ViewHostMsg_GetRootWindowResizerRect(routing_id_, host_window_, + rect)); } void RenderWidget::OnImeSetInputMode(bool is_active) { diff --git a/skia/ext/platform_canvas_mac.cc b/skia/ext/platform_canvas_mac.cc index 6d08454..4acbaa6 100755 --- a/skia/ext/platform_canvas_mac.cc +++ b/skia/ext/platform_canvas_mac.cc @@ -36,7 +36,7 @@ bool PlatformCanvasMac::initialize(int width, return false; setDevice(device); - device->unref(); // was created with refcount 1, and setDevice also refs + device->unref(); // was created with refcount 1, and setDevice also refs return true; } @@ -77,4 +77,3 @@ SkDevice* PlatformCanvasMac::setBitmapDevice(const SkBitmap&) { } } // namespace skia - diff --git a/skia/ext/platform_canvas_mac.h b/skia/ext/platform_canvas_mac.h index adcdb86..4f7f524 100755 --- a/skia/ext/platform_canvas_mac.h +++ b/skia/ext/platform_canvas_mac.h @@ -23,7 +23,8 @@ class PlatformCanvasMac : public SkCanvas { // If you use the version with no arguments, you MUST call initialize() PlatformCanvasMac(); PlatformCanvasMac(int width, int height, bool is_opaque); - PlatformCanvasMac(int width, int height, bool is_opaque, CGContextRef context); + PlatformCanvasMac(int width, int height, bool is_opaque, + CGContextRef context); virtual ~PlatformCanvasMac(); // For two-part init, call if you use the no-argument constructor above @@ -85,4 +86,3 @@ class PlatformCanvasMac : public SkCanvas { } // namespace skia #endif // SKIA_EXT_PLATFORM_CANVAS_MAC_H_ - diff --git a/skia/ext/platform_canvas_win.cc b/skia/ext/platform_canvas_win.cc index edb425e..ed0d6d7 100644 --- a/skia/ext/platform_canvas_win.cc +++ b/skia/ext/platform_canvas_win.cc @@ -75,7 +75,7 @@ bool PlatformCanvasWin::initialize(int width, return false; setDevice(device); - device->unref(); // was created with refcount 1, and setDevice also refs + device->unref(); // was created with refcount 1, and setDevice also refs return true; } diff --git a/skia/ext/platform_canvas_win.h b/skia/ext/platform_canvas_win.h index e0e6e70..88f9cea 100644 --- a/skia/ext/platform_canvas_win.h +++ b/skia/ext/platform_canvas_win.h @@ -99,7 +99,8 @@ class PlatformCanvasWin : public SkCanvas { template <class T> class CanvasPaintT : public T { public: - CanvasPaintT(HWND hwnd) : hwnd_(hwnd), paint_dc_(NULL), for_paint_(true) { + explicit CanvasPaintT(HWND hwnd) : hwnd_(hwnd), paint_dc_(NULL), + for_paint_(true) { memset(&ps_, 0, sizeof(ps_)); initPaint(true); } @@ -198,4 +199,3 @@ typedef CanvasPaintT<PlatformCanvasWin> PlatformCanvasWinPaint; } // namespace skia #endif // SKIA_EXT_PLATFORM_CANVAS_WIN_H_ - |