| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H |
| 6 #define CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H | 6 #define CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
| 10 | 10 |
| 11 #include "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 13 | 13 |
| 14 class RenderWidgetHostViewMac; | 14 class RenderWidgetHostViewMac; |
| 15 | 15 |
| 16 // Informal protocol implemented by windows that need to be informed explicitly | 16 // Informal protocol implemented by windows that need to be informed explicitly |
| 17 // about underlay surfaces. | 17 // about underlay surfaces. |
| 18 @interface NSObject (UnderlayableSurface) | 18 @interface NSObject (UnderlayableSurface) |
| 19 - (void)underlaySurfaceAdded; | 19 - (void)underlaySurfaceAdded; |
| 20 - (void)underlaySurfaceRemoved; | 20 - (void)underlaySurfaceRemoved; |
| 21 @end | 21 @end |
| 22 | 22 |
| 23 // This subclass of NSView hosts the output of accelerated plugins on | 23 // This subclass of NSView hosts the output of accelerated plugins on |
| 24 // the page. | 24 // the page. |
| 25 | |
| 26 // This class takes a couple of locks, some indirectly. The lock hiearchy is: | |
| 27 // 1. The DisplayLink lock, implicit to the display link owned by this view. | |
| 28 // It is taken by the framework before |DrawOneAcceleratedPluginCallback()| | |
| 29 // is called, and during CVDisplayLink* function calls. | |
| 30 // 2. The CGL lock, taken explicitly. | |
| 31 // 3. The AcceleratedSurfaceContainerManagerMac's lock, which it takes when any | |
| 32 // of its methods are called. | |
| 33 // | |
| 34 // No code should ever try to acquire a lock further up in the hierarchy if it | |
| 35 // already owns a lower lock. For example, while the CGL lock is taken, no | |
| 36 // CVDisplayLink* functions must be called. | |
| 37 @interface AcceleratedPluginView : NSView { | 25 @interface AcceleratedPluginView : NSView { |
| 38 scoped_nsobject<NSOpenGLPixelFormat> glPixelFormat_; | 26 scoped_nsobject<NSOpenGLPixelFormat> glPixelFormat_; |
| 39 CGLPixelFormatObj cglPixelFormat_; // weak, backed by |glPixelFormat_|. | 27 CGLPixelFormatObj cglPixelFormat_; // weak, backed by |glPixelFormat_|. |
| 40 scoped_nsobject<NSOpenGLContext> glContext_; | 28 scoped_nsobject<NSOpenGLContext> glContext_; |
| 41 CGLContextObj cglContext_; // weak, backed by |glContext_|. | 29 CGLContextObj cglContext_; // weak, backed by |glContext_|. |
| 42 | 30 |
| 43 CVDisplayLinkRef displayLink_; // Owned by us. | |
| 44 | |
| 45 RenderWidgetHostViewMac* renderWidgetHostView_; // weak | 31 RenderWidgetHostViewMac* renderWidgetHostView_; // weak |
| 46 gfx::PluginWindowHandle pluginHandle_; // weak | 32 gfx::PluginWindowHandle pluginHandle_; // weak |
| 47 | 33 |
| 48 // The number of swap buffers calls that have been requested by the | |
| 49 // GPU process, or a monotonically increasing number of calls to | |
| 50 // updateSwapBuffersCount:fromRenderer:routeId: if the update came | |
| 51 // from an accelerated plugin. | |
| 52 uint64 swapBuffersCount_; | |
| 53 // The number of swap buffers calls that have been processed by the | |
| 54 // display link thread. This is only used with the GPU process | |
| 55 // update path. | |
| 56 volatile uint64 acknowledgedSwapBuffersCount_; | |
| 57 | |
| 58 // Auxiliary information needed to formulate an acknowledgment to | |
| 59 // the GPU process. These are constant after the first message. | |
| 60 // These are all zero for updates coming from a plugin process. | |
| 61 volatile int rendererId_; | |
| 62 volatile int32 routeId_; | |
| 63 volatile int gpuHostId_; | |
| 64 | |
| 65 // Cocoa methods can only be called on the main thread, so have a copy of the | |
| 66 // view's size, since it's required on the displaylink thread. | |
| 67 NSSize cachedSize_; | |
| 68 | |
| 69 // Rects that should show web content rather than plugin content. | 34 // Rects that should show web content rather than plugin content. |
| 70 scoped_nsobject<NSArray> cutoutRects_; | 35 scoped_nsobject<NSArray> cutoutRects_; |
| 71 | 36 |
| 72 // -globalFrameDidChange: can be called recursively, this counts how often it | 37 // -globalFrameDidChange: can be called recursively, this counts how often it |
| 73 // holds the CGL lock. | 38 // holds the CGL lock. |
| 74 int globalFrameDidChangeCGLLockCount_; | 39 int globalFrameDidChangeCGLLockCount_; |
| 75 } | 40 } |
| 76 | 41 |
| 77 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r | 42 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r |
| 78 pluginHandle:(gfx::PluginWindowHandle)pluginHandle; | 43 pluginHandle:(gfx::PluginWindowHandle)pluginHandle; |
| 79 - (void)drawView; | 44 - (void)drawView; |
| 80 | 45 |
| 81 // Sets the list of rectangles that should show the web page, rather than the | 46 // Sets the list of rectangles that should show the web page, rather than the |
| 82 // accelerated plugin. This is used to simulate the iframe-based trick that web | 47 // accelerated plugin. This is used to simulate the iframe-based trick that web |
| 83 // pages have long used to show web content above windowed plugins on Windows | 48 // pages have long used to show web content above windowed plugins on Windows |
| 84 // and Linux. | 49 // and Linux. |
| 85 - (void)setCutoutRects:(NSArray*)cutout_rects; | 50 - (void)setCutoutRects:(NSArray*)cutout_rects; |
| 86 | 51 |
| 87 // Updates the number of swap buffers calls that have been requested. | |
| 88 // This is currently called with non-zero values only in response to | |
| 89 // updates from the GPU process. For accelerated plugins, all zeros | |
| 90 // are passed, and the view takes this as a hint that no flow control | |
| 91 // or acknowledgment of the swap buffers are desired. | |
| 92 - (void)updateSwapBuffersCount:(uint64)count | |
| 93 fromRenderer:(int)rendererId | |
| 94 routeId:(int32)routeId | |
| 95 gpuHostId:(int)gpuHostId; | |
| 96 | |
| 97 // NSViews autorelease subviews when they die. The RWHVMac gets destroyed when | 52 // NSViews autorelease subviews when they die. The RWHVMac gets destroyed when |
| 98 // RHWVCocoa gets dealloc'd, which means the AcceleratedPluginView child views | 53 // RHWVCocoa gets dealloc'd, which means the AcceleratedPluginView child views |
| 99 // can be around a little longer than the RWHVMac. This is called when the | 54 // can be around a little longer than the RWHVMac. This is called when the |
| 100 // RWHVMac is about to be deleted (but it's still valid while this method runs). | 55 // RWHVMac is about to be deleted (but it's still valid while this method runs). |
| 101 - (void)onRenderWidgetHostViewGone; | 56 - (void)onRenderWidgetHostViewGone; |
| 102 | 57 |
| 103 // This _must_ be atomic, since it's accessed from several threads. | |
| 104 @property NSSize cachedSize; | |
| 105 @end | 58 @end |
| 106 | 59 |
| 107 #endif // CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H | 60 #endif // CHROME_BROWSER_RENDERER_HOST_ACCELERATED_PLUGIN_VIEW_MAC_H |
| OLD | NEW |