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

Side by Side Diff: content/browser/renderer_host/compositing_iosurface_context_mac.h

Issue 472663004: Revert of Remove code used by --disable-delegated-renderer on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | content/browser/renderer_host/compositing_iosurface_context_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
7 7
8 #import <AppKit/NSOpenGL.h> 8 #import <AppKit/NSOpenGL.h>
9 #include <OpenGL/OpenGL.h> 9 #include <OpenGL/OpenGL.h>
10 #include <map> 10 #include <map>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/mac/scoped_nsobject.h" 14 #include "base/mac/scoped_nsobject.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "content/public/browser/gpu_data_manager_observer.h" 17 #include "content/public/browser/gpu_data_manager_observer.h"
18 #include "ui/gl/scoped_cgl.h" 18 #include "ui/gl/scoped_cgl.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 class CompositingIOSurfaceShaderPrograms;
23
22 class CompositingIOSurfaceContext 24 class CompositingIOSurfaceContext
23 : public base::RefCounted<CompositingIOSurfaceContext>, 25 : public base::RefCounted<CompositingIOSurfaceContext>,
24 public content::GpuDataManagerObserver { 26 public content::GpuDataManagerObserver {
25 public: 27 public:
26 enum { 28 enum {
27 // The number used to look up the context used for async readback and for 29 // The number used to look up the context used for async readback and for
28 // initializing the IOSurface. 30 // initializing the IOSurface.
29 kOffscreenContextWindowNumber = -2, 31 kOffscreenContextWindowNumber = -2,
30 // The number used to look up the context used by CAOpenGLLayers. 32 // The number used to look up the context used by CAOpenGLLayers.
31 kCALayerContextWindowNumber = -3, 33 kCALayerContextWindowNumber = -3,
32 }; 34 };
33 35
34 // Get or create a GL context for the specified window with the specified 36 // Get or create a GL context for the specified window with the specified
35 // surface ordering. Share these GL contexts as much as possible because 37 // surface ordering. Share these GL contexts as much as possible because
36 // creating and destroying them can be expensive 38 // creating and destroying them can be expensive
37 // http://crbug.com/180463 39 // http://crbug.com/180463
38 static scoped_refptr<CompositingIOSurfaceContext> Get(int window_number); 40 static scoped_refptr<CompositingIOSurfaceContext> Get(int window_number);
39 41
40 // Mark that all the GL contexts in the same sharegroup as this context as 42 // Mark that all the GL contexts in the same sharegroup as this context as
41 // invalid, so they shouldn't be returned anymore by Get, but rather, new 43 // invalid, so they shouldn't be returned anymore by Get, but rather, new
42 // contexts should be created. This is called as a precaution when unexpected 44 // contexts should be created. This is called as a precaution when unexpected
43 // GL errors occur. 45 // GL errors occur.
44 void PoisonContextAndSharegroup(); 46 void PoisonContextAndSharegroup();
45 bool HasBeenPoisoned() const { return poisoned_; } 47 bool HasBeenPoisoned() const { return poisoned_; }
46 48
49 CompositingIOSurfaceShaderPrograms* shader_program_cache() const {
50 return shader_program_cache_.get();
51 }
47 CGLContextObj cgl_context() const { return cgl_context_; } 52 CGLContextObj cgl_context() const { return cgl_context_; }
48 int window_number() const { return window_number_; } 53 int window_number() const { return window_number_; }
49 54
50 // content::GpuDataManagerObserver implementation. 55 // content::GpuDataManagerObserver implementation.
51 virtual void OnGpuSwitching() OVERRIDE; 56 virtual void OnGpuSwitching() OVERRIDE;
52 57
53 private: 58 private:
54 friend class base::RefCounted<CompositingIOSurfaceContext>; 59 friend class base::RefCounted<CompositingIOSurfaceContext>;
55 60
56 CompositingIOSurfaceContext( 61 CompositingIOSurfaceContext(
57 int window_number, 62 int window_number,
58 base::ScopedTypeRef<CGLContextObj> clg_context_strong, 63 base::ScopedTypeRef<CGLContextObj> clg_context_strong,
59 CGLContextObj clg_context); 64 CGLContextObj clg_context,
65 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache);
60 virtual ~CompositingIOSurfaceContext(); 66 virtual ~CompositingIOSurfaceContext();
61 67
62 int window_number_; 68 int window_number_;
63 base::ScopedTypeRef<CGLContextObj> cgl_context_strong_; 69 base::ScopedTypeRef<CGLContextObj> cgl_context_strong_;
64 // Weak, backed by |cgl_context_strong_|. 70 // Weak, backed by |cgl_context_strong_|.
65 CGLContextObj cgl_context_; 71 CGLContextObj cgl_context_;
66 72
73 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache_;
67 bool poisoned_; 74 bool poisoned_;
68 75
69 // The global map from window number and window ordering to 76 // The global map from window number and window ordering to
70 // context data. 77 // context data.
71 typedef std::map<int, CompositingIOSurfaceContext*> WindowMap; 78 typedef std::map<int, CompositingIOSurfaceContext*> WindowMap;
72 static base::LazyInstance<WindowMap> window_map_; 79 static base::LazyInstance<WindowMap> window_map_;
73 static WindowMap* window_map(); 80 static WindowMap* window_map();
74 }; 81 };
75 82
76 } // namespace content 83 } // namespace content
77 84
78 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_ 85 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/compositing_iosurface_context_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698