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

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

Issue 2018603002: Mac: Clean up ifdefs in output surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 4 years, 7 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: content/browser/compositor/gpu_output_surface_mac.mm
diff --git a/content/browser/compositor/gpu_output_surface_mac.mm b/content/browser/compositor/gpu_output_surface_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..29e0e026f017d8cdcdea85e554da053dcfd8cbfc
--- /dev/null
+++ b/content/browser/compositor/gpu_output_surface_mac.mm
@@ -0,0 +1,93 @@
+// 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 "content/browser/compositor/gpu_output_surface_mac.h"
+
+#include "components/display_compositor/compositor_overlay_candidate_validator.h"
+#include "content/browser/gpu/gpu_surface_tracker.h"
+#include "content/common/gpu/client/context_provider_command_buffer.h"
+#include "gpu/GLES2/gl2extchromium.h"
+#include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
+#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
+#include "ui/base/cocoa/remote_layer_api.h"
+#include "ui/gfx/mac/io_surface.h"
+
+namespace content {
+
+GpuOutputSurfaceMac::GpuOutputSurfaceMac(
+ scoped_refptr<ContextProviderCommandBuffer> context,
+ gpu::SurfaceHandle surface_handle,
+ scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
+ base::SingleThreadTaskRunner* task_runner,
+ std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
+ overlay_candidate_validator,
+ gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager)
+ : GpuSurfacelessBrowserCompositorOutputSurface(
+ std::move(context),
+ surface_handle,
+ std::move(vsync_manager),
+ task_runner,
+ std::move(overlay_candidate_validator),
+ GL_TEXTURE_RECTANGLE_ARB,
+ GL_RGBA,
+ gpu_memory_buffer_manager) {}
+
+GpuOutputSurfaceMac::~GpuOutputSurfaceMac() {}
+
+void GpuOutputSurfaceMac::SwapBuffers(cc::CompositorFrame* frame) {
+ GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(frame);
+
+ if (should_show_frames_state_ ==
+ SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) {
+ should_show_frames_state_ = SHOULD_SHOW_FRAMES;
+ }
+}
+
+void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted(
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result,
+ const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
+ if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) {
+ gfx::AcceleratedWidget native_widget =
+ content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
+ params_mac->surface_handle);
+ ui::AcceleratedWidgetMacGotFrame(
+ native_widget, params_mac->ca_context_id,
+ params_mac->fullscreen_low_power_ca_context_valid,
+ params_mac->fullscreen_low_power_ca_context_id, params_mac->io_surface,
+ params_mac->pixel_size, params_mac->scale_factor, nullptr, nullptr);
+ }
+ GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
+ latency_info, result, params_mac);
+}
+
+void GpuOutputSurfaceMac::SetSurfaceSuspendedForRecycle(bool suspended) {
+ if (suspended) {
+ // It may be that there are frames in-flight from the GPU process back to
+ // the browser. Make sure that these frames are not displayed by ignoring
+ // them in GpuProcessHostUIShim, until the browser issues a SwapBuffers for
+ // the new content.
+ should_show_frames_state_ = SHOULD_NOT_SHOW_FRAMES_SUSPENDED;
+ } else {
+ // Discard the backbuffer before drawing the new frame. This is necessary
+ // only when using a ImageTransportSurfaceFBO with a
+ // CALayerStorageProvider. Discarding the backbuffer results in the next
+ // frame using a new CALayer and CAContext, which guarantees that the
+ // browser will not flash stale content when adding the remote CALayer to
+ // the NSView hierarchy (it could flash stale content because the system
+ // window server is not synchronized with any signals we control or
+ // observe).
+ if (should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED) {
+ DiscardBackbuffer();
+ should_show_frames_state_ =
+ SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED;
+ }
+ }
+}
+
+bool GpuOutputSurfaceMac::SurfaceIsSuspendForRecycle() const {
+ return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/compositor/gpu_output_surface_mac.h ('k') | content/browser/compositor/gpu_process_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698