summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorccameron <ccameron@chromium.org>2015-10-27 08:28:39 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-27 15:29:17 +0000
commit516ddd741c0f9ec54947f4b23082e8c47d8d2278 (patch)
tree71801671f13f42e63e7717efa7b8f26b17f1785c /ui
parent50767a82f2be8f62f9d20f2add7f602130e0a305 (diff)
downloadchromium_src-516ddd741c0f9ec54947f4b23082e8c47d8d2278.zip
chromium_src-516ddd741c0f9ec54947f4b23082e8c47d8d2278.tar.gz
chromium_src-516ddd741c0f9ec54947f4b23082e8c47d8d2278.tar.bz2
Mac: Always use surfaceless mode
The goal of this change is to unify all image transport surfaces on Mac. Prior to this, if we do not support remote CoreAnimation APIs, then we will create an ImageTransportSurfaceFBO, which will send the IOSurface that it creates in the GPU process to the browser process. Change this to use the ImageTranportSurfaceOverlayMac. Using this surface will trigger the use of GpuSurfacelessBrowserCompositorOutputSurface instead of GpuBrowserCompositorOutputSurface. This output surface allocates an IOSurface-backed GpuMemoryBuffer in BufferQueue, which is rendered to. When frames are swapped in ImageTranportSurfaceOverlayMac, and remote CoreAnimation is not supported, send the backbuffer's IOSurface handle to the browser in GpuHostMsg_AcceleratedSurfaceBuffersSwapped. There is one snag here, where we are unable to open the IOSurface by its handle if the GpuMemoryBuffer that was created by BufferQueue has been destroyed. To fix this, make BufferQueue hold on to the GpuMemoryBuffer while it may be in use. Also, in GpuTransportFactory's CreateOverlayCandidateValidator, only create a validator if the remote CoreAnimation API is supported, because the non-remote-CoreAnimation path only supports drawing a single layer. BUG=546795 Review URL: https://codereview.chromium.org/1416363002 Cr-Commit-Position: refs/heads/master@{#356301}
Diffstat (limited to 'ui')
-rw-r--r--ui/accelerated_widget_mac/accelerated_widget_mac.h32
-rw-r--r--ui/accelerated_widget_mac/accelerated_widget_mac.mm41
-rw-r--r--ui/accelerated_widget_mac/surface_handle_types.h4
-rw-r--r--ui/gl/gl_image_io_surface.h1
4 files changed, 40 insertions, 38 deletions
diff --git a/ui/accelerated_widget_mac/accelerated_widget_mac.h b/ui/accelerated_widget_mac/accelerated_widget_mac.h
index 6d05c79..e5fd631 100644
--- a/ui/accelerated_widget_mac/accelerated_widget_mac.h
+++ b/ui/accelerated_widget_mac/accelerated_widget_mac.h
@@ -10,6 +10,7 @@
#include "base/mac/scoped_cftyperef.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
+#include "ui/accelerated_widget_mac/surface_handle_types.h"
#include "ui/events/latency_info.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
@@ -79,13 +80,13 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
void BeginPumpingFrames();
void EndPumpingFrames();
- void GotAcceleratedFrame(
- uint64 surface_handle,
- const std::vector<ui::LatencyInfo>& latency_info,
- const gfx::Size& pixel_size,
- float scale_factor,
- const gfx::Rect& pixel_damage_rect,
- const base::Closure& drawn_callback);
+ void GotAcceleratedFrame(CAContextID ca_context_id,
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
+ const std::vector<ui::LatencyInfo>& latency_info,
+ const gfx::Size& pixel_size,
+ float scale_factor,
+ const gfx::Rect& pixel_damage_rect,
+ const base::Closure& drawn_callback);
void GotIOSurfaceFrame(base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
const gfx::Size& pixel_size,
@@ -97,9 +98,10 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
const gfx::Size& pixel_size,
float scale_factor);
- void GotAcceleratedIOSurfaceFrame(IOSurfaceID io_surface_id,
- const gfx::Size& pixel_size,
- float scale_factor);
+ void GotAcceleratedIOSurfaceFrame(
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
+ const gfx::Size& pixel_size,
+ float scale_factor);
void AcknowledgeAcceleratedFrame();
@@ -153,14 +155,18 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
ACCELERATED_WIDGET_MAC_EXPORT
void AcceleratedWidgetMacGotAcceleratedFrame(
- gfx::AcceleratedWidget widget, uint64 surface_handle,
+ gfx::AcceleratedWidget widget,
+ CAContextID ca_context_id,
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
const std::vector<ui::LatencyInfo>& latency_info,
const gfx::Size& pixel_size,
float scale_factor,
const gfx::Rect& pixel_damage_rect,
const base::Closure& drawn_callback,
- bool* disable_throttling, int* renderer_id,
- base::TimeTicks* vsync_timebase, base::TimeDelta* vsync_interval);
+ bool* disable_throttling,
+ int* renderer_id,
+ base::TimeTicks* vsync_timebase,
+ base::TimeDelta* vsync_interval);
ACCELERATED_WIDGET_MAC_EXPORT
void AcceleratedWidgetMacGotIOSurfaceFrame(
diff --git a/ui/accelerated_widget_mac/accelerated_widget_mac.mm b/ui/accelerated_widget_mac/accelerated_widget_mac.mm
index ede33e5..dc76866 100644
--- a/ui/accelerated_widget_mac/accelerated_widget_mac.mm
+++ b/ui/accelerated_widget_mac/accelerated_widget_mac.mm
@@ -12,7 +12,6 @@
#include "base/message_loop/message_loop.h"
#include "base/trace_event/trace_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
-#include "ui/accelerated_widget_mac/surface_handle_types.h"
#include "ui/base/cocoa/animation_utils.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gl/scoped_cgl.h"
@@ -135,7 +134,8 @@ void AcceleratedWidgetMac::EndPumpingFrames() {
}
void AcceleratedWidgetMac::GotAcceleratedFrame(
- uint64 surface_handle,
+ CAContextID ca_context_id,
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
const std::vector<ui::LatencyInfo>& latency_info,
const gfx::Size& pixel_size,
float scale_factor,
@@ -156,21 +156,10 @@ void AcceleratedWidgetMac::GotAcceleratedFrame(
// Disable the fade-in or fade-out effect if we create or remove layers.
ScopedCAActionDisabler disabler;
- switch (GetSurfaceHandleType(surface_handle)) {
- case kSurfaceHandleTypeIOSurface: {
- IOSurfaceID io_surface_id = IOSurfaceIDFromSurfaceHandle(surface_handle);
- GotAcceleratedIOSurfaceFrame(io_surface_id, pixel_size, scale_factor);
- break;
- }
- case kSurfaceHandleTypeCAContext: {
- CAContextID ca_context_id = CAContextIDFromSurfaceHandle(surface_handle);
- GotAcceleratedCAContextFrame(ca_context_id, pixel_size, scale_factor);
- break;
- }
- default:
- DLOG(ERROR) << "Unrecognized accelerated frame type.";
- return;
- }
+ if (ca_context_id)
+ GotAcceleratedCAContextFrame(ca_context_id, pixel_size, scale_factor);
+ else
+ GotAcceleratedIOSurfaceFrame(io_surface, pixel_size, scale_factor);
AcknowledgeAcceleratedFrame();
}
@@ -206,12 +195,10 @@ void AcceleratedWidgetMac::GotAcceleratedCAContextFrame(
}
void AcceleratedWidgetMac::GotAcceleratedIOSurfaceFrame(
- IOSurfaceID io_surface_id,
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
const gfx::Size& pixel_size,
float scale_factor) {
- base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
- IOSurfaceLookup(io_surface_id));
- GotIOSurfaceFrame(io_surface, pixel_size, scale_factor, true);
+ GotIOSurfaceFrame(io_surface, pixel_size, scale_factor, false);
}
void AcceleratedWidgetMac::EnsureLocalLayer() {
@@ -294,19 +281,23 @@ void AcceleratedWidgetMac::AcknowledgeAcceleratedFrame() {
}
void AcceleratedWidgetMacGotAcceleratedFrame(
- gfx::AcceleratedWidget widget, uint64 surface_handle,
+ gfx::AcceleratedWidget widget,
+ CAContextID ca_context_id,
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
const std::vector<ui::LatencyInfo>& latency_info,
const gfx::Size& pixel_size,
float scale_factor,
const gfx::Rect& pixel_damage_rect,
const base::Closure& drawn_callback,
- bool* disable_throttling, int* renderer_id,
- base::TimeTicks* vsync_timebase, base::TimeDelta* vsync_interval) {
+ bool* disable_throttling,
+ int* renderer_id,
+ base::TimeTicks* vsync_timebase,
+ base::TimeDelta* vsync_interval) {
AcceleratedWidgetMac* accelerated_widget_mac =
GetHelperFromAcceleratedWidget(widget);
if (accelerated_widget_mac) {
accelerated_widget_mac->GotAcceleratedFrame(
- surface_handle, latency_info, pixel_size, scale_factor,
+ ca_context_id, io_surface, latency_info, pixel_size, scale_factor,
pixel_damage_rect, drawn_callback);
*disable_throttling =
accelerated_widget_mac->IsRendererThrottlingDisabled();
diff --git a/ui/accelerated_widget_mac/surface_handle_types.h b/ui/accelerated_widget_mac/surface_handle_types.h
index 7b55ec9..6a544e3 100644
--- a/ui/accelerated_widget_mac/surface_handle_types.h
+++ b/ui/accelerated_widget_mac/surface_handle_types.h
@@ -23,9 +23,13 @@ enum SurfaceHandleType {
kSurfaceHandleTypeCAContext,
};
+ACCELERATED_WIDGET_MAC_EXPORT
SurfaceHandleType GetSurfaceHandleType(uint64 surface_handle);
+ACCELERATED_WIDGET_MAC_EXPORT
CAContextID CAContextIDFromSurfaceHandle(uint64 surface_handle);
+
+ACCELERATED_WIDGET_MAC_EXPORT
IOSurfaceID IOSurfaceIDFromSurfaceHandle(uint64 surface_handle);
ACCELERATED_WIDGET_MAC_EXPORT
diff --git a/ui/gl/gl_image_io_surface.h b/ui/gl/gl_image_io_surface.h
index 45bd3ac..16e35b2 100644
--- a/ui/gl/gl_image_io_surface.h
+++ b/ui/gl/gl_image_io_surface.h
@@ -48,6 +48,7 @@ class GL_EXPORT GLImageIOSurface : public GLImage {
uint64_t process_tracing_id,
const std::string& dump_name) override;
+ gfx::GenericSharedMemoryId io_surface_id() const { return io_surface_id_; }
base::ScopedCFTypeRef<IOSurfaceRef> io_surface();
static void SetLayerForWidget(AcceleratedWidget widget, CALayer* layer);