| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GPU_GPU_DATA_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class CommandLine; | 22 class CommandLine; |
| 23 | 23 |
| 24 class CONTENT_EXPORT GpuDataManagerImpl | 24 class CONTENT_EXPORT GpuDataManagerImpl |
| 25 : public NON_EXPORTED_BASE(content::GpuDataManager) { | 25 : public NON_EXPORTED_BASE(content::GpuDataManager) { |
| 26 public: | 26 public: |
| 27 // Getter for the singleton. This will return NULL on failure. | 27 // Getter for the singleton. This will return NULL on failure. |
| 28 static GpuDataManagerImpl* GetInstance(); | 28 static GpuDataManagerImpl* GetInstance(); |
| 29 | 29 |
| 30 // GpuDataManager implementation. | 30 // GpuDataManager implementation. |
| 31 virtual content::GpuFeatureType GetGpuFeatureType() OVERRIDE; | 31 virtual void InitializeGpuInfo() OVERRIDE; |
| 32 virtual void SetGpuFeatureType(content::GpuFeatureType feature_type) OVERRIDE; | 32 virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE; |
| 33 virtual void SetPreliminaryBlacklistedFeatures( |
| 34 content::GpuFeatureType features) OVERRIDE; |
| 33 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; | 35 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; |
| 34 virtual bool GpuAccessAllowed() OVERRIDE; | 36 virtual bool GpuAccessAllowed() const OVERRIDE; |
| 35 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; | 37 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; |
| 36 virtual bool IsCompleteGPUInfoAvailable() const OVERRIDE; | 38 virtual bool IsCompleteGpuInfoAvailable() const OVERRIDE; |
| 37 virtual void RequestVideoMemoryUsageStatsUpdate() OVERRIDE; | 39 virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE; |
| 38 virtual bool ShouldUseSoftwareRendering() OVERRIDE; | 40 virtual bool ShouldUseSoftwareRendering() const OVERRIDE; |
| 39 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; | 41 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; |
| 40 virtual const base::ListValue& GetLogMessages() const OVERRIDE; | 42 virtual void AddLogMessage(int level, const std::string& header, |
| 43 const std::string& message) OVERRIDE; |
| 44 virtual base::ListValue* GetLogMessages() const OVERRIDE; |
| 41 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; | 45 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; |
| 42 virtual void RemoveObserver( | 46 virtual void RemoveObserver( |
| 43 content::GpuDataManagerObserver* observer) OVERRIDE; | 47 content::GpuDataManagerObserver* observer) OVERRIDE; |
| 44 | 48 |
| 45 // Only update if the current GPUInfo is not finalized. | 49 // Only update if the current GPUInfo is not finalized. |
| 46 void UpdateGpuInfo(const content::GPUInfo& gpu_info); | 50 void UpdateGpuInfo(const content::GPUInfo& gpu_info); |
| 47 | 51 |
| 48 void UpdateVideoMemoryUsageStats( | 52 void UpdateVideoMemoryUsageStats( |
| 49 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); | 53 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); |
| 50 | 54 |
| 51 void AddLogMessage(Value* msg); | |
| 52 | |
| 53 // Insert disable-feature switches corresponding to preliminary gpu feature | 55 // Insert disable-feature switches corresponding to preliminary gpu feature |
| 54 // flags into the renderer process command line. | 56 // flags into the renderer process command line. |
| 55 void AppendRendererCommandLine(CommandLine* command_line); | 57 void AppendRendererCommandLine(CommandLine* command_line) const; |
| 56 | 58 |
| 57 // Insert switches into gpu process command line: kUseGL, | 59 // Insert switches into gpu process command line: kUseGL, |
| 58 // kDisableGLMultisampling. | 60 // kDisableGLMultisampling. |
| 59 void AppendGpuCommandLine(CommandLine* command_line); | 61 void AppendGpuCommandLine(CommandLine* command_line) const; |
| 60 | 62 |
| 61 // Insert switches into plugin process command line: | 63 // Insert switches into plugin process command line: |
| 62 // kDisableCoreAnimationPlugins. | 64 // kDisableCoreAnimationPlugins. |
| 63 void AppendPluginCommandLine(CommandLine* command_line); | 65 void AppendPluginCommandLine(CommandLine* command_line) const; |
| 64 | |
| 65 // This gets called when switching GPU might have happened. | |
| 66 void HandleGpuSwitch(); | |
| 67 | 66 |
| 68 // Force the current card to be blacklisted (usually due to GPU process | 67 // Force the current card to be blacklisted (usually due to GPU process |
| 69 // crashes). | 68 // crashes). |
| 70 void BlacklistCard(); | 69 void BlacklistCard(); |
| 71 | 70 |
| 72 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 73 // Is the GPU process using the accelerated surface to present, instead of | 72 // Is the GPU process using the accelerated surface to present, instead of |
| 74 // presenting by itself. | 73 // presenting by itself. |
| 75 bool IsUsingAcceleratedSurface(); | 74 bool IsUsingAcceleratedSurface() const; |
| 76 #endif | 75 #endif |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 typedef ObserverListThreadSafe<content::GpuDataManagerObserver> | 78 typedef ObserverListThreadSafe<content::GpuDataManagerObserver> |
| 80 GpuDataManagerObserverList; | 79 GpuDataManagerObserverList; |
| 81 | 80 |
| 82 friend struct DefaultSingletonTraits<GpuDataManagerImpl>; | 81 friend struct DefaultSingletonTraits<GpuDataManagerImpl>; |
| 83 | 82 |
| 84 GpuDataManagerImpl(); | 83 GpuDataManagerImpl(); |
| 85 virtual ~GpuDataManagerImpl(); | 84 virtual ~GpuDataManagerImpl(); |
| 86 | 85 |
| 87 void Initialize(); | |
| 88 | |
| 89 // If flags hasn't been set and GPUInfo is available, run through blacklist | 86 // If flags hasn't been set and GPUInfo is available, run through blacklist |
| 90 // and compute the flags. | 87 // and compute the flags. |
| 91 void UpdateGpuFeatureType(content::GpuFeatureType embedder_feature_type); | 88 void UpdateBlacklistedFeatures(content::GpuFeatureType features); |
| 92 | 89 |
| 93 // Notify all observers whenever there is a GPU info update. | 90 // Notify all observers whenever there is a GPU info update. |
| 94 void NotifyGpuInfoUpdate(); | 91 void NotifyGpuInfoUpdate(); |
| 95 | 92 |
| 96 // If use-gl switch is osmesa or any, return true. | |
| 97 bool UseGLIsOSMesaOrAny(); | |
| 98 | |
| 99 // Try to switch to software rendering, if possible and necessary. | 93 // Try to switch to software rendering, if possible and necessary. |
| 100 void EnableSoftwareRenderingIfNecessary(); | 94 void EnableSoftwareRenderingIfNecessary(); |
| 101 | 95 |
| 102 bool complete_gpu_info_already_requested_; | 96 bool complete_gpu_info_already_requested_; |
| 103 bool complete_gpu_info_available_; | |
| 104 | 97 |
| 105 content::GpuFeatureType gpu_feature_type_; | 98 content::GpuFeatureType gpu_feature_type_; |
| 106 content::GpuFeatureType preliminary_gpu_feature_type_; | 99 content::GpuFeatureType preliminary_gpu_feature_type_; |
| 107 | 100 |
| 108 content::GPUInfo gpu_info_; | 101 content::GPUInfo gpu_info_; |
| 109 mutable base::Lock gpu_info_lock_; | 102 mutable base::Lock gpu_info_lock_; |
| 110 | 103 |
| 111 // Observers. | |
| 112 const scoped_refptr<GpuDataManagerObserverList> observer_list_; | 104 const scoped_refptr<GpuDataManagerObserverList> observer_list_; |
| 113 | 105 |
| 114 ListValue log_messages_; | 106 ListValue log_messages_; |
| 107 mutable base::Lock log_messages_lock_; |
| 108 |
| 115 bool software_rendering_; | 109 bool software_rendering_; |
| 116 | 110 |
| 117 FilePath swiftshader_path_; | 111 FilePath swiftshader_path_; |
| 118 | 112 |
| 119 // Current card force-blacklisted due to GPU crashes, or disabled through | 113 // Current card force-blacklisted due to GPU crashes, or disabled through |
| 120 // the --disable-gpu commandline switch. | 114 // the --disable-gpu commandline switch. |
| 121 bool card_blacklisted_; | 115 bool card_blacklisted_; |
| 122 | 116 |
| 123 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); | 117 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); |
| 124 }; | 118 }; |
| 125 | 119 |
| 126 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 120 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
| OLD | NEW |