Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_COMPOSITOR_ACCELERATED_WIDGET_HELPER_MAC_H_ | 5 #ifndef UI_COMPOSITOR_MAC_ACCELERATED_WIDGET_HELPER_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_ACCELERATED_WIDGET_HELPER_MAC_H_ | 6 #define UI_COMPOSITOR_MAC_ACCELERATED_WIDGET_HELPER_MAC_H_ |
| 7 | 7 |
| 8 #include <IOSurface/IOSurfaceAPI.h> | 8 #include <IOSurface/IOSurfaceAPI.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "skia/ext/platform_canvas.h" | 11 #include "ui/compositor/compositor_export.h" |
| 12 #include "ui/events/latency_info.h" | 12 #include "ui/events/latency_info.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 | 15 |
| 16 #if defined(__OBJC__) | 16 #if defined(__OBJC__) |
| 17 #import <Cocoa/Cocoa.h> | 17 #import <Cocoa/Cocoa.h> |
| 18 #import "base/mac/scoped_nsobject.h" | 18 #import "base/mac/scoped_nsobject.h" |
| 19 #import "content/browser/compositor/io_surface_layer_mac.h" | |
| 20 #include "ui/base/cocoa/remote_layer_api.h" | 19 #include "ui/base/cocoa/remote_layer_api.h" |
|
ccameron
2014/11/25 17:54:25
I'd prefer for software_layer to live in ui/compos
tapted
2014/11/25 23:53:55
Done. There was an earlier objection to it being i
| |
| 21 #import "ui/base/cocoa/software_layer.h" | 20 #import "ui/base/cocoa/software_layer.h" |
| 21 #import "ui/compositor/mac/io_surface_layer_mac.h" | |
| 22 #endif // __OBJC__ | 22 #endif // __OBJC__ |
| 23 | 23 |
| 24 class SkCanvas; | |
| 25 | |
| 24 namespace cc { | 26 namespace cc { |
| 25 class SoftwareFrameData; | 27 class SoftwareFrameData; |
| 26 } | 28 } |
| 27 | 29 |
| 30 // TODO(tapted): Move this out of content namespace. | |
|
ccameron
2014/11/25 17:54:25
I'd prefer to move this stuff to ui:: in this patc
tapted
2014/11/25 23:53:55
Done. (with ui:: for now so you can see how it loo
| |
| 28 namespace content { | 31 namespace content { |
| 29 | 32 |
| 30 class AcceleratedWidgetMac; | 33 class AcceleratedWidgetMac; |
| 31 | 34 |
| 32 // A class through which an AcceleratedWidget may be bound to draw the contents | 35 // A class through which an AcceleratedWidget may be bound to draw the contents |
| 33 // of an NSView. An AcceleratedWidget may be bound to multiple different views | 36 // of an NSView. An AcceleratedWidget may be bound to multiple different views |
| 34 // throughout its lifetime (one at a time, though). | 37 // throughout its lifetime (one at a time, though). |
| 35 class AcceleratedWidgetMacNSView { | 38 class AcceleratedWidgetMacNSView { |
| 36 public: | 39 public: |
| 37 virtual NSView* AcceleratedWidgetGetNSView() const = 0; | 40 virtual NSView* AcceleratedWidgetGetNSView() const = 0; |
| 38 virtual bool AcceleratedWidgetShouldIgnoreBackpressure() const = 0; | 41 virtual bool AcceleratedWidgetShouldIgnoreBackpressure() const = 0; |
| 42 virtual bool AcceleratedWidgetNeedsGLFinishWorkaround() const = 0; | |
| 39 virtual void AcceleratedWidgetSwapCompleted( | 43 virtual void AcceleratedWidgetSwapCompleted( |
| 40 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 44 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
| 41 virtual void AcceleratedWidgetHitError() = 0; | 45 virtual void AcceleratedWidgetHitError() = 0; |
| 42 }; | 46 }; |
| 43 | 47 |
| 44 #if defined(__OBJC__) | 48 #if defined(__OBJC__) |
| 45 | 49 |
| 46 // AcceleratedWidgetMac owns a tree of CALayers. The widget may be passed | 50 // AcceleratedWidgetMac owns a tree of CALayers. The widget may be passed |
| 47 // to a ui::Compositor, which will cause, through its output surface, calls to | 51 // to a ui::Compositor, which will cause, through its output surface, calls to |
| 48 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed | 52 // GotAcceleratedFrame and GotSoftwareFrame. The CALayers may be installed |
| 49 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper. | 53 // in an NSView by setting the AcceleratedWidgetMacNSView for the helper. |
| 50 class AcceleratedWidgetMac : public IOSurfaceLayerClient { | 54 class COMPOSITOR_EXPORT AcceleratedWidgetMac : public IOSurfaceLayerClient { |
| 51 public: | 55 public: |
| 52 AcceleratedWidgetMac(); | 56 AcceleratedWidgetMac(); |
| 53 virtual ~AcceleratedWidgetMac(); | 57 virtual ~AcceleratedWidgetMac(); |
| 54 | 58 |
| 55 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; } | 59 gfx::AcceleratedWidget accelerated_widget() { return native_widget_; } |
| 56 | 60 |
| 57 void SetNSView(AcceleratedWidgetMacNSView* view); | 61 void SetNSView(AcceleratedWidgetMacNSView* view); |
| 58 void ResetNSView(); | 62 void ResetNSView(); |
| 59 | 63 |
| 60 // Return true if the last frame swapped has a size in DIP of |dip_size|. | 64 // Return true if the last frame swapped has a size in DIP of |dip_size|. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 77 gfx::Size pixel_size, | 81 gfx::Size pixel_size, |
| 78 float scale_factor, | 82 float scale_factor, |
| 79 const base::Closure& drawn_callback); | 83 const base::Closure& drawn_callback); |
| 80 | 84 |
| 81 void GotSoftwareFrame( | 85 void GotSoftwareFrame( |
| 82 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); | 86 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 83 | 87 |
| 84 private: | 88 private: |
| 85 // IOSurfaceLayerClient implementation: | 89 // IOSurfaceLayerClient implementation: |
| 86 bool IOSurfaceLayerShouldAckImmediately() const override; | 90 bool IOSurfaceLayerShouldAckImmediately() const override; |
| 91 bool IOSurfaceNeedsGLFinishWorkaround() const override; | |
| 87 void IOSurfaceLayerDidDrawFrame() override; | 92 void IOSurfaceLayerDidDrawFrame() override; |
| 88 void IOSurfaceLayerHitError() override; | 93 void IOSurfaceLayerHitError() override; |
| 89 | 94 |
| 90 void GotAcceleratedCAContextFrame( | 95 void GotAcceleratedCAContextFrame( |
| 91 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); | 96 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); |
| 92 | 97 |
| 93 void GotAcceleratedIOSurfaceFrame( | 98 void GotAcceleratedIOSurfaceFrame( |
| 94 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); | 99 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); |
| 95 | 100 |
| 96 void AcknowledgeAcceleratedFrame(); | 101 void AcknowledgeAcceleratedFrame(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 base::Closure accelerated_frame_drawn_callback_; | 141 base::Closure accelerated_frame_drawn_callback_; |
| 137 | 142 |
| 138 // The size in DIP of the last swap received from |compositor_|. | 143 // The size in DIP of the last swap received from |compositor_|. |
| 139 gfx::Size last_swap_size_dip_; | 144 gfx::Size last_swap_size_dip_; |
| 140 | 145 |
| 141 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac); | 146 DISALLOW_COPY_AND_ASSIGN(AcceleratedWidgetMac); |
| 142 }; | 147 }; |
| 143 | 148 |
| 144 #endif // __OBJC__ | 149 #endif // __OBJC__ |
| 145 | 150 |
| 151 COMPOSITOR_EXPORT | |
| 146 void AcceleratedWidgetMacGotAcceleratedFrame( | 152 void AcceleratedWidgetMacGotAcceleratedFrame( |
| 147 gfx::AcceleratedWidget widget, uint64 surface_handle, | 153 gfx::AcceleratedWidget widget, uint64 surface_handle, |
| 148 const std::vector<ui::LatencyInfo>& latency_info, | 154 const std::vector<ui::LatencyInfo>& latency_info, |
| 149 gfx::Size pixel_size, float scale_factor, | 155 gfx::Size pixel_size, float scale_factor, |
| 150 const base::Closure& drawn_callback, | 156 const base::Closure& drawn_callback, |
| 151 bool* disable_throttling, int* renderer_id); | 157 bool* disable_throttling, int* renderer_id); |
| 152 | 158 |
| 159 COMPOSITOR_EXPORT | |
| 153 void AcceleratedWidgetMacGotSoftwareFrame( | 160 void AcceleratedWidgetMacGotSoftwareFrame( |
| 154 gfx::AcceleratedWidget widget, | 161 gfx::AcceleratedWidget widget, |
| 155 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); | 162 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 156 | 163 |
| 157 } // namespace content | 164 } // namespace content |
| 158 | 165 |
| 159 #endif // CONTENT_BROWSER_COMPOSITOR_ACCELERATED_WIDGET_HELPER_MAC_H_ | 166 #endif // UI_COMPOSITOR_MAC_ACCELERATED_WIDGET_HELPER_MAC_H_ |
| OLD | NEW |