blob: 586625bf97cfe6515b9fed771609a9a766a1bb9d [file] [log] [blame]
Chris Craik07d8d592016-02-03 18:43:04 -08001/*
2 * Copyright (C) 2015 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 "tests/common/TestUtils.h"
18
19#include <gtest/gtest.h>
20#include <SkShader.h>
21
22using namespace android;
23using namespace android::uirenderer;
24
25/**
26 * 1x1 bitmaps must not be optimized into solid color shaders, since HWUI can't
27 * compose/render color shaders
28 */
29TEST(SkiaBehavior, CreateBitmapShader1x1) {
30 SkBitmap origBitmap = TestUtils::createSkBitmap(1, 1);
31 std::unique_ptr<SkShader> s(SkShader::CreateBitmapShader(
32 origBitmap,
33 SkShader::kClamp_TileMode,
34 SkShader::kRepeat_TileMode));
35
36 SkBitmap bitmap;
37 SkShader::TileMode xy[2];
38 ASSERT_TRUE(s->isABitmap(&bitmap, nullptr, xy))
39 << "1x1 bitmap shader must query as bitmap shader";
40 EXPECT_EQ(SkShader::kClamp_TileMode, xy[0]);
41 EXPECT_EQ(SkShader::kRepeat_TileMode, xy[1]);
42 EXPECT_EQ(origBitmap.pixelRef(), bitmap.pixelRef());
43}