| John Reck | c3127a7 | 2016-01-29 15:54:10 -0800 | [diff] [blame] | 1 | /* |
| 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 Reck | c3127a7 | 2016-01-29 15:54:10 -0800 | [diff] [blame] | 24 | #include <SkPaint.h> |
| 25 | |
| 26 | using namespace android; |
| 27 | using namespace android::uirenderer; |
| 28 | |
| Chris Craik | c848249 | 2017-04-17 13:58:21 -0700 | [diff] [blame] | 29 | RENDERTHREAD_OPENGL_PIPELINE_TEST(TextDropShadowCache, DISABLED_addRemove) { |
| Chris Craik | e8c3c81 | 2016-02-05 20:10:50 -0800 | [diff] [blame] | 30 | SkPaint paint; |
| 31 | paint.setTextSize(20); |
| 32 | |
| John Reck | c3127a7 | 2016-01-29 15:54:10 -0800 | [diff] [blame] | 33 | GammaFontRenderer gammaFontRenderer; |
| 34 | FontRenderer& fontRenderer = gammaFontRenderer.getFontRenderer(); |
| Chris Craik | e8c3c81 | 2016-02-05 20:10:50 -0800 | [diff] [blame] | 35 | fontRenderer.setFont(&paint, SkMatrix::I()); |
| 36 | TextDropShadowCache cache(MB(5)); |
| John Reck | c3127a7 | 2016-01-29 15:54:10 -0800 | [diff] [blame] | 37 | cache.setFontRenderer(fontRenderer); |
| 38 | |
| Chris Craik | e8c3c81 | 2016-02-05 20:10:50 -0800 | [diff] [blame] | 39 | 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 Reck | c3127a7 | 2016-01-29 15:54:10 -0800 | [diff] [blame] | 49 | 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 | } |