diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 01:14:42 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 01:14:42 +0000 |
commit | 0b07be45881306b32eab0d87f7d55ec3e84cd676 (patch) | |
tree | 914217cc11befe8e1dfe8b6f571ca8dd15a734bd /chrome/browser | |
parent | 808d95b86f71910d1d3da1b16483b8fe24ab8980 (diff) | |
download | chromium_src-0b07be45881306b32eab0d87f7d55ec3e84cd676.zip chromium_src-0b07be45881306b32eab0d87f7d55ec3e84cd676.tar.gz chromium_src-0b07be45881306b32eab0d87f7d55ec3e84cd676.tar.bz2 |
Get rid of BackingStore usage in chrome. I added methods on RenderWidgetHost to copy data out of the backing store to satisfy the existing users.
Note that the ThumbnailGenerator test turned out to be testing a feature that has since been removed! So I removed that test and the supporting code.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9515009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/DEPS | 4 | ||||
-rw-r--r-- | chrome/browser/aeropeek_manager.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 30 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.h | 4 | ||||
-rw-r--r-- | chrome/browser/memory_details.cc | 5 | ||||
-rw-r--r-- | chrome/browser/memory_purger.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/thumbnail_generator.cc | 43 | ||||
-rw-r--r-- | chrome/browser/tab_contents/thumbnail_generator.h | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/thumbnail_generator_unittest.cc | 176 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/tabpose_window.mm | 28 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc | 20 |
11 files changed, 58 insertions, 270 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 609a311..5daf1e2 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -60,10 +60,6 @@ include_rules = [ "+content/browser/net/url_request_slow_http_job.h", "+content/browser/plugin_service_filter.h", "+content/browser/quota_permission_context.h", - "+content/browser/renderer_host/backing_store.h", - "+content/browser/renderer_host/backing_store_gtk.h", - "+content/browser/renderer_host/backing_store_mac.h", - "+content/browser/renderer_host/backing_store_manager.h", "+content/browser/renderer_host/dummy_resource_handler.h", "+content/browser/renderer_host/mock_render_process_host.h", "+content/browser/renderer_host/render_process_host_browsertest.h", diff --git a/chrome/browser/aeropeek_manager.cc b/chrome/browser/aeropeek_manager.cc index b387364..e24f906 100644 --- a/chrome/browser/aeropeek_manager.cc +++ b/chrome/browser/aeropeek_manager.cc @@ -25,7 +25,6 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/browser_distribution.h" -#include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" @@ -996,15 +995,10 @@ bool AeroPeekManager::GetTabPreview(int tab_id, SkBitmap* preview) { if (!render_view_host) return false; - BackingStore* backing_store = render_view_host->GetBackingStore(false); - if (!backing_store) - return false; - // Create a copy of this BackingStore image. // This code is just copied from "thumbnail_generator.cc". skia::PlatformCanvas canvas; - if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), - &canvas)) + if (!render_view_host->CopyFromBackingStore(&canvas)) return false; const SkBitmap& bitmap = skia::GetTopDevice(canvas)->accessBitmap(false); diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index a6a9ddc..bd3ff79 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -48,7 +48,6 @@ #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" -#include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -1625,9 +1624,15 @@ bool CaptureVisibleTabFunction::RunImpl() { // If a backing store is cached for the tab we want to capture, // and it can be copied into a bitmap, then use it to generate the image. - BackingStore* backing_store = render_view_host->GetBackingStore(false); - if (backing_store && CaptureSnapshotFromBackingStore(backing_store)) + // This may fail if we can not copy a backing store into a bitmap. + // For example, some uncommon X11 visual modes are not supported by + // CopyFromBackingStore(). + skia::PlatformCanvas temp_canvas; + if (render_view_host->CopyFromBackingStore(&temp_canvas)) { + VLOG(1) << "captureVisibleTab() got image from backing store."; + SendResultFromBitmap(skia::GetTopDevice(temp_canvas)->accessBitmap(false)); return true; + } // Ask the renderer for a snapshot of the tab. TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); @@ -1640,25 +1645,6 @@ bool CaptureVisibleTabFunction::RunImpl() { return true; } -// Build the image of a tab's contents out of a backing store. -// This may fail if we can not copy a backing store into a bitmap. -// For example, some uncommon X11 visual modes are not supported by -// CopyFromBackingStore(). -bool CaptureVisibleTabFunction::CaptureSnapshotFromBackingStore( - BackingStore* backing_store) { - - skia::PlatformCanvas temp_canvas; - if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), - &temp_canvas)) { - return false; - } - VLOG(1) << "captureVisibleTab() got image from backing store."; - - SendResultFromBitmap( - skia::GetTopDevice(temp_canvas)->accessBitmap(false)); - return true; -} - // If a backing store was not available in CaptureVisibleTabFunction::RunImpl, // than the renderer was asked for a snapshot. Listen for a notification // that the snapshot is available. diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h index 61f2c39..7038bc2 100644 --- a/chrome/browser/extensions/extension_tabs_module.h +++ b/chrome/browser/extensions/extension_tabs_module.h @@ -164,11 +164,11 @@ class CaptureVisibleTabFunction : public AsyncExtensionFunction, virtual ~CaptureVisibleTabFunction() {} virtual bool RunImpl() OVERRIDE; - virtual bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - virtual void SendResultFromBitmap(const SkBitmap& screen_capture); + bool CaptureSnapshotFromBackingStore(BackingStore* backing_store); + void SendResultFromBitmap(const SkBitmap& screen_capture); content::NotificationRegistrar registrar_; diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index ea3985c..a44f50a 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -16,10 +16,9 @@ #include "chrome/common/chrome_view_type.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" +#include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/browser_child_process_host_iterator.h" #include "content/public/browser/child_process_data.h" -#include "content/browser/renderer_host/backing_store_manager.h" -#include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -415,7 +414,7 @@ void MemoryDetails::UpdateHistograms() { } } UMA_HISTOGRAM_MEMORY_KB("Memory.BackingStore", - BackingStoreManager::MemorySize() / 1024); + RenderWidgetHost::BackingStoreMemorySize() / 1024); UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", static_cast<int>(browser.processes.size())); diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc index 2222d81..bf0fc11 100644 --- a/chrome/browser/memory_purger.cc +++ b/chrome/browser/memory_purger.cc @@ -15,7 +15,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/render_messages.h" -#include "content/browser/renderer_host/backing_store_manager.h" +#include "content/browser/renderer_host/render_widget_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/resource_context.h" #include "net/proxy/proxy_resolver.h" @@ -85,7 +85,7 @@ void MemoryPurger::PurgeAll() { // static void MemoryPurger::PurgeBrowser() { // Dump the backing stores. - BackingStoreManager::RemoveAllBackingStores(); + RenderWidgetHost::RemoveAllBackingStores(); // Per-profile cleanup. scoped_refptr<PurgeMemoryIOHelper> purge_memory_io_helper( diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index 1ff460f..76c63c8 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <map> +#include "base/bind.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/time.h" @@ -15,7 +16,6 @@ #include "chrome/browser/history/top_sites.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/thumbnail_score.h" -#include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -60,10 +60,10 @@ static const int kThumbnailHeight = 132; static const char kThumbnailHistogramName[] = "Thumbnail.ComputeMS"; -// Creates a downsampled thumbnail for the given backing store. The returned -// bitmap will be isNull if there was an error creating it. -SkBitmap GetBitmapForBackingStore( - BackingStore* backing_store, +// Creates a downsampled thumbnail for the given RenderWidgetHost's backing +// store. The returned bitmap will be isNull if there was an error creating it. +SkBitmap GetBitmapForRenderWidgetHost( + RenderWidgetHost* render_widget_host, int desired_width, int desired_height, int options, @@ -76,8 +76,7 @@ SkBitmap GetBitmapForBackingStore( // allocation and we can tolerate failure here, so give up if the allocation // fails. skia::PlatformCanvas temp_canvas; - if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), - &temp_canvas)) + if (!render_widget_host->CopyFromBackingStore(&temp_canvas)) return result; const SkBitmap& bmp_with_scrollbars = skia::GetTopDevice(temp_canvas)->accessBitmap(false); @@ -200,17 +199,13 @@ void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer, gfx::Size page_size, gfx::Size desired_size) { if (prefer_backing_store) { - BackingStore* backing_store = renderer->GetBackingStore(false); - if (backing_store) { - // We were able to find a non-null backing store for this renderer, so - // we'll go with it. - SkBitmap first_try = GetBitmapForBackingStore(backing_store, - desired_size.width(), - desired_size.height(), - kNoOptions, - NULL); + // We were able to find a non-null backing store for this renderer, so + // we'll go with it. + SkBitmap first_try = GetBitmapForRenderWidgetHost( + renderer, desired_size.width(), desired_size.height(), kNoOptions, + NULL); + if (!first_try.isNull()) { callback.Run(first_try); - return; } // Now, if the backing store didn't exist, we will still try and @@ -275,18 +270,8 @@ SkBitmap ThumbnailGenerator::GetThumbnailForRendererWithOptions( RenderWidgetHost* renderer, int options, ClipResult* clip_result) const { - BackingStore* backing_store = renderer->GetBackingStore(false); - if (!backing_store) { - // When we have no backing store, there's no choice in what to use. We - // have to return the empty thumbnail. - return SkBitmap(); - } - - return GetBitmapForBackingStore(backing_store, - kThumbnailWidth, - kThumbnailHeight, - options, - clip_result); + return GetBitmapForRenderWidgetHost( + renderer, kThumbnailWidth, kThumbnailHeight, options, clip_result); } void ThumbnailGenerator::WidgetDidReceivePaintAtSizeAck( diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h index d2d49b9..5a4dc0a 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.h +++ b/chrome/browser/tab_contents/thumbnail_generator.h @@ -11,9 +11,9 @@ #include <vector> #include "base/basictypes.h" +#include "base/callback_forward.h" #include "base/memory/linked_ptr.h" #include "base/timer.h" -#include "content/browser/renderer_host/backing_store.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" @@ -23,6 +23,10 @@ class Profile; class RenderWidgetHost; class SkBitmap; +namespace gfx { +class Size; +} + namespace history { class TopSites; } diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc index 4f1ea97..99647ca 100644 --- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc +++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc @@ -8,7 +8,6 @@ #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/common/render_messages.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/renderer_host/backing_store_manager.h" #include "content/browser/renderer_host/mock_render_process_host.h" #include "content/browser/renderer_host/test_render_view_host.h" #include "content/public/browser/notification_service.h" @@ -21,171 +20,14 @@ using content::WebContents; -static const int kBitmapWidth = 100; -static const int kBitmapHeight = 100; +typedef testing::Test ThumbnailGeneratorTest; -// TODO(brettw,satorux) enable this when GetThumbnailForBackingStore is -// implemented for Mac in thumbnail_generator.cc -// -// The test fails on Windows for the following error. Figure it out and fix. -// -// transport_dib_win.cc(71)] Check failed: !memory(). Mapped file twice in -// the same process. -// -#if !defined(OS_MACOSX) && !defined(OS_WIN) - -class ThumbnailGeneratorTest : public testing::Test { - public: - ThumbnailGeneratorTest() { - profile_.reset(new TestingProfile()); - process_ = new MockRenderProcessHost(profile_.get()); - view_.reset(TestRenderWidgetHostViewWithBackingStoreSkia::Construct( - process_, MSG_ROUTING_NONE)); - widget_ = view_->GetRenderWidgetHost(); - DCHECK(view_.get() && widget_); - - // Need to send out a create notification for the RWH to get hooked. This is - // a little scary in that we don't have a RenderView, but the only listener - // will want a RenderWidget, so it works out OK. - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<WebContents>(NULL), - content::Details<RenderViewHost>(reinterpret_cast<RenderViewHost*>( - widget_))); - - transport_dib_.reset(TransportDIB::Create(kBitmapWidth * kBitmapHeight * 4, - 1)); - } - - ~ThumbnailGeneratorTest() { - view_.reset(); - process_ = NULL; - profile_.reset(); - - // Process all pending tasks to avoid leaks. - message_loop_.RunAllPending(); - } - - protected: - // Indicates what bitmap should be sent with the paint message. _OTHER will - // only be retrned by CheckFirstPixel if the pixel is none of the others. - enum TransportType { TRANSPORT_BLACK, TRANSPORT_WHITE, TRANSPORT_OTHER }; - - void SendPaint(TransportType type) { - scoped_ptr<skia::PlatformCanvas> canvas( - transport_dib_->GetPlatformCanvas(kBitmapWidth, kBitmapHeight)); - switch (type) { - case TRANSPORT_BLACK: - skia::GetTopDevice(*canvas)->accessBitmap(true).eraseARGB( - 0xFF, 0, 0, 0); - break; - case TRANSPORT_WHITE: - skia::GetTopDevice(*canvas)->accessBitmap(true).eraseARGB( - 0xFF, 0xFF, 0xFF, 0xFF); - break; - case TRANSPORT_OTHER: - default: - NOTREACHED(); - break; - } - - gfx::Rect rect(0, 0, kBitmapWidth, kBitmapHeight); - SimulateUpdateRect(widget_, transport_dib_->id(), rect); - } - - TransportType ClassifyFirstPixel(const SkBitmap& bitmap) { - // Returns the color of the first pixel of the bitmap. The bitmap must be - // non-empty. - SkAutoLockPixels lock(bitmap); - uint32 pixel = *bitmap.getAddr32(0, 0); - - if (SkGetPackedA32(pixel) != 0xFF) - return TRANSPORT_OTHER; // All values expect an opqaue alpha channel - - if (SkGetPackedR32(pixel) == 0 && - SkGetPackedG32(pixel) == 0 && - SkGetPackedB32(pixel) == 0) - return TRANSPORT_BLACK; - - if (SkGetPackedR32(pixel) == 0xFF && - SkGetPackedG32(pixel) == 0xFF && - SkGetPackedB32(pixel) == 0xFF) - return TRANSPORT_WHITE; - - EXPECT_TRUE(false) << "Got weird color: " << pixel; - return TRANSPORT_OTHER; - } - - MessageLoopForUI message_loop_; - - scoped_ptr<TestingProfile> profile_; - - // Deleted automatically by widget_, but the deletion is done by - // DeleteSoon(), hence the message loop needs to run pending tasks. - MockRenderProcessHost* process_; - - RenderWidgetHost* widget_; - scoped_ptr<TestRenderWidgetHostViewWithBackingStoreSkia> view_; - ThumbnailGenerator generator_; - - scoped_ptr<TransportDIB> transport_dib_; - - private: - // testing::Test implementation. - void SetUp() { - } - void TearDown() { - } -}; - -TEST_F(ThumbnailGeneratorTest, NoThumbnail) { - // This is the case where there is no thumbnail available on the tab and - // there is no backing store. There should be no image returned. - SkBitmap result = generator_.GetThumbnailForRenderer(widget_); - EXPECT_TRUE(result.isNull()); -} - -// Tests basic thumbnail generation when a backing store is discarded. -TEST_F(ThumbnailGeneratorTest, DiscardBackingStore) { - // First set up a backing store. - SendPaint(TRANSPORT_BLACK); - ASSERT_TRUE(widget_->GetBackingStore(false)); - - // The thumbnail generator should be able to retrieve a thumbnail. - SkBitmap result = generator_.GetThumbnailForRenderer(widget_); - ASSERT_FALSE(result.isNull()); - // Valgrind reports MemoryCheck::Cond inside ClassifyFirstPixel(). With - // --track-origins=yes, valgrind reports that the uninitialized value - // originates from SkBitmap created in BackingStoreSkia's constructor. - // However, the bitmap is set properly when we send bitmap data in - // SendPaint() using TransportDIB (the test fails if the bitmap does not - // starts with 0xFF, 0x00, 0x00, 0x00, which is unlikely to happen by - // accident). Valgrind doesn't seem to be able to track data transfer - // from TransportDIB probably because the data comes from shared - // memory. This can explain why valgrind wrongly reports that the value - // in the bitmap is uninitialized. See also crbug.com/80458. - EXPECT_EQ(TRANSPORT_BLACK, ClassifyFirstPixel(result)); - - // Discard the backing store. - ASSERT_TRUE(BackingStoreManager::ExpireBackingStoreForTest(widget_)); - ASSERT_FALSE(widget_->GetBackingStore(false)); - - // The thumbnail generator should not be able to retrieve a thumbnail, - // as the backing store is now gone. - result = generator_.GetThumbnailForRenderer(widget_); - ASSERT_TRUE(result.isNull()); -} - -#endif // !defined(OS_MACOSX) - -typedef testing::Test ThumbnailGeneratorSimpleTest; - -TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_Empty) { +TEST_F(ThumbnailGeneratorTest, CalculateBoringScore_Empty) { SkBitmap bitmap; EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap)); } -TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_SingleColor) { +TEST_F(ThumbnailGeneratorTest, CalculateBoringScore_SingleColor) { const gfx::Size kSize(20, 10); gfx::CanvasSkia canvas(kSize, true); // Fill all pixesl in black. @@ -197,7 +39,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_SingleColor) { EXPECT_DOUBLE_EQ(1.0, ThumbnailGenerator::CalculateBoringScore(&bitmap)); } -TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_TwoColors) { +TEST_F(ThumbnailGeneratorTest, CalculateBoringScore_TwoColors) { const gfx::Size kSize(20, 10); gfx::CanvasSkia canvas(kSize, true); @@ -215,7 +57,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, CalculateBoringScore_TwoColors) { EXPECT_DOUBLE_EQ(0.5, ThumbnailGenerator::CalculateBoringScore(&bitmap)); } -TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_TallerThanWide) { +TEST_F(ThumbnailGeneratorTest, GetClippedBitmap_TallerThanWide) { // The input bitmap is vertically long. gfx::CanvasSkia canvas(gfx::Size(40, 90), true); SkBitmap bitmap = @@ -232,7 +74,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_TallerThanWide) { EXPECT_EQ(ThumbnailGenerator::kTallerThanWide, clip_result); } -TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_WiderThanTall) { +TEST_F(ThumbnailGeneratorTest, GetClippedBitmap_WiderThanTall) { // The input bitmap is horizontally long. gfx::CanvasSkia canvas(gfx::Size(90, 40), true); SkBitmap bitmap = @@ -249,7 +91,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_WiderThanTall) { EXPECT_EQ(ThumbnailGenerator::kWiderThanTall, clip_result); } -TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_NotClipped) { +TEST_F(ThumbnailGeneratorTest, GetClippedBitmap_NotClipped) { // The input bitmap is square. gfx::CanvasSkia canvas(gfx::Size(40, 40), true); SkBitmap bitmap = @@ -266,7 +108,7 @@ TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_NotClipped) { EXPECT_EQ(ThumbnailGenerator::kNotClipped, clip_result); } -TEST_F(ThumbnailGeneratorSimpleTest, GetClippedBitmap_NonSquareOutput) { +TEST_F(ThumbnailGeneratorTest, GetClippedBitmap_NonSquareOutput) { // The input bitmap is square. gfx::CanvasSkia canvas(gfx::Size(40, 40), true); SkBitmap bitmap = @@ -320,7 +162,7 @@ class MockTopSites : public history::TopSites { std::map<std::string, ThumbnailScore> known_url_map_; }; -TEST_F(ThumbnailGeneratorSimpleTest, ShouldUpdateThumbnail) { +TEST_F(ThumbnailGeneratorTest, ShouldUpdateThumbnail) { const GURL kGoodURL("http://www.google.com/"); const GURL kBadURL("chrome://newtab"); diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm index a742eb0..aa47af5 100644 --- a/chrome/browser/ui/cocoa/tabpose_window.mm +++ b/chrome/browser/ui/cocoa/tabpose_window.mm @@ -29,7 +29,6 @@ #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" -#include "content/browser/renderer_host/backing_store_mac.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" @@ -267,23 +266,6 @@ void ThumbnailLoader::LoadThumbnail() { return bottomOffset; } -- (void)drawBackingStore:(BackingStoreMac*)backing_store - inRect:(CGRect)destRect - context:(CGContextRef)context { - // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv. - // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor) - // won't show up in tabpose. - gfx::ScopedCGContextSaveGState CGContextSaveGState(context); - CGContextSetInterpolationQuality(context, kCGInterpolationHigh); - if (backing_store->cg_layer()) { - CGContextDrawLayerInRect(context, destRect, backing_store->cg_layer()); - } else { - base::mac::ScopedCFTypeRef<CGImageRef> image( - CGBitmapContextCreateImage(backing_store->cg_bitmap())); - CGContextDrawImage(context, destRect, image); - } -} - - (void)drawInContext:(CGContextRef)context { RenderWidgetHost* rwh = contents_->web_contents()->GetRenderViewHost(); // NULL if renderer crashed. @@ -311,10 +293,7 @@ void ThumbnailLoader::LoadThumbnail() { // a) there's no backing store or // b) the backing store's size doesn't match our required size and // c) we didn't already send a thumbnail request to the renderer. - BackingStoreMac* backing_store = - (BackingStoreMac*)rwh->GetBackingStore(/*force_create=*/false); - bool draw_backing_store = - backing_store && backing_store->size() == desiredThumbSize; + bool draw_backing_store = rwh->GetBackingStoreSize() == desiredThumbSize; // Next weirdness: The destination rect. If the layer is |fullSize_| big, the // destination rect is (0, bottomOffset), (fullSize_.width, topOffset). But we @@ -345,7 +324,10 @@ void ThumbnailLoader::LoadThumbnail() { if (draw_backing_store) { // Backing store 'cache' hit! - [self drawBackingStore:backing_store inRect:destRect context:context]; + // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv. + // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor) + // won't show up in tabpose. + rwh->CopyFromBackingStoreToCGContext(destRect, context); } else if (thumbnail_) { // No cache hit, but the renderer returned a thumbnail to us. gfx::ScopedCGContextSaveGState CGContextSaveGState(context); diff --git a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc index e68fb9a..05d623a 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc @@ -21,7 +21,6 @@ #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" #include "chrome/browser/ui/gtk/theme_service_gtk.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/renderer_host/backing_store_gtk.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/web_contents.h" #include "third_party/skia/include/core/SkShader.h" @@ -399,16 +398,17 @@ gboolean DraggedViewGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) { gtk_widget_get_allocation(widget, &allocation); // Draw the render area. - BackingStore* backing_store = drag_data_->GetSourceWebContents()-> - GetRenderViewHost()->GetBackingStore(false); - if (backing_store && !attached_) { + if (!attached_) { + RenderWidgetHost* render_widget_host = drag_data_->GetSourceWebContents()-> + GetRenderViewHost(); + // This leaves room for the border. - static_cast<BackingStoreGtk*>(backing_store)->PaintToRect( - gfx::Rect(kDragFrameBorderSize, tab_height, - allocation.width - kTwiceDragFrameBorderSize, - allocation.height - tab_height - - kDragFrameBorderSize), - GDK_DRAWABLE(gtk_widget_get_window(widget))); + gfx::Rect dest_rect(kDragFrameBorderSize, tab_height, + allocation.width - kTwiceDragFrameBorderSize, + allocation.height - tab_height - + kDragFrameBorderSize); + render_widget_host->CopyFromBackingStoreToGtkWindow( + dest_rect, GDK_DRAWABLE(gtk_widget_get_window(widget))); } cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget)); |