Cast: Skip receiver log messages with time delta that can't be encoded.
[chromium-blink-merge.git] / content / browser / renderer_host / compositing_iosurface_context_mac.h
blob55c20e285b4c27eb0c9ca26396a83f03cc2b3994
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
8 #import <AppKit/NSOpenGL.h>
9 #include <OpenGL/OpenGL.h>
10 #include <map>
12 #include "base/basictypes.h"
13 #include "base/lazy_instance.h"
14 #include "base/mac/scoped_nsobject.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "ui/gl/scoped_cgl.h"
19 namespace content {
21 enum CoreAnimationStatus {
22 CORE_ANIMATION_DISABLED,
23 CORE_ANIMATION_ENABLED,
25 CoreAnimationStatus GetCoreAnimationStatus();
27 class CompositingIOSurfaceShaderPrograms;
29 class CompositingIOSurfaceContext
30 : public base::RefCounted<CompositingIOSurfaceContext> {
31 public:
32 enum {
33 // The number used to look up the context used for async readback and for
34 // initializing the IOSurface.
35 kOffscreenContextWindowNumber = -2,
36 // The number used to look up the context used by CAOpenGLLayers.
37 kCALayerContextWindowNumber = -3,
40 // Get or create a GL context for the specified window with the specified
41 // surface ordering. Share these GL contexts as much as possible because
42 // creating and destroying them can be expensive
43 // http://crbug.com/180463
44 static scoped_refptr<CompositingIOSurfaceContext> Get(int window_number);
46 // Mark that all the currently existing GL contexts shouldn't be returned
47 // anymore by Get, but rather, new contexts should be created. This is
48 // called as a precaution when unexpected GL errors occur.
49 static void MarkExistingContextsAsNotShareable();
51 CompositingIOSurfaceShaderPrograms* shader_program_cache() const {
52 return shader_program_cache_.get();
54 NSOpenGLContext* nsgl_context() const;
55 CGLContextObj cgl_context() const { return cgl_context_; }
56 bool is_vsync_disabled() const { return is_vsync_disabled_; }
57 int window_number() const { return window_number_; }
59 bool IsVendorIntel();
61 private:
62 friend class base::RefCounted<CompositingIOSurfaceContext>;
64 CompositingIOSurfaceContext(
65 int window_number,
66 NSOpenGLContext* nsgl_context,
67 base::ScopedTypeRef<CGLContextObj> clg_context_strong,
68 CGLContextObj clg_context,
69 bool is_vsync_disabled_,
70 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache);
71 ~CompositingIOSurfaceContext();
73 int window_number_;
74 base::scoped_nsobject<NSOpenGLContext> nsgl_context_;
75 base::ScopedTypeRef<CGLContextObj> cgl_context_strong_;
76 // Weak, backed by |nsgl_context_| or |cgl_context_strong_|.
77 CGLContextObj cgl_context_;
79 bool is_vsync_disabled_;
80 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache_;
81 bool can_be_shared_;
83 bool initialized_is_intel_;
84 bool is_intel_;
85 GLint screen_;
87 // The global map from window number and window ordering to
88 // context data.
89 typedef std::map<int, CompositingIOSurfaceContext*> WindowMap;
90 static base::LazyInstance<WindowMap> window_map_;
91 static WindowMap* window_map();
94 } // namespace content
96 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_