Commit 212266c0 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

viz/mac: Remove GpuSurfaceTracker, redefine gfx::AcceleratedWidget

GpuSurfaceTracker has been removed from all other desktop platforms (in
crrev.com/389975) and is not used on Mac. Remove it.

Include Mac in GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW with other
desktop platforms.

Define gfx::AcceleratedWidget to be uint64_t instead of NSView*. It
never actually was NSView*, but was rather a sequence number used to
look up a ui::AcceleratedWidgetMac.

Fix a number of locations that were dangerously mixing NSView* and
gfx::AcceleratedWidget (now that they are incompatible types, this is
a compile error).

Bug: 772576
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I29212236627c512ed6a7fe55a8cf3e613e4e593a
Reviewed-on: https://chromium-review.googlesource.com/792295
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521030}
parent b6d6208b
...@@ -13,7 +13,7 @@ namespace { ...@@ -13,7 +13,7 @@ namespace {
TEST(SoftwareOutputDeviceMacTest, Basics) { TEST(SoftwareOutputDeviceMacTest, Basics) {
std::unique_ptr<SoftwareOutputDeviceMac> device( std::unique_ptr<SoftwareOutputDeviceMac> device(
new SoftwareOutputDeviceMac(nullptr)); new SoftwareOutputDeviceMac(gfx::kNullAcceleratedWidget));
gfx::Size pixel_size(512, 512); gfx::Size pixel_size(512, 512);
float scale_factor = 1; float scale_factor = 1;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "content/browser/accessibility/browser_accessibility_mac.h" #import "content/browser/accessibility/browser_accessibility_mac.h"
#include "content/common/accessibility_messages.h" #include "content/common/accessibility_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/accessibility/ax_role_properties.h" #include "ui/accessibility/ax_role_properties.h"
namespace { namespace {
...@@ -486,7 +487,10 @@ BrowserAccessibilityManagerMac::GetUserInfoForValueChangedNotification( ...@@ -486,7 +487,10 @@ BrowserAccessibilityManagerMac::GetUserInfoForValueChangedNotification(
} }
NSView* BrowserAccessibilityManagerMac::GetParentView() { NSView* BrowserAccessibilityManagerMac::GetParentView() {
return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr; gfx::AcceleratedWidget accelerated_widget =
delegate() ? delegate()->AccessibilityGetAcceleratedWidget()
: gfx::kNullAcceleratedWidget;
return ui::AcceleratedWidgetMac::GetNSView(accelerated_widget);
} }
} // namespace content } // namespace content
...@@ -509,7 +509,7 @@ GpuProcessHost::~GpuProcessHost() { ...@@ -509,7 +509,7 @@ GpuProcessHost::~GpuProcessHost() {
if (g_gpu_process_hosts[kind_] == this) if (g_gpu_process_hosts[kind_] == this)
g_gpu_process_hosts[kind_] = nullptr; g_gpu_process_hosts[kind_] = nullptr;
#if defined(OS_MACOSX) || defined(OS_ANDROID) #if defined(OS_ANDROID)
UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount",
gpu::GpuSurfaceTracker::Get()->GetSurfaceCount()); gpu::GpuSurfaceTracker::Get()->GetSurfaceCount());
#endif #endif
......
...@@ -1733,8 +1733,15 @@ gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( ...@@ -1733,8 +1733,15 @@ gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen(
return gfx::Point(originInScreen.x, originInScreen.y); return gfx::Point(originInScreen.x, originInScreen.y);
} }
NSView* RenderWidgetHostViewMac::AccessibilityGetAcceleratedWidget() { gfx::AcceleratedWidget
return cocoa_view_; RenderWidgetHostViewMac::AccessibilityGetAcceleratedWidget() {
if (browser_compositor_) {
ui::AcceleratedWidgetMac* accelerated_widget_mac =
browser_compositor_->GetAcceleratedWidgetMac();
if (accelerated_widget_mac)
return accelerated_widget_mac->accelerated_widget();
}
return gfx::kNullAcceleratedWidget;
} }
void RenderWidgetHostViewMac::SetTextInputActive(bool active) { void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "gpu/gles2_conform_support/egl/display.h" #include "gpu/gles2_conform_support/egl/display.h"
#include "build/build_config.h"
#include "gpu/gles2_conform_support/egl/config.h" #include "gpu/gles2_conform_support/egl/config.h"
#include "gpu/gles2_conform_support/egl/context.h" #include "gpu/gles2_conform_support/egl/context.h"
#include "gpu/gles2_conform_support/egl/surface.h" #include "gpu/gles2_conform_support/egl/surface.h"
...@@ -214,8 +215,12 @@ EGLSurface Display::CreateWindowSurface(ThreadState* ts, ...@@ -214,8 +215,12 @@ EGLSurface Display::CreateWindowSurface(ThreadState* ts,
return result; return result;
} }
scoped_refptr<gl::GLSurface> gl_surface; scoped_refptr<gl::GLSurface> gl_surface;
gl_surface = #if defined(OS_MACOSX)
gl::init::CreateViewGLSurface(static_cast<gfx::AcceleratedWidget>(win)); gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget;
#else
gfx::AcceleratedWidget widget = static_cast<gfx::AcceleratedWidget>(win);
#endif
gl_surface = gl::init::CreateViewGLSurface(widget);
if (!gl_surface) if (!gl_surface)
return ts->ReturnError(EGL_BAD_ALLOC, EGL_NO_SURFACE); return ts->ReturnError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
surfaces_.emplace_back(new Surface(gl_surface.get(), config)); surfaces_.emplace_back(new Surface(gl_surface.get(), config));
......
...@@ -121,7 +121,7 @@ source_set("ipc_common_sources") { ...@@ -121,7 +121,7 @@ source_set("ipc_common_sources") {
] ]
} }
if (is_mac || is_android) { if (is_android) {
sources += [ sources += [
"gpu_surface_lookup.cc", "gpu_surface_lookup.cc",
"gpu_surface_lookup.h", "gpu_surface_lookup.h",
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "build/build_config.h" #include "build/build_config.h"
#if (defined(OS_WIN) || defined(USE_X11) || defined(USE_OZONE)) && \ #if (defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_X11) || \
defined(USE_OZONE)) && \
!defined(OS_NACL) !defined(OS_NACL)
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#define GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW #define GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW
......
...@@ -54,6 +54,12 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac { ...@@ -54,6 +54,12 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac {
base::TimeTicks* timebase, base::TimeDelta* interval) const; base::TimeTicks* timebase, base::TimeDelta* interval) const;
static AcceleratedWidgetMac* Get(gfx::AcceleratedWidget widget); static AcceleratedWidgetMac* Get(gfx::AcceleratedWidget widget);
// Translate from a gfx::AcceleratedWidget to the NSView in which it will
// appear. This may return nil if |widget| is invalid or is not currently
// attached to an NSView.
static NSView* GetNSView(gfx::AcceleratedWidget widget);
void GotCALayerFrame(base::scoped_nsobject<CALayer> content_layer, void GotCALayerFrame(base::scoped_nsobject<CALayer> content_layer,
const gfx::Size& pixel_size, const gfx::Size& pixel_size,
float scale_factor); float scale_factor);
......
...@@ -48,10 +48,8 @@ AcceleratedWidgetMac::AcceleratedWidgetMac() : view_(nullptr) { ...@@ -48,10 +48,8 @@ AcceleratedWidgetMac::AcceleratedWidgetMac() : view_(nullptr) {
// Use a sequence number as the accelerated widget handle that we can use // Use a sequence number as the accelerated widget handle that we can use
// to look up the internals structure. // to look up the internals structure.
static intptr_t last_sequence_number = 0; static uint64_t last_sequence_number = 0;
last_sequence_number += 1; native_widget_ = ++last_sequence_number;
native_widget_ = reinterpret_cast<gfx::AcceleratedWidget>(
last_sequence_number);
g_widget_to_helper_map.Pointer()->insert( g_widget_to_helper_map.Pointer()->insert(
std::make_pair(native_widget_, this)); std::make_pair(native_widget_, this));
} }
...@@ -106,6 +104,7 @@ void AcceleratedWidgetMac::GetVSyncParameters( ...@@ -106,6 +104,7 @@ void AcceleratedWidgetMac::GetVSyncParameters(
} }
} }
// static
AcceleratedWidgetMac* AcceleratedWidgetMac::Get(gfx::AcceleratedWidget widget) { AcceleratedWidgetMac* AcceleratedWidgetMac::Get(gfx::AcceleratedWidget widget) {
WidgetToHelperMap::const_iterator found = WidgetToHelperMap::const_iterator found =
g_widget_to_helper_map.Pointer()->find(widget); g_widget_to_helper_map.Pointer()->find(widget);
...@@ -117,6 +116,14 @@ AcceleratedWidgetMac* AcceleratedWidgetMac::Get(gfx::AcceleratedWidget widget) { ...@@ -117,6 +116,14 @@ AcceleratedWidgetMac* AcceleratedWidgetMac::Get(gfx::AcceleratedWidget widget) {
return found->second; return found->second;
} }
// static
NSView* AcceleratedWidgetMac::GetNSView(gfx::AcceleratedWidget widget) {
AcceleratedWidgetMac* widget_mac = Get(widget);
if (!widget_mac || !widget_mac->view_)
return nil;
return widget_mac->view_->AcceleratedWidgetGetNSView();
}
void AcceleratedWidgetMac::GotCALayerFrame( void AcceleratedWidgetMac::GotCALayerFrame(
base::scoped_nsobject<CALayer> content_layer, base::scoped_nsobject<CALayer> content_layer,
const gfx::Size& pixel_size, const gfx::Size& pixel_size,
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
DCHECK(compositor_) << "Drawing with no compositor set."; DCHECK(compositor_) << "Drawing with no compositor set.";
compositor_->ScheduleFullRedraw(); compositor_->ScheduleFullRedraw();
} }
- (gfx::AcceleratedWidget)widget {
return compositor_->widget();
}
@end @end
namespace ui { namespace ui {
...@@ -142,7 +146,7 @@ void TestCompositorHostMac::Show() { ...@@ -142,7 +146,7 @@ void TestCompositorHostMac::Show() {
defer:NO]; defer:NO];
base::scoped_nsobject<AcceleratedTestView> view( base::scoped_nsobject<AcceleratedTestView> view(
[[AcceleratedTestView alloc] init]); [[AcceleratedTestView alloc] init]);
compositor_.SetAcceleratedWidget(view); compositor_.SetAcceleratedWidget([view widget]);
compositor_.SetScaleAndSize(1.0f, bounds_.size()); compositor_.SetScaleAndSize(1.0f, bounds_.size());
[view setCompositor:&compositor_]; [view setCompositor:&compositor_];
[window_ setContentView:view]; [window_ setContentView:view];
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <utility> #include <utility>
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/mojo/buffer_types_struct_traits.h" #include "ui/gfx/mojo/buffer_types_struct_traits.h"
...@@ -18,7 +19,7 @@ namespace gfx { ...@@ -18,7 +19,7 @@ namespace gfx {
namespace { namespace {
gfx::AcceleratedWidget castToAcceleratedWidget(int i) { gfx::AcceleratedWidget castToAcceleratedWidget(int i) {
#if defined(USE_OZONE) || defined(USE_X11) #if defined(USE_OZONE) || defined(USE_X11) || defined(OS_MACOSX)
return static_cast<gfx::AcceleratedWidget>(i); return static_cast<gfx::AcceleratedWidget>(i);
#else #else
return reinterpret_cast<gfx::AcceleratedWidget>(i); return reinterpret_cast<gfx::AcceleratedWidget>(i);
......
...@@ -187,7 +187,7 @@ constexpr AcceleratedWidget kNullAcceleratedWidget = 0; ...@@ -187,7 +187,7 @@ constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
typedef UIView* AcceleratedWidget; typedef UIView* AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = 0; constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
typedef NSView* AcceleratedWidget; typedef uint64_t AcceleratedWidget;
constexpr AcceleratedWidget kNullAcceleratedWidget = 0; constexpr AcceleratedWidget kNullAcceleratedWidget = 0;
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
typedef ANativeWindow* AcceleratedWidget; typedef ANativeWindow* AcceleratedWidget;
......
...@@ -1063,7 +1063,7 @@ void BridgedNativeWidget::OnShowAnimationComplete() { ...@@ -1063,7 +1063,7 @@ void BridgedNativeWidget::OnShowAnimationComplete() {
ui::InputMethod* BridgedNativeWidget::GetInputMethod() { ui::InputMethod* BridgedNativeWidget::GetInputMethod() {
if (!input_method_) { if (!input_method_) {
input_method_ = ui::CreateInputMethod(this, nil); input_method_ = ui::CreateInputMethod(this, gfx::kNullAcceleratedWidget);
// For now, use always-focused mode on Mac for the input method. // For now, use always-focused mode on Mac for the input method.
// TODO(tapted): Move this to OnWindowKeyStatusChangedTo() and balance. // TODO(tapted): Move this to OnWindowKeyStatusChangedTo() and balance.
input_method_->OnFocus(); input_method_->OnFocus();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment