Chromium Code Reviews| Index: ui/gl/angle_platform_impl.cc |
| diff --git a/ui/gl/angle_platform_impl.cc b/ui/gl/angle_platform_impl.cc |
| index 6a74fc29d04803fb81775eafc3dec02c2e0141db..bbf70bf81dabe5db3e50657c963f8c9119e72dff 100644 |
| --- a/ui/gl/angle_platform_impl.cc |
| +++ b/ui/gl/angle_platform_impl.cc |
| @@ -7,37 +7,35 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/trace_event/trace_event.h" |
| +#include "third_party/angle/include/platform/Platform.h" |
| +#include "ui/gl/gl_bindings.h" |
| namespace gl { |
| -ANGLEPlatformImpl::ANGLEPlatformImpl() { |
| -} |
| - |
| -ANGLEPlatformImpl::~ANGLEPlatformImpl() { |
| -} |
| +namespace { |
| -double ANGLEPlatformImpl::currentTime() { |
| +double ANGLEPlatformImpl_currentTime() { |
| return base::Time::Now().ToDoubleT(); |
| } |
| -double ANGLEPlatformImpl::monotonicallyIncreasingTime() { |
| +double ANGLEPlatformImpl_monotonicallyIncreasingTime() { |
| return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| } |
| -const unsigned char* ANGLEPlatformImpl::getTraceCategoryEnabledFlag( |
| +const unsigned char* ANGLEPlatformImpl_getTraceCategoryEnabledFlag( |
| const char* category_group) { |
| return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); |
| } |
| -void ANGLEPlatformImpl::logError(const char* errorMessage) { |
| +void ANGLEPlatformImpl_logError(const char* errorMessage) { |
| LOG(ERROR) << errorMessage; |
| } |
| -void ANGLEPlatformImpl::logWarning(const char* warningMessage) { |
| +void ANGLEPlatformImpl_logWarning(const char* warningMessage) { |
| LOG(WARNING) << warningMessage; |
| } |
| -angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent( |
| +angle::TraceEventHandle ANGLEPlatformImpl_addTraceEvent( |
| char phase, |
| const unsigned char* category_group_enabled, |
| const char* name, |
| @@ -56,26 +54,26 @@ angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent( |
| trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId, |
| base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names, |
| arg_types, arg_values, nullptr, flags); |
| - angle::Platform::TraceEventHandle result; |
| + angle::TraceEventHandle result; |
| memcpy(&result, &handle, sizeof(result)); |
| return result; |
| } |
| -void ANGLEPlatformImpl::updateTraceEventDuration( |
| +void ANGLEPlatformImpl_updateTraceEventDuration( |
| const unsigned char* category_group_enabled, |
| const char* name, |
| - TraceEventHandle handle) { |
| + angle::TraceEventHandle handle) { |
| base::trace_event::TraceEventHandle trace_event_handle; |
| memcpy(&trace_event_handle, &handle, sizeof(handle)); |
| TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name, |
| trace_event_handle); |
| } |
| -void ANGLEPlatformImpl::histogramCustomCounts(const char* name, |
| - int sample, |
| - int min, |
| - int max, |
| - int bucket_count) { |
| +void ANGLEPlatformImpl_histogramCustomCounts(const char* name, |
| + int sample, |
| + int min, |
| + int max, |
| + int bucket_count) { |
| // Copied from histogram macro, but without the static variable caching |
| // the histogram because name is dynamic. |
| base::HistogramBase* counter = base::Histogram::FactoryGet( |
| @@ -85,9 +83,9 @@ void ANGLEPlatformImpl::histogramCustomCounts(const char* name, |
| counter->Add(sample); |
| } |
| -void ANGLEPlatformImpl::histogramEnumeration(const char* name, |
| - int sample, |
| - int boundary_value) { |
| +void ANGLEPlatformImpl_histogramEnumeration(const char* name, |
| + int sample, |
| + int boundary_value) { |
| // Copied from histogram macro, but without the static variable caching |
| // the histogram because name is dynamic. |
| base::HistogramBase* counter = base::LinearHistogram::FactoryGet( |
| @@ -97,14 +95,57 @@ void ANGLEPlatformImpl::histogramEnumeration(const char* name, |
| counter->Add(sample); |
| } |
| -void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) { |
| +void ANGLEPlatformImpl_histogramSparse(const char* name, int sample) { |
| // For sparse histograms, we can use the macro, as it does not incorporate a |
| // static. |
| UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); |
| } |
| -void ANGLEPlatformImpl::histogramBoolean(const char* name, bool sample) { |
| - histogramEnumeration(name, sample ? 1 : 0, 2); |
| +void ANGLEPlatformImpl_histogramBoolean(const char* name, bool sample) { |
| + ANGLEPlatformImpl_histogramEnumeration(name, sample ? 1 : 0, 2); |
| +} |
| + |
| +} // anonymous namespace |
| + |
| +bool InitializeANGLEPlatform(EGLDisplay display) { |
| + angle::GetDisplayPlatformFunc angle_get_platform = |
| + reinterpret_cast<angle::GetDisplayPlatformFunc>( |
| + eglGetProcAddress("ANGLEGetDisplayPlatform")); |
| + if (!angle_get_platform) |
| + return false; |
| + |
| + angle::PlatformMethods* platformMethods = nullptr; |
| + if (!angle_get_platform(static_cast<angle::EGLDisplayType>(display), |
| + angle::g_PlatformMethodNames, |
| + 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
|
| + return false; |
| + platformMethods->currentTime = ANGLEPlatformImpl_currentTime; |
| + platformMethods->addTraceEvent = ANGLEPlatformImpl_addTraceEvent; |
| + platformMethods->currentTime = ANGLEPlatformImpl_currentTime; |
| + platformMethods->getTraceCategoryEnabledFlag = |
| + ANGLEPlatformImpl_getTraceCategoryEnabledFlag; |
| + platformMethods->histogramBoolean = ANGLEPlatformImpl_histogramBoolean; |
| + platformMethods->histogramCustomCounts = |
| + ANGLEPlatformImpl_histogramCustomCounts; |
| + platformMethods->histogramEnumeration = |
| + ANGLEPlatformImpl_histogramEnumeration; |
| + platformMethods->histogramSparse = ANGLEPlatformImpl_histogramSparse; |
| + platformMethods->logError = ANGLEPlatformImpl_logError; |
| + platformMethods->logWarning = ANGLEPlatformImpl_logWarning; |
| + platformMethods->monotonicallyIncreasingTime = |
| + ANGLEPlatformImpl_monotonicallyIncreasingTime; |
| + platformMethods->updateTraceEventDuration = |
| + ANGLEPlatformImpl_updateTraceEventDuration; |
| + return true; |
| +} |
| + |
| +void ResetANGLEPlatform(EGLDisplay display) { |
| + angle::ResetDisplayPlatformFunc angle_reset_platform = |
| + reinterpret_cast<angle::ResetDisplayPlatformFunc>( |
| + eglGetProcAddress("ANGLEResetDisplayPlatform")); |
| + if (!angle_reset_platform) |
| + return; |
| + angle_reset_platform(static_cast<angle::EGLDisplayType>(display)); |
| } |
| } // namespace gl |