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

Unified Diff: ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm

Issue 1917723002: Move logic from ImageTransportSurfaceOverlayMac into ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix grammar Created 4 years, 8 months 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: ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
diff --git a/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d8a6d9bd605c728d3449d60f697a565ce6159201
--- /dev/null
+++ b/ui/accelerated_widget_mac/ca_layer_tree_coordinator.mm
@@ -0,0 +1,97 @@
+// Copyright 2016 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 "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h"
+
+#include "base/trace_event/trace_event.h"
+#include "ui/base/cocoa/animation_utils.h"
+
+namespace ui {
+
+CALayerTreeCoordinator::CALayerTreeCoordinator(bool allow_remote_layers)
+ : allow_remote_layers_(allow_remote_layers) {
+ if (allow_remote_layers_) {
+ root_ca_layer_.reset([[CALayer alloc] init]);
+ [root_ca_layer_ setGeometryFlipped:YES];
+ [root_ca_layer_ setOpaque:YES];
+ }
+}
+
+CALayerTreeCoordinator::~CALayerTreeCoordinator() {}
+
+void CALayerTreeCoordinator::Resize(const gfx::Size& pixel_size,
+ float scale_factor) {
+ pixel_size_ = pixel_size;
+ scale_factor_ = scale_factor;
+}
+
+bool CALayerTreeCoordinator::SetPendingGLRendererBackbuffer(
+ base::ScopedCFTypeRef<IOSurfaceRef> backbuffer) {
+ if (pending_ca_renderer_layer_tree_) {
+ DLOG(ERROR) << "Either CALayer overlays or a backbuffer should be "
+ "specified, but not both.";
+ return false;
+ }
+ if (pending_gl_renderer_layer_tree_) {
+ DLOG(ERROR) << "Only one backbuffer per swap is allowed.";
+ return false;
+ }
+ pending_gl_renderer_layer_tree_.reset(new GLRendererLayerTree(
+ allow_remote_layers_, backbuffer, gfx::Rect(pixel_size_)));
+
+ return true;
+}
+
+CARendererLayerTree* CALayerTreeCoordinator::GetPendingCARendererLayerTree() {
+ DCHECK(allow_remote_layers_);
+ if (pending_gl_renderer_layer_tree_) {
+ DLOG(ERROR) << "Either CALayer overlays or a backbuffer should be "
+ "specified, but not both.";
+ }
+ if (!pending_ca_renderer_layer_tree_)
+ pending_ca_renderer_layer_tree_.reset(new CARendererLayerTree);
+ return pending_ca_renderer_layer_tree_.get();
+}
+
+void CALayerTreeCoordinator::CommitPendingTreesToCA(
+ const gfx::Rect& pixel_damage_rect) {
+ // Update the CALayer hierarchy.
+ ScopedCAActionDisabler disabler;
+ if (pending_ca_renderer_layer_tree_) {
+ pending_ca_renderer_layer_tree_->CommitScheduledCALayers(
+ root_ca_layer_.get(), std::move(current_ca_renderer_layer_tree_),
+ scale_factor_);
+ current_ca_renderer_layer_tree_.swap(pending_ca_renderer_layer_tree_);
+ current_gl_renderer_layer_tree_.reset();
+ } else if (pending_gl_renderer_layer_tree_) {
+ pending_gl_renderer_layer_tree_->CommitCALayers(
+ root_ca_layer_.get(), std::move(current_gl_renderer_layer_tree_),
+ scale_factor_, pixel_damage_rect);
+ current_gl_renderer_layer_tree_.swap(pending_gl_renderer_layer_tree_);
+ current_ca_renderer_layer_tree_.reset();
+ } else {
+ TRACE_EVENT0("gpu", "Blank frame: No overlays or CALayers");
+ [root_ca_layer_ setSublayers:nil];
+ current_gl_renderer_layer_tree_.reset();
+ current_ca_renderer_layer_tree_.reset();
+ }
+
+ // Reset all state for the next frame.
+ pending_ca_renderer_layer_tree_.reset();
+ pending_gl_renderer_layer_tree_.reset();
+}
+
+CALayer* CALayerTreeCoordinator::GetCALayerForDisplay() const {
+ DCHECK(allow_remote_layers_);
+ return root_ca_layer_.get();
+}
+
+IOSurfaceRef CALayerTreeCoordinator::GetIOSurfaceForDisplay() {
+ DCHECK(!allow_remote_layers_);
+ if (!current_gl_renderer_layer_tree_)
+ return nullptr;
+ return current_gl_renderer_layer_tree_->RootLayerIOSurface();
+}
+
+} // namespace ui
« no previous file with comments | « ui/accelerated_widget_mac/ca_layer_tree_coordinator.h ('k') | ui/accelerated_widget_mac/ca_layer_tree_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698