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

Side by Side Diff: content/browser/gpu/gpu_data_manager.cc

Issue 8772031: Add a JS API for detecting WebGL availability. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_data_manager.h ('k') | content/browser/gpu/gpu_process_host.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/gpu/gpu_data_manager.h" 5 #include "content/browser/gpu/gpu_data_manager.h"
6 6
7 #if defined(OS_MACOSX) 7 #if defined(OS_MACOSX)
8 #include <CoreGraphics/CGDisplayConfiguration.h> 8 #include <CoreGraphics/CGDisplayConfiguration.h>
9 #endif 9 #endif
10 10
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void GpuDataManager::UserFlags::ApplyPolicies() { 190 void GpuDataManager::UserFlags::ApplyPolicies() {
191 if (disable_accelerated_compositing_) { 191 if (disable_accelerated_compositing_) {
192 disable_accelerated_2d_canvas_ = true; 192 disable_accelerated_2d_canvas_ = true;
193 disable_accelerated_layers_ = true; 193 disable_accelerated_layers_ = true;
194 } 194 }
195 } 195 }
196 196
197 GpuDataManager::GpuDataManager() 197 GpuDataManager::GpuDataManager()
198 : complete_gpu_info_already_requested_(false), 198 : complete_gpu_info_already_requested_(false),
199 complete_gpu_info_available_(false),
199 observer_list_(new GpuDataManagerObserverList), 200 observer_list_(new GpuDataManagerObserverList),
200 software_rendering_(false) { 201 software_rendering_(false) {
201 Initialize(); 202 Initialize();
202 } 203 }
203 204
204 void GpuDataManager::Initialize() { 205 void GpuDataManager::Initialize() {
205 // User flags need to be collected before any further initialization. 206 // User flags need to be collected before any further initialization.
206 user_flags_.Initialize(); 207 user_flags_.Initialize();
207 208
208 if (!user_flags_.skip_gpu_data_loading()) { 209 if (!user_flags_.skip_gpu_data_loading()) {
209 content::GPUInfo gpu_info; 210 content::GPUInfo gpu_info;
210 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); 211 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
211 UpdateGpuInfo(gpu_info); 212 {
213 base::AutoLock auto_lock(gpu_info_lock_);
214 gpu_info_ = gpu_info;
215 }
212 } 216 }
213 217
214 #if defined(OS_MACOSX) 218 #if defined(OS_MACOSX)
215 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); 219 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this);
216 #endif 220 #endif
217 } 221 }
218 222
219 GpuDataManager::~GpuDataManager() { 223 GpuDataManager::~GpuDataManager() {
220 #if defined(OS_MACOSX) 224 #if defined(OS_MACOSX)
221 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); 225 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this);
222 #endif 226 #endif
223 } 227 }
224 228
225 // static 229 // static
226 GpuDataManager* GpuDataManager::GetInstance() { 230 GpuDataManager* GpuDataManager::GetInstance() {
227 return Singleton<GpuDataManager>::get(); 231 return Singleton<GpuDataManager>::get();
228 } 232 }
229 233
230 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() { 234 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
232 if (complete_gpu_info_already_requested_) 236
237 if (complete_gpu_info_already_requested_ || complete_gpu_info_available_)
233 return; 238 return;
234 complete_gpu_info_already_requested_ = true; 239 complete_gpu_info_already_requested_ = true;
235 240
236 GpuProcessHost::SendOnIO( 241 GpuProcessHost::SendOnIO(
237 0, 242 0,
238 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE D, 243 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE D,
239 new GpuMsg_CollectGraphicsInfo()); 244 new GpuMsg_CollectGraphicsInfo());
240 } 245 }
241 246
242 void GpuDataManager::UpdateGpuInfo(const content::GPUInfo& gpu_info) { 247 void GpuDataManager::UpdateGpuInfo(const content::GPUInfo& gpu_info) {
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
249
250 complete_gpu_info_available_ = true;
251 complete_gpu_info_already_requested_ = true;
243 { 252 {
244 base::AutoLock auto_lock(gpu_info_lock_); 253 base::AutoLock auto_lock(gpu_info_lock_);
245 if (!Merge(&gpu_info_, gpu_info)) 254 if (!Merge(&gpu_info_, gpu_info))
246 return; 255 return;
247 }
248
249 NotifyGpuInfoUpdate();
250
251 {
252 base::AutoLock auto_lock(gpu_info_lock_);
253 content::GetContentClient()->SetGpuInfo(gpu_info_); 256 content::GetContentClient()->SetGpuInfo(gpu_info_);
254 } 257 }
255 258
256 UpdateGpuFeatureFlags(); 259 UpdateGpuFeatureFlags();
260 // We have to update GpuFeatureFlags before notify all the observers.
261 NotifyGpuInfoUpdate();
257 } 262 }
258 263
259 const content::GPUInfo& GpuDataManager::gpu_info() const { 264 const content::GPUInfo& GpuDataManager::gpu_info() const {
260 base::AutoLock auto_lock(gpu_info_lock_); 265 base::AutoLock auto_lock(gpu_info_lock_);
261 return gpu_info_; 266 return gpu_info_;
262 } 267 }
263 268
264 Value* GpuDataManager::GetFeatureStatus() { 269 Value* GpuDataManager::GetFeatureStatus() {
265 bool gpu_access_blocked = !GpuAccessAllowed(); 270 bool gpu_access_blocked = !GpuAccessAllowed();
266 271
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 #endif 553 #endif
549 554
550 return info; 555 return info;
551 } 556 }
552 557
553 void GpuDataManager::NotifyGpuInfoUpdate() { 558 void GpuDataManager::NotifyGpuInfoUpdate() {
554 observer_list_->Notify(&GpuDataManager::Observer::OnGpuInfoUpdate); 559 observer_list_->Notify(&GpuDataManager::Observer::OnGpuInfoUpdate);
555 } 560 }
556 561
557 void GpuDataManager::UpdateGpuFeatureFlags() { 562 void GpuDataManager::UpdateGpuFeatureFlags() {
558 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
559 BrowserThread::PostTask(
560 BrowserThread::UI, FROM_HERE,
561 base::Bind(&GpuDataManager::UpdateGpuFeatureFlags,
562 base::Unretained(this)));
563 return;
564 }
565 564
566 GpuBlacklist* gpu_blacklist = GetGpuBlacklist(); 565 GpuBlacklist* gpu_blacklist = GetGpuBlacklist();
567 // We don't set a lock around modifying gpu_feature_flags_ since it's just an 566 // We don't set a lock around modifying gpu_feature_flags_ since it's just an
568 // int. 567 // int.
569 if (!gpu_blacklist) { 568 if (!gpu_blacklist) {
570 gpu_feature_flags_.set_flags(0); 569 gpu_feature_flags_.set_flags(0);
571 return; 570 return;
572 } 571 }
573 572
574 { 573 {
575 base::AutoLock auto_lock(gpu_info_lock_); 574 base::AutoLock auto_lock(gpu_info_lock_);
576 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( 575 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags(
577 GpuBlacklist::kOsAny, NULL, gpu_info_); 576 GpuBlacklist::kOsAny, NULL, gpu_info_);
578 } 577 }
579 578
580 // Notify clients that GpuInfo state has changed
581 NotifyGpuInfoUpdate();
582
583 uint32 flags = gpu_feature_flags_.flags(); 579 uint32 flags = gpu_feature_flags_.flags();
584 uint32 max_entry_id = gpu_blacklist->max_entry_id(); 580 uint32 max_entry_id = gpu_blacklist->max_entry_id();
585 bool disabled = false; 581 bool disabled = false;
586 if (flags == 0) { 582 if (flags == 0) {
587 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 583 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
588 0, max_entry_id + 1); 584 0, max_entry_id + 1);
589 } else { 585 } else {
590 std::vector<uint32> flag_entries; 586 std::vector<uint32> flag_entries;
591 gpu_blacklist->GetGpuFeatureFlagEntries( 587 gpu_blacklist->GetGpuFeatureFlagEntries(
592 GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled); 588 GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 bool GpuDataManager::supportsAccelerated2dCanvas() const { 751 bool GpuDataManager::supportsAccelerated2dCanvas() const {
756 if (gpu_info_.can_lose_context) 752 if (gpu_info_.can_lose_context)
757 return false; 753 return false;
758 #if defined(USE_SKIA) 754 #if defined(USE_SKIA)
759 return true; 755 return true;
760 #else 756 #else
761 return false; 757 return false;
762 #endif 758 #endif
763 } 759 }
764 760
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698