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

Side by Side Diff: ui/accelerated_widget_mac/io_surface_ns_gl_surface.h

Issue 1164363005: Mac: Only allow NSOpenGLContext displaying on the main display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add GPU switch Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_ 5 #ifndef UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_
6 #define UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_ 6 #define UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_
7 7
8 #include <Cocoa/Cocoa.h> 8 #include <Cocoa/Cocoa.h>
9 #include <OpenGL/OpenGL.h> 9 #include <OpenGL/OpenGL.h>
10 10
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "ui/accelerated_widget_mac/display_link_mac.h" 13 #include "ui/accelerated_widget_mac/display_link_mac.h"
14 #include "ui/accelerated_widget_mac/io_surface_context.h" 14 #include "ui/accelerated_widget_mac/io_surface_context.h"
15 #include "ui/accelerated_widget_mac/io_surface_texture.h" 15 #include "ui/accelerated_widget_mac/io_surface_texture.h"
16 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gl/gpu_switching_observer.h"
17 18
18 namespace ui { 19 namespace ui {
19 20
20 class IOSurfaceNSGLSurfaceClient { 21 class IOSurfaceNSGLSurfaceClient {
21 public: 22 public:
22 virtual void IOSurfaceNSGLSurfaceDidDrawFrame() = 0; 23 virtual void IOSurfaceNSGLSurfaceDidDrawFrame() = 0;
23 }; 24 };
24 25
25 class IOSurfaceNSGLSurface { 26 class IOSurfaceNSGLSurface : public ui::GpuSwitchingObserver {
26 public: 27 public:
27 static IOSurfaceNSGLSurface* Create( 28 static IOSurfaceNSGLSurface* Create(
28 IOSurfaceNSGLSurfaceClient* client, NSView* view); 29 IOSurfaceNSGLSurfaceClient* client,
30 NSView* view,
31 bool needs_gl_finish_workaround);
29 virtual ~IOSurfaceNSGLSurface(); 32 virtual ~IOSurfaceNSGLSurface();
30 33
31 // Called on the UI thread. 34 static bool CanUseNSGLSurfaceForView(NSView* view);
35
32 bool GotFrame(IOSurfaceID io_surface_id, 36 bool GotFrame(IOSurfaceID io_surface_id,
33 gfx::Size pixel_size, 37 gfx::Size pixel_size,
34 float scale_factor, 38 float scale_factor,
35 gfx::Rect pixel_damage_rect); 39 gfx::Rect pixel_damage_rect);
36 40
41 int GetRendererID();
42
43 bool NeedsToBeRecreated() const { return needs_to_be_recreated_; }
44
45 // ui::GpuSwitchingObserver implementation.
46 void OnGpuSwitched() override;
47
37 private: 48 private:
38 explicit IOSurfaceNSGLSurface( 49 explicit IOSurfaceNSGLSurface(
39 IOSurfaceNSGLSurfaceClient* client, 50 IOSurfaceNSGLSurfaceClient* client,
40 NSView* view, 51 NSView* view,
52 bool needs_gl_finish_workaround,
41 base::scoped_nsobject<NSOpenGLContext> ns_gl_context, 53 base::scoped_nsobject<NSOpenGLContext> ns_gl_context,
42 scoped_refptr<ui::IOSurfaceTexture> iosurface); 54 scoped_refptr<ui::IOSurfaceTexture> iosurface);
43 55
44 void DoPendingDrawIfNeeded(); 56 void DoPendingDrawIfNeeded();
45 57
46 IOSurfaceNSGLSurfaceClient* client_; 58 IOSurfaceNSGLSurfaceClient* client_;
47 NSView* view_; 59 NSView* view_;
48 scoped_refptr<IOSurfaceTexture> iosurface_; 60 scoped_refptr<IOSurfaceTexture> iosurface_;
49 base::scoped_nsobject<NSOpenGLContext> ns_gl_context_; 61 base::scoped_nsobject<NSOpenGLContext> ns_gl_context_;
50 62
51 // The size and scale factor of the backbuffer. 63 // The size and scale factor of the backbuffer.
52 gfx::Size contents_pixel_size_; 64 gfx::Size contents_pixel_size_;
53 float contents_scale_factor_; 65 float contents_scale_factor_;
54 66
55 // The state of a draw that has been sent to the surface, but has not been 67 // The state of a draw that has been sent to the surface, but has not been
56 // flushed yet. 68 // flushed yet.
57 bool pending_draw_exists_; 69 bool pending_draw_exists_;
58 gfx::Rect pending_draw_damage_rect_; 70 gfx::Rect pending_draw_damage_rect_;
71
72 // If the context has hit an error or has changed GPUs, then this will be
73 // set to true.
74 bool needs_to_be_recreated_;
59 }; 75 };
60 76
61 } // namespace ui 77 } // namespace ui
62 78
63 #endif // UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_ 79 #endif // UI_ACCELERATED_WIDGET_MAC_IO_SURFACE_NS_GL_SURFACE_H_
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_layer.mm ('k') | ui/accelerated_widget_mac/io_surface_ns_gl_surface.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698