diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-14 20:05:03 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-14 20:05:03 +0000 |
commit | 0c6c321fa47d17fdd07bc3a51e615f98c3605277 (patch) | |
tree | 12af5f53b4d9a8445c2b722a32394b8b645f09af | |
parent | 456dc91fda9c3d3e456382258e3cb0e31f6f68a7 (diff) | |
download | chromium_src-0c6c321fa47d17fdd07bc3a51e615f98c3605277.zip chromium_src-0c6c321fa47d17fdd07bc3a51e615f98c3605277.tar.gz chromium_src-0c6c321fa47d17fdd07bc3a51e615f98c3605277.tar.bz2 |
Revert 74840 - BackingStoreSkia: Use skia for painting in RenderWidgetHostViewViews.
Instead of directly painting to X, paint to the skia canvas from RWHVV. This
will make it easier to apply transformation to views in a uniform way, without
requiring any special-casing for RWHVV.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6246129
TBR=sadrul@chromium.org
Review URL: http://codereview.chromium.org/6517018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74846 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/backing_store_skia.cc | 103 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_skia.h | 51 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_views.cc | 49 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
4 files changed, 10 insertions, 195 deletions
diff --git a/chrome/browser/renderer_host/backing_store_skia.cc b/chrome/browser/renderer_host/backing_store_skia.cc deleted file mode 100644 index bcb367a..0000000 --- a/chrome/browser/renderer_host/backing_store_skia.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2011 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_skia.h" - -#include "chrome/browser/renderer_host/render_process_host.h" -#include "skia/ext/platform_canvas.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/canvas_skia.h" -#include "ui/gfx/rect.h" - -// Assume that somewhere along the line, someone will do width * height * 4 -// with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = -// 2**29 and floor(sqrt(2**29)) = 23170. - -// Max height and width for layers -static const int kMaxVideoLayerSize = 23170; - -BackingStoreSkia::BackingStoreSkia(RenderWidgetHost* widget, - const gfx::Size& size) - : BackingStore(widget, size) { - bitmap_.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); - bitmap_.allocPixels(); - canvas_.reset(new SkCanvas(bitmap_)); -} - -BackingStoreSkia::~BackingStoreSkia() { -} - -void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, - gfx::Canvas* canvas) { - canvas->AsCanvasSkia()->drawBitmap(bitmap_, - SkIntToScalar(point.x()), SkIntToScalar(point.y())); -} - -size_t BackingStoreSkia::MemorySize() { - // NOTE: The computation may be different when the canvas is a subrectangle of - // a larger bitmap. - return size().GetArea() * 4; -} - -void BackingStoreSkia::PaintToBackingStore( - RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects) { - if (bitmap_rect.IsEmpty()) - return; - - const int width = bitmap_rect.width(); - const int height = bitmap_rect.height(); - - if (width <= 0 || width > kMaxVideoLayerSize || - height <= 0 || height > kMaxVideoLayerSize) - return; - - TransportDIB* dib = process->GetTransportDIB(bitmap); - if (!dib) - return; - - scoped_ptr<skia::PlatformCanvas> p_canvas( - dib->GetPlatformCanvas(width, height)); - for (size_t i = 0; i < copy_rects.size(); i++) { - const gfx::Rect& copy_rect = copy_rects[i]; - int x = copy_rect.x() - bitmap_rect.x(); - int y = copy_rect.y() - bitmap_rect.y(); - int w = copy_rect.width(); - int h = copy_rect.height(); - SkIRect srcrect = SkIRect::MakeXYWH(x, y, w, h); - SkRect dstrect = SkRect::MakeXYWH(copy_rect.x(), copy_rect.y(), w, h); - SkBitmap b = p_canvas->getTopPlatformDevice().accessBitmap(false); - canvas_.get()->drawBitmapRect(b, &srcrect, dstrect); - } -} - -void BackingStoreSkia::ScrollBackingStore(int dx, int dy, - const gfx::Rect& clip_rect, - const gfx::Size& view_size) { - int x = std::min(clip_rect.x(), clip_rect.x() - dx); - int y = std::min(clip_rect.y(), clip_rect.y() - dy); - int w = clip_rect.width() + abs(dx); - int h = clip_rect.height() + abs(dy); - SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); - bitmap_.scrollRect(&rect, dx, dy); -} - -bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformCanvas* output) { - const int width = std::min(size().width(), rect.width()); - const int height = std::min(size().height(), rect.height()); - if (!output->initialize(width, height, true)) - return false; - - SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); - SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); - SkBitmap b; - if (!canvas_->readPixels(skrect, &b)) - return false; - output->writePixels(b, rect.x(), rect.y()); - return true; -} diff --git a/chrome/browser/renderer_host/backing_store_skia.h b/chrome/browser/renderer_host/backing_store_skia.h deleted file mode 100644 index 4185496..0000000 --- a/chrome/browser/renderer_host/backing_store_skia.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011 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_SKIA_H_ -#define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_SKIA_H_ -#pragma once - -#include "base/scoped_ptr.h" -#include "chrome/browser/renderer_host/backing_store.h" -#include "third_party/skia/include/core/SkBitmap.h" - -class SkCanvas; - -namespace gfx { -class Point; -class Canvas; -} - -// A backing store that uses skia. This is a temporary backing store used by -// RenderWidgetHostViewViews. In time, only GPU rendering will be used for -// RWHVV, and then this backing store will be removed. -class BackingStoreSkia : public BackingStore { - public: - BackingStoreSkia(RenderWidgetHost* widget, const gfx::Size& size); - virtual ~BackingStoreSkia(); - - void SkiaShowRect(const gfx::Point& point, gfx::Canvas* canvas); - - // BackingStore implementation. - virtual size_t MemorySize(); - virtual void PaintToBackingStore( - RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects); - virtual bool CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformCanvas* output); - virtual void ScrollBackingStore(int dx, int dy, - const gfx::Rect& clip_rect, - const gfx::Size& view_size); - - private: - SkBitmap bitmap_; - - scoped_ptr<SkCanvas> canvas_; - - DISALLOW_COPY_AND_ASSIGN(BackingStoreSkia); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_SKIA_H_ diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index cd38138..410b4b1 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -14,7 +14,6 @@ #include "base/string_number_conversions.h" #include "base/task.h" #include "base/time.h" -#include "chrome/browser/renderer_host/backing_store_skia.h" #include "chrome/browser/renderer_host/backing_store_x.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/common/native_web_keyboard_event.h" @@ -26,7 +25,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/x/x11_util.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/canvas_skia.h" #include "views/events/event.h" #include "views/ime/ime_context.h" #include "views/widget/widget.h" @@ -34,8 +32,7 @@ static const int kMaxWindowWidth = 4000; static const int kMaxWindowHeight = 4000; -static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__"; -static const char kBackingStoreSkiaSwitch[] = "use-backing-store-skia"; +static const char* kRenderWidgetHostViewKey = "__RENDER_WIDGET_HOST_VIEW__"; // Copied from third_party/WebKit/Source/WebCore/page/EventHandler.cpp // @@ -60,18 +57,6 @@ const char RenderWidgetHostViewViews::kViewClassName[] = namespace { -bool UsingBackingStoreSkia() { - static bool decided = false; - static bool use_skia = false; - if (!decided) { - CommandLine* cmdline = CommandLine::ForCurrentProcess(); - use_skia = (cmdline && cmdline->HasSwitch(kBackingStoreSkiaSwitch)); - decided = true; - } - - return use_skia; -} - int WebInputEventFlagsFromViewsEvent(const views::Event& event) { int modifiers = 0; @@ -502,14 +487,9 @@ BackingStore* RenderWidgetHostViewViews::AllocBackingStore( gfx::NativeView nview = GetInnerNativeView(); if (!nview) return NULL; - - if (UsingBackingStoreSkia()) { - return new BackingStoreSkia(host_, size); - } else { - return new BackingStoreX(host_, size, - ui::GetVisualFromGtkWidget(nview), - gtk_widget_get_visual(nview)->depth); - } + return new BackingStoreX(host_, size, + ui::GetVisualFromGtkWidget(nview), + gtk_widget_get_visual(nview)->depth); } gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const { @@ -560,7 +540,8 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { ConvertPointToWidget(this, &origin); about_to_validate_and_paint_ = true; - BackingStore* backing_store = host_->GetBackingStore(true); + BackingStoreX* backing_store = static_cast<BackingStoreX*>( + host_->GetBackingStore(true)); // Calling GetBackingStore maybe have changed |invalid_rect_|... about_to_validate_and_paint_ = false; @@ -575,15 +556,9 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { if (!visually_deemphasized_) { // In the common case, use XCopyArea. We don't draw more than once, so // we don't need to double buffer. - - if (UsingBackingStoreSkia()) { - static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect( - gfx::Point(paint_rect.x(), paint_rect.y()), canvas); - } else { - static_cast<BackingStoreX*>(backing_store)->XShowRect(origin, - paint_rect, ui::GetX11WindowFromGdkWindow(window)); - } - } else if (!UsingBackingStoreSkia()) { + backing_store->XShowRect(origin, + paint_rect, ui::GetX11WindowFromGdkWindow(window)); + } else { // If the grey blend is showing, we make two drawing calls. Use double // buffering to prevent flicker. Use CairoShowRect because XShowRect // shortcuts GDK's double buffering. @@ -591,8 +566,7 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { paint_rect.width(), paint_rect.height() }; gdk_window_begin_paint_rect(window, &rect); - static_cast<BackingStoreX*>(backing_store)->CairoShowRect( - paint_rect, GDK_DRAWABLE(window)); + backing_store->CairoShowRect(paint_rect, GDK_DRAWABLE(window)); cairo_t* cr = gdk_cairo_create(window); gdk_cairo_rectangle(cr, &rect); @@ -601,9 +575,6 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { cairo_destroy(cr); gdk_window_end_paint(window); - } else { - // TODO(sad) - NOTIMPLEMENTED(); } } if (!whiteout_start_time_.is_null()) { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cd2b59e..dddd522 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1941,8 +1941,6 @@ 'browser/renderer_host/backing_store_mac.mm', 'browser/renderer_host/backing_store_manager.cc', 'browser/renderer_host/backing_store_manager.h', - 'browser/renderer_host/backing_store_skia.cc', - 'browser/renderer_host/backing_store_skia.h', 'browser/renderer_host/backing_store_win.cc', 'browser/renderer_host/backing_store_win.h', 'browser/renderer_host/backing_store_x.cc', |