Debian Codegraph @

src/core/SkDebugUtils.h

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkDebugUtils_DEFINED
9 #define SkDebugUtils_DEFINED
10
•11 #include "include/core/SkFourByteTag.h"
12 #include "include/core/SkTileMode.h"
13 #include "include/private/base/SkAssert.h"
14 #include "include/private/base/SkDebug.h"
15
16 #include <array>
17 #include <cstdint>
18
19 static constexpr const char* SkTileModeToStr(SkTileMode tm) {
20 switch (tm) {
21 case SkTileMode::kClamp: return "Clamp";
22 case SkTileMode::kRepeat: return "Repeat";
23 case SkTileMode::kMirror: return "Mirror";
24 case SkTileMode::kDecal: return "Decal";
25 }
26 SkUNREACHABLE;
27 }
28
29 #if defined(SK_DEBUG)
30 inline void SkDumpBuffer(uint8_t const* const buffer, int w, int h, int rowBytes,
31 bool dumpActualValues = false) {
32 SkASSERT(buffer);
33
34 static constexpr char shades[] = {'0', '1', '2', '3', '4', '5', '6', '7',
35 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
36
37 for (int y = 0; y < h; ++y) {
38 for (int x = 0; x < w; ++x) {
39 uint8_t pixelValue = buffer[y * rowBytes + x];
40 if (dumpActualValues) {
41 SkDebugf("%u\t", pixelValue);
42 } else {
43 int idx = static_cast<int>(pixelValue * std::size(shades) / 256);
44 SkASSERT(idx >= 0 && idx < (int)std::size(shades));
45 SkDebugf("%c", shades[idx]);
46 }
47 }
48 SkDebugf("\n");
49 }
50 }
51 #else
52 inline void SkDumpBuffer(uint8_t*, int, int, int) {}
53 #endif
54
•55 static inline void SkDumpTag(SkFourByteTag tag) {
56 SkDebugf("%c%c%c%c", (char)(tag >> 24), (char)(tag >> 16) & 0xFF, (char)(tag >> 8) & 0xFF, (char)tag & 0xFF);
57 }
58
59
60 #endif // SkDebugUtils_DEFINED