| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/gpu/gpu_performance_stats.h" | |
| 6 | |
| 7 #include <winsatcominterfacei.h> | |
| 8 | |
| 9 static float GetComponentScore(IProvideWinSATAssessmentInfo* subcomponent) { | |
| 10 float score; | |
| 11 HRESULT hr = subcomponent->get_Score(&score); | |
| 12 if (FAILED(hr)) | |
| 13 return 0.0; | |
| 14 return score; | |
| 15 } | |
| 16 | |
| 17 GpuPerformanceStats GpuPerformanceStats::RetrieveGpuPerformanceStats() { | |
| 18 HRESULT hr = S_OK; | |
| 19 IQueryRecentWinSATAssessment* assessment = NULL; | |
| 20 IProvideWinSATResultsInfo* results = NULL; | |
| 21 IProvideWinSATAssessmentInfo* subcomponent = NULL; | |
| 22 GpuPerformanceStats stats; | |
| 23 | |
| 24 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); | |
| 25 if (FAILED(hr)) | |
| 26 goto cleanup; | |
| 27 | |
| 28 hr = CoCreateInstance(__uuidof(CQueryWinSAT), | |
| 29 NULL, | |
| 30 CLSCTX_INPROC_SERVER, | |
| 31 __uuidof(IQueryRecentWinSATAssessment), | |
| 32 reinterpret_cast<void**>(&assessment)); | |
| 33 if (FAILED(hr)) | |
| 34 goto cleanup; | |
| 35 | |
| 36 hr = assessment->get_Info(&results); | |
| 37 if (FAILED(hr)) | |
| 38 goto cleanup; | |
| 39 | |
| 40 hr = results->get_SystemRating(&stats.overall); | |
| 41 if (FAILED(hr)) | |
| 42 goto cleanup; | |
| 43 | |
| 44 hr = results->GetAssessmentInfo(WINSAT_ASSESSMENT_D3D, &subcomponent); | |
| 45 if (FAILED(hr)) | |
| 46 goto cleanup; | |
| 47 stats.gaming = GetComponentScore(subcomponent); | |
| 48 subcomponent->Release(); | |
| 49 subcomponent = NULL; | |
| 50 | |
| 51 hr = results->GetAssessmentInfo(WINSAT_ASSESSMENT_GRAPHICS, &subcomponent); | |
| 52 if (FAILED(hr)) | |
| 53 goto cleanup; | |
| 54 stats.graphics = GetComponentScore(subcomponent); | |
| 55 subcomponent->Release(); | |
| 56 subcomponent = NULL; | |
| 57 | |
| 58 cleanup: | |
| 59 if (assessment) | |
| 60 assessment->Release(); | |
| 61 if (results) | |
| 62 results->Release(); | |
| 63 if (subcomponent) | |
| 64 subcomponent->Release(); | |
| 65 CoUninitialize(); | |
| 66 | |
| 67 return stats; | |
| 68 } | |
| OLD | NEW |