Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / gl / angle_platform_impl.cc
blob47f6cef6f5f1ee41b5376bfc5853d9fd38f3a7bb
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
3 // found in the LICENSE file.
5 #include "ui/gl/angle_platform_impl.h"
7 #include "base/metrics/histogram.h"
8 #include "base/metrics/sparse_histogram.h"
9 #include "base/trace_event/trace_event.h"
11 namespace gfx {
13 ANGLEPlatformImpl::ANGLEPlatformImpl() {
16 ANGLEPlatformImpl::~ANGLEPlatformImpl() {
19 double ANGLEPlatformImpl::monotonicallyIncreasingTime() {
20 return base::TimeTicks::Now().ToInternalValue() /
21 static_cast<double>(base::Time::kMicrosecondsPerSecond);
24 const unsigned char* ANGLEPlatformImpl::getTraceCategoryEnabledFlag(
25 const char* category_group) {
26 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
29 angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent(
30 char phase,
31 const unsigned char* category_group_enabled,
32 const char* name,
33 unsigned long long id,
34 double timestamp,
35 int num_args,
36 const char** arg_names,
37 const unsigned char* arg_types,
38 const unsigned long long* arg_values,
39 unsigned char flags) {
40 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue(
41 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond));
42 base::trace_event::TraceEventHandle handle =
43 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
44 phase, category_group_enabled, name, id,
45 base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names,
46 arg_types, arg_values, nullptr, flags);
47 angle::Platform::TraceEventHandle result;
48 memcpy(&result, &handle, sizeof(result));
49 return result;
52 void ANGLEPlatformImpl::updateTraceEventDuration(
53 const unsigned char* category_group_enabled,
54 const char* name,
55 TraceEventHandle handle) {
56 base::trace_event::TraceEventHandle trace_event_handle;
57 memcpy(&trace_event_handle, &handle, sizeof(handle));
58 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name,
59 trace_event_handle);
62 void ANGLEPlatformImpl::histogramCustomCounts(const char* name,
63 int sample,
64 int min,
65 int max,
66 int bucket_count) {
67 // Copied from histogram macro, but without the static variable caching
68 // the histogram because name is dynamic.
69 base::HistogramBase* counter = base::Histogram::FactoryGet(
70 name, min, max, bucket_count,
71 base::HistogramBase::kUmaTargetedHistogramFlag);
72 DCHECK_EQ(name, counter->histogram_name());
73 counter->Add(sample);
76 void ANGLEPlatformImpl::histogramEnumeration(const char* name,
77 int sample,
78 int boundary_value) {
79 // Copied from histogram macro, but without the static variable caching
80 // the histogram because name is dynamic.
81 base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
82 name, 1, boundary_value, boundary_value + 1,
83 base::HistogramBase::kUmaTargetedHistogramFlag);
84 DCHECK_EQ(name, counter->histogram_name());
85 counter->Add(sample);
88 void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) {
89 // For sparse histograms, we can use the macro, as it does not incorporate a
90 // static.
91 UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample);
94 } // namespace gfx