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

Unified Diff: ui/gl/angle_platform_impl.cc

Issue 2697463003: gpu: Update ANGLE Platform integration. (Closed)
Patch Set: Fix crash in Reset 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1363fb97b4e0d030c2e545f559b37861fa35583e 100644
--- a/ui/gl/angle_platform_impl.cc
+++ b/ui/gl/angle_platform_impl.cc
@@ -7,37 +7,42 @@
#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() {
-}
+namespace {
-ANGLEPlatformImpl::~ANGLEPlatformImpl() {
-}
+angle::ResetDisplayPlatformFunc g_angle_reset_platform = nullptr;
-double ANGLEPlatformImpl::currentTime() {
+double ANGLEPlatformImpl_currentTime(angle::PlatformMethods* platform) {
return base::Time::Now().ToDoubleT();
}
-double ANGLEPlatformImpl::monotonicallyIncreasingTime() {
+double ANGLEPlatformImpl_monotonicallyIncreasingTime(
+ angle::PlatformMethods* platform) {
return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
}
-const unsigned char* ANGLEPlatformImpl::getTraceCategoryEnabledFlag(
+const unsigned char* ANGLEPlatformImpl_getTraceCategoryEnabledFlag(
+ angle::PlatformMethods* platform,
const char* category_group) {
return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
}
-void ANGLEPlatformImpl::logError(const char* errorMessage) {
+void ANGLEPlatformImpl_logError(angle::PlatformMethods* platform,
+ const char* errorMessage) {
LOG(ERROR) << errorMessage;
}
-void ANGLEPlatformImpl::logWarning(const char* warningMessage) {
+void ANGLEPlatformImpl_logWarning(angle::PlatformMethods* platform,
+ const char* warningMessage) {
LOG(WARNING) << warningMessage;
}
-angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent(
+angle::TraceEventHandle ANGLEPlatformImpl_addTraceEvent(
+ angle::PlatformMethods* platform,
char phase,
const unsigned char* category_group_enabled,
const char* name,
@@ -56,26 +61,28 @@ 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(
+ angle::PlatformMethods* platform,
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(angle::PlatformMethods* platform,
+ 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 +92,10 @@ void ANGLEPlatformImpl::histogramCustomCounts(const char* name,
counter->Add(sample);
}
-void ANGLEPlatformImpl::histogramEnumeration(const char* name,
- int sample,
- int boundary_value) {
+void ANGLEPlatformImpl_histogramEnumeration(angle::PlatformMethods* platform,
+ 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 +105,63 @@ void ANGLEPlatformImpl::histogramEnumeration(const char* name,
counter->Add(sample);
}
-void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) {
+void ANGLEPlatformImpl_histogramSparse(angle::PlatformMethods* platform,
+ 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(angle::PlatformMethods* platform,
+ const char* name,
+ bool sample) {
+ ANGLEPlatformImpl_histogramEnumeration(platform, 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;
+
+ // Save the pointer to the destroy function here to avoid crash.
+ g_angle_reset_platform = reinterpret_cast<angle::ResetDisplayPlatformFunc>(
+ eglGetProcAddress("ANGLEResetDisplayPlatform"));
+
+ angle::PlatformMethods* platformMethods = nullptr;
+ if (!angle_get_platform(static_cast<angle::EGLDisplayType>(display),
+ angle::g_PlatformMethodNames,
+ angle::g_NumPlatformMethods, nullptr,
+ &platformMethods))
+ 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) {
+ if (!g_angle_reset_platform)
+ return;
+ g_angle_reset_platform(static_cast<angle::EGLDisplayType>(display));
}
} // namespace gl
« 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