Skip to content

Commit 0ecfb4e

Browse files
committed
Add app.getGPUFeatureStatus
1 parent 717a1a6 commit 0ecfb4e

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

atom/browser/api/atom_api_app.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "chrome/browser/browser_process.h"
3535
#include "chrome/browser/icon_manager.h"
3636
#include "chrome/common/chrome_paths.h"
37+
#include "content/browser/gpu/compositor_util.h"
3738
#include "content/public/browser/browser_accessibility_state.h"
3839
#include "content/public/browser/browser_child_process_host.h"
3940
#include "content/public/browser/child_process_data.h"
@@ -1021,6 +1022,34 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
10211022
return result;
10221023
}
10231024

1025+
static mate::Dictionary ConvertDictionary(
1026+
v8::Isolate* isolate, const base::DictionaryValue &dict) {
1027+
auto result = mate::Dictionary::CreateEmpty(isolate);
1028+
1029+
for (base::DictionaryValue::Iterator iterator(dict);
1030+
!iterator.IsAtEnd();
1031+
iterator.Advance()) {
1032+
auto& key = iterator.key();
1033+
auto& value = iterator.value();
1034+
if (value.is_string()) {
1035+
std::string strValue;
1036+
if (value.GetAsString(&strValue)) {
1037+
result.Set(key, strValue);
1038+
}
1039+
}
1040+
}
1041+
1042+
return result;
1043+
}
1044+
1045+
mate::Dictionary App::GetGPUFeatureStatus(v8::Isolate* isolate) {
1046+
if (auto status = content::GetFeatureStatus()) {
1047+
return ConvertDictionary(isolate, *status);
1048+
} else {
1049+
return mate::Dictionary::CreateEmpty(isolate);
1050+
}
1051+
}
1052+
10241053
// static
10251054
mate::Handle<App> App::Create(v8::Isolate* isolate) {
10261055
return mate::CreateHandle(isolate, new App(isolate));
@@ -1094,6 +1123,7 @@ void App::BuildPrototype(
10941123
&App::DisableHardwareAcceleration)
10951124
.SetMethod("getFileIcon", &App::GetFileIcon)
10961125
.SetMethod("getAppMetrics", &App::GetAppMetrics)
1126+
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
10971127
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
10981128
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics);
10991129
}

atom/browser/api/atom_api_app.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class App : public AtomBrowserClient::Delegate,
177177
mate::Arguments* args);
178178

179179
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
180+
mate::Dictionary GetGPUFeatureStatus(v8::Isolate* isolate);
180181

181182
#if defined(OS_WIN)
182183
// Get the current Jump List settings.

docs/api/app.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMet
771771

772772
Returns [`ProcessMetric[]`](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and cpu usage statistics of all the processes associated with the app.
773773

774+
### `app.getGpuFeatureStatus()`
775+
776+
Returns [`GPUFeatureStatus`](structures/gpu-feature-status.md) - The Graphics Feature Status from `chrome://gpu/`.
777+
774778
### `app.setBadgeCount(count)` _Linux_ _macOS_
775779

776780
* `count` Integer
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# GPUFeatureStatus Object
2+
3+
* `2d_canvas` String - Canvas
4+
* `flash_3d` String - Flash
5+
* `flash_stage3d` String - Flash Stage3D
6+
* `flash_stage3d_baseline` String - Flash Stage3D Baseline profile
7+
* `gpu_compositing` String - Compositing
8+
* `multiple_raster_threads` String - Multiple Raster Threads
9+
* `native_gpu_memory_buffers` String - Native GpuMemoryBuffers
10+
* `rasterization` String - Rasterization
11+
* `video_decode` String - Video Decode
12+
* `video_encode` String - Video Encode
13+
* `vpx_decode` String - VPx Video Decode
14+
* `webgl` String - WebGL
15+
* `webgl2` String - WebGL2
16+
17+
Possible values:
18+
19+
* `disabled_software` - Software only. Hardware acceleration disabled (yellow)
20+
* `disabled_off` - Disabled (red)
21+
* `disabled_off_ok` - Disabled (yellow)
22+
* `unavailable_software` - Software only, hardware acceleration unavailable (yellow)
23+
* `unavailable_off` - Unavailable (red)
24+
* `unavailable_off_ok` - Unavailable (yellow)
25+
* `enabled_readback` - Hardware accelerated but at reduced performance (yellow)
26+
* `enabled_force` - Hardware accelerated on all pages (green)
27+
* `enabled` - Hardware accelerated (green)
28+
* `enabled_on` - Enabled (green)
29+
* `enabled_force_on` - Force enabled (green)

0 commit comments

Comments
 (0)