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

Unified Diff: content/common/gpu/image_transport_surface_overlay_mac.mm

Issue 1844053002: Add detached mode plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: And target Created 4 years, 9 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
« no previous file with comments | « content/common/gpu/image_transport_surface_overlay_mac.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/image_transport_surface_overlay_mac.mm
diff --git a/content/common/gpu/image_transport_surface_overlay_mac.mm b/content/common/gpu/image_transport_surface_overlay_mac.mm
index 0cf26dfee85383a031671350a1461b754183c8b3..aa42dd210da19cda33d65b3d12e5f81424f9bc24 100644
--- a/content/common/gpu/image_transport_surface_overlay_mac.mm
+++ b/content/common/gpu/image_transport_surface_overlay_mac.mm
@@ -4,6 +4,7 @@
#include "content/common/gpu/image_transport_surface_overlay_mac.h"
+#include <AVFoundation/AVFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <IOSurface/IOSurface.h>
#include <OpenGL/CGLRenderers.h>
@@ -40,6 +41,11 @@ typedef void* GLeglImageOES;
#include "ui/gl/scoped_api.h"
#include "ui/gl/scoped_cgl.h"
+#if !defined(MAC_OS_X_VERSION_10_8) || \
+ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
+extern NSString* const AVLayerVideoGravityResize;
+#endif // MAC_OS_X_VERSION_10_8
+
namespace {
// Don't let a frame draw until 5% of the way through the next vsync interval
@@ -79,6 +85,8 @@ void IOSurfaceContextNoOp(scoped_refptr<ui::IOSurfaceContext>) {
namespace content {
+void UpdateVideoLayer(AVSampleBufferDisplayLayer* sample_buffer_display_layer);
+
scoped_refptr<gfx::GLSurface> ImageTransportSurfaceCreateNativeSurface(
GpuChannelManager* manager,
GpuCommandBufferStub* stub,
@@ -161,6 +169,13 @@ bool ImageTransportSurfaceOverlayMac::Initialize(
[ca_root_layer_ setGeometryFlipped:YES];
[ca_root_layer_ setOpaque:YES];
[ca_context_ setLayer:ca_root_layer_];
+
+ detached_ca_context_.reset([
+ [CAContext contextWithCGSConnection:connection_id options:@{}] retain]);
+ detached_av_layer_.reset([[AVSampleBufferDisplayLayer alloc] init]);
+ [detached_av_layer_ setVideoGravity:AVLayerVideoGravityResize];
+ [detached_ca_context_ setLayer:detached_av_layer_];
+ [detached_av_layer_ setFrame:CGRectMake(0, 0, 1280, 720)];
}
return true;
}
@@ -198,24 +213,6 @@ void ImageTransportSurfaceOverlayMac::BufferPresented(
}
}
-void ImageTransportSurfaceOverlayMac::SendAcceleratedSurfaceBuffersSwapped(
- int32_t surface_id,
- CAContextID ca_context_id,
- const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface,
- const gfx::Size& size,
- float scale_factor,
- std::vector<ui::LatencyInfo> latency_info) {
- // TRACE_EVENT for gpu tests:
- TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
- "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
- "width", size.width());
- // On mac, handle_ is a surface id. See
- // GpuProcessTransportFactory::CreatePerCompositorData
- manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(
- surface_id, ca_context_id, io_surface, size, scale_factor,
- std::move(latency_info));
-}
-
gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
const gfx::Rect& pixel_damage_rect) {
TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::SwapBuffersInternal");
@@ -330,13 +327,14 @@ void ImageTransportSurfaceOverlayMac::DisplayFirstPendingSwapImmediately() {
}
// Update the CALayer hierarchy.
+ bool use_detached_mode = false;
{
gfx::RectF pixel_damage_rect = gfx::RectF(swap->pixel_damage_rect);
ScopedCAActionDisabler disabler;
if (swap->ca_layer_tree) {
swap->ca_layer_tree->CommitScheduledCALayers(
- ca_root_layer_.get(), std::move(current_ca_layer_tree_),
- swap->scale_factor);
+ ca_root_layer_.get(), &use_detached_mode, detached_av_layer_.get(),
+ std::move(current_ca_layer_tree_), swap->scale_factor);
current_ca_layer_tree_.swap(swap->ca_layer_tree);
current_partial_damage_tree_.reset();
} else if (swap->partial_damage_tree) {
@@ -378,8 +376,16 @@ void ImageTransportSurfaceOverlayMac::DisplayFirstPendingSwapImmediately() {
float scale_factor = swap->scale_factor;
std::vector<ui::LatencyInfo> latency_info;
latency_info.swap(swap->latency_info);
- SendAcceleratedSurfaceBuffersSwapped(handle_, ca_context_id, io_surface, size,
- scale_factor, std::move(latency_info));
+
+ CAContextID detached_ca_context_id = [detached_ca_context_ contextId];
+
+ // TRACE_EVENT for gpu tests:
+ TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
+ "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
+ "width", size.width());
+ manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(
+ handle_, ca_context_id, io_surface, use_detached_mode, detached_ca_context_id,
+ size, scale_factor, std::move(latency_info));
// Remove this from the queue, and reset any callback timers.
pending_swaps_.pop_front();
« no previous file with comments | « content/common/gpu/image_transport_surface_overlay_mac.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698