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

Side by Side Diff: ui/gl/angle_platform_impl.cc

Issue 2697463003: gpu: Update ANGLE Platform integration. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ui/gl/angle_platform_impl.h ('k') | ui/gl/gl_surface_egl.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/gl/angle_platform_impl.h" 5 #include "ui/gl/angle_platform_impl.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "third_party/angle/include/platform/Platform.h"
11 #include "ui/gl/gl_bindings.h"
10 12
11 namespace gl { 13 namespace gl {
12 14
13 ANGLEPlatformImpl::ANGLEPlatformImpl() { 15 namespace {
14 }
15 16
16 ANGLEPlatformImpl::~ANGLEPlatformImpl() { 17 double ANGLEPlatformImpl_currentTime() {
17 }
18
19 double ANGLEPlatformImpl::currentTime() {
20 return base::Time::Now().ToDoubleT(); 18 return base::Time::Now().ToDoubleT();
21 } 19 }
22 20
23 double ANGLEPlatformImpl::monotonicallyIncreasingTime() { 21 double ANGLEPlatformImpl_monotonicallyIncreasingTime() {
24 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 22 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
25 } 23 }
26 24
27 const unsigned char* ANGLEPlatformImpl::getTraceCategoryEnabledFlag( 25 const unsigned char* ANGLEPlatformImpl_getTraceCategoryEnabledFlag(
28 const char* category_group) { 26 const char* category_group) {
29 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); 27 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
30 } 28 }
31 29
32 void ANGLEPlatformImpl::logError(const char* errorMessage) { 30 void ANGLEPlatformImpl_logError(const char* errorMessage) {
33 LOG(ERROR) << errorMessage; 31 LOG(ERROR) << errorMessage;
34 } 32 }
35 33
36 void ANGLEPlatformImpl::logWarning(const char* warningMessage) { 34 void ANGLEPlatformImpl_logWarning(const char* warningMessage) {
37 LOG(WARNING) << warningMessage; 35 LOG(WARNING) << warningMessage;
38 } 36 }
39 37
40 angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent( 38 angle::TraceEventHandle ANGLEPlatformImpl_addTraceEvent(
41 char phase, 39 char phase,
42 const unsigned char* category_group_enabled, 40 const unsigned char* category_group_enabled,
43 const char* name, 41 const char* name,
44 unsigned long long id, 42 unsigned long long id,
45 double timestamp, 43 double timestamp,
46 int num_args, 44 int num_args,
47 const char** arg_names, 45 const char** arg_names,
48 const unsigned char* arg_types, 46 const unsigned char* arg_types,
49 const unsigned long long* arg_values, 47 const unsigned long long* arg_values,
50 unsigned char flags) { 48 unsigned char flags) {
51 base::TimeTicks timestamp_tt = 49 base::TimeTicks timestamp_tt =
52 base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp); 50 base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp);
53 base::trace_event::TraceEventHandle handle = 51 base::trace_event::TraceEventHandle handle =
54 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 52 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
55 phase, category_group_enabled, name, 53 phase, category_group_enabled, name,
56 trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId, 54 trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId,
57 base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names, 55 base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names,
58 arg_types, arg_values, nullptr, flags); 56 arg_types, arg_values, nullptr, flags);
59 angle::Platform::TraceEventHandle result; 57 angle::TraceEventHandle result;
60 memcpy(&result, &handle, sizeof(result)); 58 memcpy(&result, &handle, sizeof(result));
61 return result; 59 return result;
62 } 60 }
63 61
64 void ANGLEPlatformImpl::updateTraceEventDuration( 62 void ANGLEPlatformImpl_updateTraceEventDuration(
65 const unsigned char* category_group_enabled, 63 const unsigned char* category_group_enabled,
66 const char* name, 64 const char* name,
67 TraceEventHandle handle) { 65 angle::TraceEventHandle handle) {
68 base::trace_event::TraceEventHandle trace_event_handle; 66 base::trace_event::TraceEventHandle trace_event_handle;
69 memcpy(&trace_event_handle, &handle, sizeof(handle)); 67 memcpy(&trace_event_handle, &handle, sizeof(handle));
70 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name, 68 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name,
71 trace_event_handle); 69 trace_event_handle);
72 } 70 }
73 71
74 void ANGLEPlatformImpl::histogramCustomCounts(const char* name, 72 void ANGLEPlatformImpl_histogramCustomCounts(const char* name,
75 int sample, 73 int sample,
76 int min, 74 int min,
77 int max, 75 int max,
78 int bucket_count) { 76 int bucket_count) {
79 // Copied from histogram macro, but without the static variable caching 77 // Copied from histogram macro, but without the static variable caching
80 // the histogram because name is dynamic. 78 // the histogram because name is dynamic.
81 base::HistogramBase* counter = base::Histogram::FactoryGet( 79 base::HistogramBase* counter = base::Histogram::FactoryGet(
82 name, min, max, bucket_count, 80 name, min, max, bucket_count,
83 base::HistogramBase::kUmaTargetedHistogramFlag); 81 base::HistogramBase::kUmaTargetedHistogramFlag);
84 DCHECK_EQ(name, counter->histogram_name()); 82 DCHECK_EQ(name, counter->histogram_name());
85 counter->Add(sample); 83 counter->Add(sample);
86 } 84 }
87 85
88 void ANGLEPlatformImpl::histogramEnumeration(const char* name, 86 void ANGLEPlatformImpl_histogramEnumeration(const char* name,
89 int sample, 87 int sample,
90 int boundary_value) { 88 int boundary_value) {
91 // Copied from histogram macro, but without the static variable caching 89 // Copied from histogram macro, but without the static variable caching
92 // the histogram because name is dynamic. 90 // the histogram because name is dynamic.
93 base::HistogramBase* counter = base::LinearHistogram::FactoryGet( 91 base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
94 name, 1, boundary_value, boundary_value + 1, 92 name, 1, boundary_value, boundary_value + 1,
95 base::HistogramBase::kUmaTargetedHistogramFlag); 93 base::HistogramBase::kUmaTargetedHistogramFlag);
96 DCHECK_EQ(name, counter->histogram_name()); 94 DCHECK_EQ(name, counter->histogram_name());
97 counter->Add(sample); 95 counter->Add(sample);
98 } 96 }
99 97
100 void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) { 98 void ANGLEPlatformImpl_histogramSparse(const char* name, int sample) {
101 // For sparse histograms, we can use the macro, as it does not incorporate a 99 // For sparse histograms, we can use the macro, as it does not incorporate a
102 // static. 100 // static.
103 UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); 101 UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample);
104 } 102 }
105 103
106 void ANGLEPlatformImpl::histogramBoolean(const char* name, bool sample) { 104 void ANGLEPlatformImpl_histogramBoolean(const char* name, bool sample) {
107 histogramEnumeration(name, sample ? 1 : 0, 2); 105 ANGLEPlatformImpl_histogramEnumeration(name, sample ? 1 : 0, 2);
106 }
107
108 } // anonymous namespace
109
110 bool InitializeANGLEPlatform(EGLDisplay display) {
111 angle::GetDisplayPlatformFunc angle_get_platform =
112 reinterpret_cast<angle::GetDisplayPlatformFunc>(
113 eglGetProcAddress("ANGLEGetDisplayPlatform"));
114 if (!angle_get_platform)
115 return false;
116
117 angle::PlatformMethods* platformMethods = nullptr;
118 if (!angle_get_platform(static_cast<angle::EGLDisplayType>(display),
119 angle::g_PlatformMethodNames,
120 angle::g_NumPlatformMethods, &platformMethods))
Ken Russell (switch to Gerrit) 2017/02/13 23:39:13 I assume this fails if the structure's changed siz
Ken Russell (switch to Gerrit) 2017/02/13 23:40:18 Ah, I see now that you linked to it in the first m
121 return false;
122 platformMethods->currentTime = ANGLEPlatformImpl_currentTime;
123 platformMethods->addTraceEvent = ANGLEPlatformImpl_addTraceEvent;
124 platformMethods->currentTime = ANGLEPlatformImpl_currentTime;
125 platformMethods->getTraceCategoryEnabledFlag =
126 ANGLEPlatformImpl_getTraceCategoryEnabledFlag;
127 platformMethods->histogramBoolean = ANGLEPlatformImpl_histogramBoolean;
128 platformMethods->histogramCustomCounts =
129 ANGLEPlatformImpl_histogramCustomCounts;
130 platformMethods->histogramEnumeration =
131 ANGLEPlatformImpl_histogramEnumeration;
132 platformMethods->histogramSparse = ANGLEPlatformImpl_histogramSparse;
133 platformMethods->logError = ANGLEPlatformImpl_logError;
134 platformMethods->logWarning = ANGLEPlatformImpl_logWarning;
135 platformMethods->monotonicallyIncreasingTime =
136 ANGLEPlatformImpl_monotonicallyIncreasingTime;
137 platformMethods->updateTraceEventDuration =
138 ANGLEPlatformImpl_updateTraceEventDuration;
139 return true;
140 }
141
142 void ResetANGLEPlatform(EGLDisplay display) {
143 angle::ResetDisplayPlatformFunc angle_reset_platform =
144 reinterpret_cast<angle::ResetDisplayPlatformFunc>(
145 eglGetProcAddress("ANGLEResetDisplayPlatform"));
146 if (!angle_reset_platform)
147 return;
148 angle_reset_platform(static_cast<angle::EGLDisplayType>(display));
108 } 149 }
109 150
110 } // namespace gl 151 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/angle_platform_impl.h ('k') | ui/gl/gl_surface_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698