blob: 5383e5756b93356731b263a5bfe735607e7d5111 [file] [log] [blame]
John Reckc3127a72016-01-29 15:54:10 -08001/*
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#include <gtest/gtest.h>
18
19#include "GammaFontRenderer.h"
20#include "TextDropShadowCache.h"
21#include "utils/Blur.h"
22#include "tests/common/TestUtils.h"
23
John Reckc3127a72016-01-29 15:54:10 -080024#include <SkPaint.h>
25
26using namespace android;
27using namespace android::uirenderer;
28
Chris Craikc8482492017-04-17 13:58:21 -070029RENDERTHREAD_OPENGL_PIPELINE_TEST(TextDropShadowCache, DISABLED_addRemove) {
Chris Craike8c3c812016-02-05 20:10:50 -080030 SkPaint paint;
31 paint.setTextSize(20);
32
John Reckc3127a72016-01-29 15:54:10 -080033 GammaFontRenderer gammaFontRenderer;
34 FontRenderer& fontRenderer = gammaFontRenderer.getFontRenderer();
Chris Craike8c3c812016-02-05 20:10:50 -080035 fontRenderer.setFont(&paint, SkMatrix::I());
36 TextDropShadowCache cache(MB(5));
John Reckc3127a72016-01-29 15:54:10 -080037 cache.setFontRenderer(fontRenderer);
38
Chris Craike8c3c812016-02-05 20:10:50 -080039 std::vector<glyph_t> glyphs;
40 std::vector<float> positions;
41 float totalAdvance;
42 uirenderer::Rect bounds;
43 TestUtils::layoutTextUnscaled(paint, "This is a test",
44 &glyphs, &positions, &totalAdvance, &bounds);
45 EXPECT_TRUE(bounds.contains(5, -10, 100, 0)) << "Expect input to be nontrivially sized";
46
47 ShadowTexture* texture = cache.get(&paint, glyphs.data(), glyphs.size(), 10, positions.data());
48
John Reckc3127a72016-01-29 15:54:10 -080049 ASSERT_TRUE(texture);
50 ASSERT_FALSE(texture->cleanup);
51 ASSERT_EQ((uint32_t) texture->objectSize(), cache.getSize());
52 ASSERT_TRUE(cache.getSize());
53 cache.clear();
54 ASSERT_EQ(cache.getSize(), 0u);
55}