1 // Copyright 2018 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.
4 
5 #ifndef COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_REASON_H_
6 #define COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_REASON_H_
7 
8 #include "components/viz/common/viz_common_export.h"
9 #include "gpu/command_buffer/common/constants.h"
10 
11 namespace viz {
12 
13 enum ContextLostReason {
14   // These values are persisted to logs. Entries should not be renumbered and
15   // numeric values should never be reused.
16   CONTEXT_INIT_FAILED = 0,
17   CONTEXT_LOST_GPU_CHANNEL_ERROR = 1,
18   CONTEXT_PARSE_ERROR_INVALID_SIZE = 2,
19   CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS = 3,
20   CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND = 4,
21   CONTEXT_PARSE_ERROR_INVALID_ARGS = 5,
22   CONTEXT_PARSE_ERROR_GENERIC_ERROR = 6,
23   CONTEXT_LOST_GUILTY = 7,
24   CONTEXT_LOST_INNOCENT = 8,
25   CONTEXT_LOST_UNKNOWN = 9,
26   CONTEXT_LOST_OUT_OF_MEMORY = 10,
27   CONTEXT_LOST_MAKECURRENT_FAILED = 11,
28   CONTEXT_LOST_INVALID_GPU_MESSAGE = 12,
29   // SkiaRenderer marked context as lost because of failed Reshape call
30   CONTEXT_LOST_RESHAPE_FAILED = 13,
31   CONTEXT_LOST_SET_DRAW_RECTANGLE_FAILED = 14,
32   CONTEXT_LOST_DIRECT_COMPOSITION_OVERLAY_FAILED = 15,
33   CONTEXT_LOST_SWAP_FAILED = 16,
34   // Update kMaxValue here and <enum name="ContextLostReason"> in
35   // tools/metrics/histograms/enum.xml when adding new values.
36   kMaxValue = CONTEXT_LOST_SWAP_FAILED
37 };
38 
39 VIZ_COMMON_EXPORT ContextLostReason
40 GetContextLostReason(gpu::error::Error error,
41                      gpu::error::ContextLostReason reason);
42 
43 }  // namespace viz
44 
45 #endif  // COMPONENTS_VIZ_COMMON_GPU_CONTEXT_LOST_REASON_H_
46