blob: 4b9ceccc09c9f3aaee6746073c435e7adc146b0d [file] [log] [blame]
sergeyvaf102be2016-09-09 18:02:07 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18#include "../utils/RingBuffer.h"
19
20#include <utils/String8.h>
21
22namespace android {
23namespace uirenderer {
24
25class CacheTexture;
26struct CachedGlyphInfo;
27
28// Tracks glyph uploads and recent rendered/skipped glyphs, so it can give an idea
29// what a missing character is: skipped glyph, wrong coordinates in cache texture etc.
30class FontCacheHistoryTracker {
31public:
32 void glyphRendered(CachedGlyphInfo*, int penX, int penY);
33 void glyphUploaded(CacheTexture*, uint32_t x, uint32_t y, uint16_t glyphW, uint16_t glyphH);
34 void glyphsCleared(CacheTexture*);
35 void frameCompleted();
36
37 void dump(String8& log) const;
John Reck1bcacfd2017-11-03 10:12:19 -070038
sergeyvaf102be2016-09-09 18:02:07 -070039private:
40 struct CachedGlyph {
41 void* texture;
42 uint16_t generation;
43 uint16_t startX;
44 uint16_t startY;
45 uint16_t bitmapW;
46 uint16_t bitmapH;
47 };
48
49 struct RenderEntry {
50 CachedGlyph glyph;
51 int penX;
52 int penY;
53 };
54
55 static void dumpCachedGlyph(String8& log, const CachedGlyph& glyph);
56 static void dumpRenderEntry(String8& log, const RenderEntry& entry);
57 static void dumpUploadEntry(String8& log, const CachedGlyph& glyph);
58
59 RingBuffer<RenderEntry, 300> mRenderHistory;
60 RingBuffer<CachedGlyph, 120> mUploadHistory;
61 uint16_t generation = 0;
62};
63
John Reck1bcacfd2017-11-03 10:12:19 -070064}; // namespace uirenderer
65}; // namespace android