Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: content/browser/compositor/browser_compositor_view_mac.mm

Issue 745453002: Create an AcceleratedWidgetMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/compositor/browser_compositor_view_mac.mm
diff --git a/content/browser/compositor/browser_compositor_view_mac.mm b/content/browser/compositor/browser_compositor_view_mac.mm
index b38edce89aeb1bfea64e06861fb3f5a40044b9a8..11a9373eb5e99df67eb13c701a74e40f44507856 100644
--- a/content/browser/compositor/browser_compositor_view_mac.mm
+++ b/content/browser/compositor/browser_compositor_view_mac.mm
@@ -6,93 +6,72 @@
#include "base/debug/trace_event.h"
#include "base/lazy_instance.h"
-#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h"
-#include "content/common/gpu/gpu_messages.h"
+#include "content/browser/renderer_host/render_widget_resize_helper.h"
+#include "content/public/browser/context_factory.h"
////////////////////////////////////////////////////////////////////////////////
-// BrowserCompositorViewMac
+// BrowserCompositorMac
namespace content {
+
namespace {
// The number of placeholder objects allocated. If this reaches zero, then
-// the BrowserCompositorCALayerTreeMac being held on to for recycling,
-// |g_recyclable_ca_layer_tree|, will be freed.
+// the BrowserCompositorMac being held on to for recycling,
+// |g_recyclable_browser_compositor|, will be freed.
uint32 g_placeholder_count = 0;
-// A spare BrowserCompositorCALayerTreeMac kept around for recycling.
-base::LazyInstance<scoped_ptr<BrowserCompositorCALayerTreeMac>>
- g_recyclable_ca_layer_tree;
+// A spare BrowserCompositorMac kept around for recycling.
+base::LazyInstance<scoped_ptr<BrowserCompositorMac>>
+ g_recyclable_browser_compositor;
} // namespace
-BrowserCompositorViewMac::BrowserCompositorViewMac(
- BrowserCompositorViewMacClient* client,
- NSView* native_view,
- ui::Layer* ui_root_layer)
- : client_(client),
- native_view_(native_view),
- ui_root_layer_(ui_root_layer) {
- // Try to use the recyclable BrowserCompositorCALayerTreeMac if there is one,
- // otherwise allocate a new one.
- // TODO(ccameron): If there exists a frame in flight (swap has been called
- // by the compositor, but the frame has not arrived from the GPU process
- // yet), then that frame may inappropriately flash in the new view.
- ca_layer_tree_ = g_recyclable_ca_layer_tree.Get().Pass();
- if (!ca_layer_tree_)
- ca_layer_tree_.reset(new BrowserCompositorCALayerTreeMac);
- ca_layer_tree_->SetView(this);
-}
-
-BrowserCompositorViewMac::~BrowserCompositorViewMac() {
- // Make this BrowserCompositorCALayerTreeMac recyclable for future instances.
- ca_layer_tree_->ResetView();
- g_recyclable_ca_layer_tree.Get() = ca_layer_tree_.Pass();
-
- // If there are no placeholders allocated, destroy the recyclable
- // BrowserCompositorCALayerTreeMac that we just populated.
- if (!g_placeholder_count)
- g_recyclable_ca_layer_tree.Get().reset();
+BrowserCompositorMac::BrowserCompositorMac()
+ : compositor_(
+ accelerated_widget_mac_.accelerated_widget(),
+ content::GetContextFactory(),
+ RenderWidgetResizeHelper::Get()->task_runner()) {
+ compositor_.SetVisible(false);
}
-ui::Compositor* BrowserCompositorViewMac::GetCompositor() const {
- DCHECK(ca_layer_tree_);
- return ca_layer_tree_->compositor();
+// static
+BrowserCompositorMac* BrowserCompositorMac::Create() {
+ if (g_recyclable_browser_compositor.Get())
+ return g_recyclable_browser_compositor.Get().release();
+ return new BrowserCompositorMac;
}
-bool BrowserCompositorViewMac::HasFrameOfSize(
- const gfx::Size& dip_size) const {
- if (ca_layer_tree_)
- return ca_layer_tree_->HasFrameOfSize(dip_size);
- return false;
-}
+// static
+void BrowserCompositorMac::Recycle(
+ BrowserCompositorMac* compositor) {
tapted 2014/11/20 23:18:07 nit: pull up
ccameron 2014/11/21 01:32:41 (doesn't quite fit anymore)
+ DCHECK(compositor);
-void BrowserCompositorViewMac::BeginPumpingFrames() {
- if (ca_layer_tree_)
- ca_layer_tree_->BeginPumpingFrames();
-}
+ // Make this BrowserCompositorMac recyclable for future instances.
+ g_recyclable_browser_compositor.Get().reset(compositor);
-void BrowserCompositorViewMac::EndPumpingFrames() {
- if (ca_layer_tree_)
- ca_layer_tree_->EndPumpingFrames();
+ // If there are no placeholders allocated, destroy the recyclable
+ // BrowserCompositorMac that we just populated.
+ if (!g_placeholder_count)
+ g_recyclable_browser_compositor.Get().reset();
}
////////////////////////////////////////////////////////////////////////////////
-// BrowserCompositorViewPlaceholderMac
+// BrowserCompositorMacPlaceholder
-BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() {
+BrowserCompositorMacPlaceholder::BrowserCompositorMacPlaceholder() {
g_placeholder_count += 1;
}
-BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() {
+BrowserCompositorMacPlaceholder::~BrowserCompositorMacPlaceholder() {
DCHECK_GT(g_placeholder_count, 0u);
g_placeholder_count -= 1;
// If there are no placeholders allocated, destroy the recyclable
- // BrowserCompositorCALayerTreeMac.
+ // BrowserCompositorMac.
if (!g_placeholder_count)
- g_recyclable_ca_layer_tree.Get().reset();
+ g_recyclable_browser_compositor.Get().reset();
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698