1// Copyright 2013 The Flutter 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#pragma once
6
7#ifndef IMPELLER_ENABLE_VALIDATION
8#ifdef IMPELLER_DEBUG
9#define IMPELLER_ENABLE_VALIDATION 1
10#endif
11#endif
12
13#include <sstream>
14
15#include "flutter/fml/macros.h"
16
17namespace impeller {
18
19class ValidationLog {
20 public:
21 ValidationLog();
22
23 ~ValidationLog();
24
25 std::ostream& GetStream();
26
27 private:
28 std::ostringstream stream_;
29
30 FML_DISALLOW_COPY_ASSIGN_AND_MOVE(ValidationLog);
31};
32
33void ImpellerValidationBreak(const char* message);
34
35void ImpellerValidationErrorsSetFatal(bool fatal);
36
37struct ScopedValidationDisable {
38 ScopedValidationDisable();
39
40 ~ScopedValidationDisable();
41
42 FML_DISALLOW_COPY_AND_ASSIGN(ScopedValidationDisable);
43};
44
45} // namespace impeller
46
47//------------------------------------------------------------------------------
48/// Get a stream to the log Impeller uses for all validation errors. The
49/// behavior of these logs is as follows:
50///
51/// * Validation error are completely ignored in the Flutter release
52/// runtime-mode.
53/// * In non-release runtime-modes, validation logs are redirected to the
54/// Flutter `INFO` log. These logs typically show up when verbose logging is
55/// enabled.
56/// * If `ImpellerValidationErrorsSetFatal` is set to `true`, validation logs
57/// are fatal. The runtime-mode restriction still applies. This usually
58/// happens in test environments.
59///
60#define VALIDATION_LOG ::impeller::ValidationLog{}.GetStream()
61

source code of flutter_engine/flutter/impeller/base/validation.h