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

Side by Side Diff: components/metrics/gpu/gpu_metrics_provider.cc

Issue 523273003: Moves GPUMetricsProvider to //components/metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/metrics/gpu_metrics_provider.h" 5 #include "components/metrics/gpu/gpu_metrics_provider.h"
6 6
7 #include "components/metrics/proto/system_profile.pb.h" 7 #include "components/metrics/proto/system_profile.pb.h"
8 #include "content/public/browser/gpu_data_manager.h" 8 #include "content/public/browser/gpu_data_manager.h"
9 #include "gpu/config/gpu_info.h" 9 #include "gpu/config/gpu_info.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
11 11
12 namespace metrics {
13
12 #if defined(OS_WIN) 14 #if defined(OS_WIN)
13 15
14 #include <windows.h> 16 #include <windows.h>
15 17
16 namespace { 18 namespace {
17 19
18 struct ScreenDPIInformation { 20 struct ScreenDPIInformation {
19 double max_dpi_x; 21 double max_dpi_x;
20 double max_dpi_y; 22 double max_dpi_y;
21 }; 23 };
22 24
23 // Called once for each connected monitor. 25 // Called once for each connected monitor.
24 BOOL CALLBACK GetMonitorDPICallback(HMONITOR, HDC hdc, LPRECT, LPARAM dwData) { 26 BOOL CALLBACK GetMonitorDPICallback(HMONITOR, HDC hdc, LPRECT, LPARAM dwData) {
25 const double kMillimetersPerInch = 25.4; 27 const double kMillimetersPerInch = 25.4;
26 ScreenDPIInformation* screen_info = 28 ScreenDPIInformation* screen_info =
27 reinterpret_cast<ScreenDPIInformation*>(dwData); 29 reinterpret_cast<ScreenDPIInformation*>(dwData);
28 // Size of screen, in mm. 30 // Size of screen, in mm.
29 DWORD size_x = GetDeviceCaps(hdc, HORZSIZE); 31 DWORD size_x = GetDeviceCaps(hdc, HORZSIZE);
30 DWORD size_y = GetDeviceCaps(hdc, VERTSIZE); 32 DWORD size_y = GetDeviceCaps(hdc, VERTSIZE);
31 double dpi_x = (size_x > 0) ? 33 double dpi_x = (size_x > 0) ?
32 GetDeviceCaps(hdc, HORZRES) / (size_x / kMillimetersPerInch) : 0; 34 GetDeviceCaps(hdc, HORZRES) / (size_x / kMillimetersPerInch) : 0;
33 double dpi_y = (size_y > 0) ? 35 double dpi_y = (size_y > 0) ?
34 GetDeviceCaps(hdc, VERTRES) / (size_y / kMillimetersPerInch) : 0; 36 GetDeviceCaps(hdc, VERTRES) / (size_y / kMillimetersPerInch) : 0;
35 screen_info->max_dpi_x = std::max(dpi_x, screen_info->max_dpi_x); 37 screen_info->max_dpi_x = std::max(dpi_x, screen_info->max_dpi_x);
36 screen_info->max_dpi_y = std::max(dpi_y, screen_info->max_dpi_y); 38 screen_info->max_dpi_y = std::max(dpi_y, screen_info->max_dpi_y);
37 return TRUE; 39 return TRUE;
38 } 40 }
39 41
40 void WriteScreenDPIInformationProto( 42 void WriteScreenDPIInformationProto(SystemProfileProto::Hardware* hardware) {
41 metrics::SystemProfileProto::Hardware* hardware) {
42 HDC desktop_dc = GetDC(NULL); 43 HDC desktop_dc = GetDC(NULL);
43 if (desktop_dc) { 44 if (desktop_dc) {
44 ScreenDPIInformation si = {0, 0}; 45 ScreenDPIInformation si = {0, 0};
45 if (EnumDisplayMonitors(desktop_dc, NULL, GetMonitorDPICallback, 46 if (EnumDisplayMonitors(desktop_dc, NULL, GetMonitorDPICallback,
46 reinterpret_cast<LPARAM>(&si))) { 47 reinterpret_cast<LPARAM>(&si))) {
47 hardware->set_max_dpi_x(si.max_dpi_x); 48 hardware->set_max_dpi_x(si.max_dpi_x);
48 hardware->set_max_dpi_y(si.max_dpi_y); 49 hardware->set_max_dpi_y(si.max_dpi_y);
49 } 50 }
50 ReleaseDC(GetDesktopWindow(), desktop_dc); 51 ReleaseDC(GetDesktopWindow(), desktop_dc);
51 } 52 }
52 } 53 }
53 54
54 } // namespace 55 } // namespace
55 56
56 #endif // defined(OS_WIN) 57 #endif // defined(OS_WIN)
57 58
58 GPUMetricsProvider::GPUMetricsProvider() { 59 GPUMetricsProvider::GPUMetricsProvider() {
59 } 60 }
60 61
61 GPUMetricsProvider::~GPUMetricsProvider() { 62 GPUMetricsProvider::~GPUMetricsProvider() {
62 } 63 }
63 64
64 void GPUMetricsProvider::ProvideSystemProfileMetrics( 65 void GPUMetricsProvider::ProvideSystemProfileMetrics(
65 metrics::SystemProfileProto* system_profile_proto) { 66 SystemProfileProto* system_profile_proto) {
66 metrics::SystemProfileProto::Hardware* hardware = 67 SystemProfileProto::Hardware* hardware =
67 system_profile_proto->mutable_hardware(); 68 system_profile_proto->mutable_hardware();
68 69
69 const gpu::GPUInfo& gpu_info = 70 const gpu::GPUInfo& gpu_info =
70 content::GpuDataManager::GetInstance()->GetGPUInfo(); 71 content::GpuDataManager::GetInstance()->GetGPUInfo();
71 metrics::SystemProfileProto::Hardware::Graphics* gpu = 72 SystemProfileProto::Hardware::Graphics* gpu =
72 hardware->mutable_gpu(); 73 hardware->mutable_gpu();
73 gpu->set_vendor_id(gpu_info.gpu.vendor_id); 74 gpu->set_vendor_id(gpu_info.gpu.vendor_id);
74 gpu->set_device_id(gpu_info.gpu.device_id); 75 gpu->set_device_id(gpu_info.gpu.device_id);
75 gpu->set_driver_version(gpu_info.driver_version); 76 gpu->set_driver_version(gpu_info.driver_version);
76 gpu->set_driver_date(gpu_info.driver_date); 77 gpu->set_driver_date(gpu_info.driver_date);
77 metrics::SystemProfileProto::Hardware::Graphics::PerformanceStatistics* 78 SystemProfileProto::Hardware::Graphics::PerformanceStatistics*
78 gpu_performance = gpu->mutable_performance_statistics(); 79 gpu_performance = gpu->mutable_performance_statistics();
79 gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics); 80 gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics);
80 gpu_performance->set_gaming_score(gpu_info.performance_stats.gaming); 81 gpu_performance->set_gaming_score(gpu_info.performance_stats.gaming);
81 gpu_performance->set_overall_score(gpu_info.performance_stats.overall); 82 gpu_performance->set_overall_score(gpu_info.performance_stats.overall);
82 gpu->set_gl_vendor(gpu_info.gl_vendor); 83 gpu->set_gl_vendor(gpu_info.gl_vendor);
83 gpu->set_gl_renderer(gpu_info.gl_renderer); 84 gpu->set_gl_renderer(gpu_info.gl_renderer);
84 85
85 const gfx::Size display_size = GetScreenSize(); 86 const gfx::Size display_size = GetScreenSize();
86 hardware->set_primary_screen_width(display_size.width()); 87 hardware->set_primary_screen_width(display_size.width());
87 hardware->set_primary_screen_height(display_size.height()); 88 hardware->set_primary_screen_height(display_size.height());
(...skipping 11 matching lines...) Expand all
99 100
100 float GPUMetricsProvider::GetScreenDeviceScaleFactor() const { 101 float GPUMetricsProvider::GetScreenDeviceScaleFactor() const {
101 return gfx::Screen::GetNativeScreen()-> 102 return gfx::Screen::GetNativeScreen()->
102 GetPrimaryDisplay().device_scale_factor(); 103 GetPrimaryDisplay().device_scale_factor();
103 } 104 }
104 105
105 int GPUMetricsProvider::GetScreenCount() const { 106 int GPUMetricsProvider::GetScreenCount() const {
106 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312 107 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312
107 return gfx::Screen::GetNativeScreen()->GetNumDisplays(); 108 return gfx::Screen::GetNativeScreen()->GetNumDisplays();
108 } 109 }
110
111 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/gpu/gpu_metrics_provider.h ('k') | components/metrics/gpu/gpu_metrics_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698