From 666f176c1156fba64ce6c9c935455fdf526be2e7 Mon Sep 17 00:00:00 2001 From: "mmoss@chromium.org" Date: Sat, 7 Mar 2009 00:50:40 +0000 Subject: Rename _posix to _mac since it doesn't build on Linux. Fixes a gyp Linux build error because gyp expects all _posix files to actually build on all posix platforms. Review URL: http://codereview.chromium.org/39290 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11182 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/renderer_host/backing_store_mac.cc | 122 +++++++++++++++++++++ .../browser/renderer_host/backing_store_posix.cc | 122 --------------------- chrome/chrome.gyp | 2 +- 3 files changed, 123 insertions(+), 123 deletions(-) create mode 100644 chrome/browser/renderer_host/backing_store_mac.cc delete mode 100644 chrome/browser/renderer_host/backing_store_posix.cc (limited to 'chrome') diff --git a/chrome/browser/renderer_host/backing_store_mac.cc b/chrome/browser/renderer_host/backing_store_mac.cc new file mode 100644 index 0000000..cacc6f0 --- /dev/null +++ b/chrome/browser/renderer_host/backing_store_mac.cc @@ -0,0 +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/logging.h" +#include "chrome/common/transport_dib.h" +#include "skia/ext/platform_canvas.h" +#include "skia/include/SkBitmap.h" +#include "skia/include/SkCanvas.h" + +BackingStore::BackingStore(const gfx::Size& size) + : size_(size) { + if (!canvas_.initialize(size.width(), size.height(), true)) + SK_CRASH(); +} + +BackingStore::~BackingStore() { +} + +void BackingStore::PaintRect(base::ProcessHandle process, + TransportDIB* bitmap, + const gfx::Rect& bitmap_rect) { + SkBitmap skbitmap; + skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), + bitmap_rect.height(), 4 * bitmap_rect.width()); + + skbitmap.setPixels(bitmap->memory()); + + canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); +} + +void BackingStore::ScrollRect(base::ProcessHandle process, + TransportDIB* bitmap, + const gfx::Rect& bitmap_rect, + int dx, int dy, + const gfx::Rect& clip_rect, + const gfx::Size& view_size) { + // WARNING: this is temporary code until a real solution is found for Mac and + // Linux. + // + // On Windows, there's a ScrollDC call which performs horiz and vertical + // scrolling + // + // clip_rect: MSDN says "The only bits that will be painted are the + // bits that remain inside this rectangle after the scroll operation has been + // completed." + // + // The Windows code always sets the whole backing store as the source of the + // scroll. Thus, we only have to worry about pixels which will end up inside + // the clipping rectangle. (Note that the clipping rectangle is not + // translated by the scroll.) + + // We only support scrolling in one direction at a time. + DCHECK(dx == 0 || dy == 0); + + // We assume |clip_rect| is contained within the backing store. + DCHECK(clip_rect.bottom() <= canvas_.getDevice()->height()); + DCHECK(clip_rect.right() <= canvas_.getDevice()->width()); + + const SkBitmap &backing_bitmap = canvas_.getDevice()->accessBitmap(true); + const int stride = backing_bitmap.rowBytes(); + uint8_t* x = static_cast(backing_bitmap.getPixels()); + + if (dx) { + // Horizontal scroll. According to msdn, positive values of |dx| scroll + // left, but in practice this seems reversed. TODO(port): figure this + // out. For now just reverse the sign. + dx *= -1; + + // This is the number of bytes to move per line at 4 bytes per pixel. + const int len = (clip_rect.width() - abs(dx)) * 4; + + // Move |x| to the first pixel of the first row. + x += clip_rect.y() * stride; + x += clip_rect.x() * 4; + + // If we are scrolling left, move |x| to the |dx|^th pixel. + if (dx < 0) { + x -= dx * 4; + } + + for (int i = clip_rect.y(); i < clip_rect.bottom(); ++i) { + // Note that overlapping regions requires memmove, not memcpy. + memmove(x, x + dx * 4, len); + x += stride; + } + } else { + // Vertical scroll. According to msdn, positive values of |dy| scroll down, + // but in practice this seems reversed. TODO(port): figure this out. For now + // just reverse the sign. + dy *= -1; + + const int len = clip_rect.width() * 4; + + // For down scrolls, we copy bottom-up (in screen coordinates). + // For up scrolls, we copy top-down. + if (dy > 0) { + // Move |x| to the first pixel of this row. + x += clip_rect.x() * 4; + + for (int i = clip_rect.y(); i < clip_rect.height() - dy; ++i) { + memcpy(x, x + stride * dy, len); + x += stride; + } + } else { + // Move |x| to the first pixel of the last row of the clip rect. + x += clip_rect.x() * 4; + x += (clip_rect.bottom() - 1) * stride; + + for (int i = clip_rect.y(); i < clip_rect.height() + dy; ++i) { + memcpy(x, x + stride * dy, len); + x -= stride; + } + } + } + + // Now paint the new bitmap data. + PaintRect(process, bitmap, bitmap_rect); + return; +} diff --git a/chrome/browser/renderer_host/backing_store_posix.cc b/chrome/browser/renderer_host/backing_store_posix.cc deleted file mode 100644 index cacc6f0..0000000 --- a/chrome/browser/renderer_host/backing_store_posix.cc +++ /dev/null @@ -1,122 +0,0 @@ -// 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/logging.h" -#include "chrome/common/transport_dib.h" -#include "skia/ext/platform_canvas.h" -#include "skia/include/SkBitmap.h" -#include "skia/include/SkCanvas.h" - -BackingStore::BackingStore(const gfx::Size& size) - : size_(size) { - if (!canvas_.initialize(size.width(), size.height(), true)) - SK_CRASH(); -} - -BackingStore::~BackingStore() { -} - -void BackingStore::PaintRect(base::ProcessHandle process, - TransportDIB* bitmap, - const gfx::Rect& bitmap_rect) { - SkBitmap skbitmap; - skbitmap.setConfig(SkBitmap::kARGB_8888_Config, bitmap_rect.width(), - bitmap_rect.height(), 4 * bitmap_rect.width()); - - skbitmap.setPixels(bitmap->memory()); - - canvas_.drawBitmap(skbitmap, bitmap_rect.x(), bitmap_rect.y()); -} - -void BackingStore::ScrollRect(base::ProcessHandle process, - TransportDIB* bitmap, - const gfx::Rect& bitmap_rect, - int dx, int dy, - const gfx::Rect& clip_rect, - const gfx::Size& view_size) { - // WARNING: this is temporary code until a real solution is found for Mac and - // Linux. - // - // On Windows, there's a ScrollDC call which performs horiz and vertical - // scrolling - // - // clip_rect: MSDN says "The only bits that will be painted are the - // bits that remain inside this rectangle after the scroll operation has been - // completed." - // - // The Windows code always sets the whole backing store as the source of the - // scroll. Thus, we only have to worry about pixels which will end up inside - // the clipping rectangle. (Note that the clipping rectangle is not - // translated by the scroll.) - - // We only support scrolling in one direction at a time. - DCHECK(dx == 0 || dy == 0); - - // We assume |clip_rect| is contained within the backing store. - DCHECK(clip_rect.bottom() <= canvas_.getDevice()->height()); - DCHECK(clip_rect.right() <= canvas_.getDevice()->width()); - - const SkBitmap &backing_bitmap = canvas_.getDevice()->accessBitmap(true); - const int stride = backing_bitmap.rowBytes(); - uint8_t* x = static_cast(backing_bitmap.getPixels()); - - if (dx) { - // Horizontal scroll. According to msdn, positive values of |dx| scroll - // left, but in practice this seems reversed. TODO(port): figure this - // out. For now just reverse the sign. - dx *= -1; - - // This is the number of bytes to move per line at 4 bytes per pixel. - const int len = (clip_rect.width() - abs(dx)) * 4; - - // Move |x| to the first pixel of the first row. - x += clip_rect.y() * stride; - x += clip_rect.x() * 4; - - // If we are scrolling left, move |x| to the |dx|^th pixel. - if (dx < 0) { - x -= dx * 4; - } - - for (int i = clip_rect.y(); i < clip_rect.bottom(); ++i) { - // Note that overlapping regions requires memmove, not memcpy. - memmove(x, x + dx * 4, len); - x += stride; - } - } else { - // Vertical scroll. According to msdn, positive values of |dy| scroll down, - // but in practice this seems reversed. TODO(port): figure this out. For now - // just reverse the sign. - dy *= -1; - - const int len = clip_rect.width() * 4; - - // For down scrolls, we copy bottom-up (in screen coordinates). - // For up scrolls, we copy top-down. - if (dy > 0) { - // Move |x| to the first pixel of this row. - x += clip_rect.x() * 4; - - for (int i = clip_rect.y(); i < clip_rect.height() - dy; ++i) { - memcpy(x, x + stride * dy, len); - x += stride; - } - } else { - // Move |x| to the first pixel of the last row of the clip rect. - x += clip_rect.x() * 4; - x += (clip_rect.bottom() - 1) * stride; - - for (int i = clip_rect.y(); i < clip_rect.height() + dy; ++i) { - memcpy(x, x + stride * dy, len); - x -= stride; - } - } - } - - // Now paint the new bitmap data. - PaintRect(process, bitmap, bitmap_rect); - return; -} diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index b1b9a46..32940f5 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -792,7 +792,7 @@ 'browser/renderer_host/audio_renderer_host.h', 'browser/renderer_host/backing_store.cc', 'browser/renderer_host/backing_store.h', - 'browser/renderer_host/backing_store_posix.cc', + 'browser/renderer_host/backing_store_mac.cc', 'browser/renderer_host/backing_store_win.cc', 'browser/renderer_host/backing_store_x.cc', 'browser/renderer_host/browser_render_process_host.cc', -- cgit v1.1