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 "TestSceneBase.h"
18#include "utils/Color.h"
19#include "tests/common/BitmapAllocationTestUtils.h"
20
21class HwBitmap565;
22
23static TestScene::Registrar _HwBitmap565(TestScene::Info{
24    "hwBitmap565",
25    "Draws composite shader with hardware bitmap",
26    TestScene::simpleCreateScene<HwBitmap565>
27});
28
29class HwBitmap565 : public TestScene {
30public:
31    sp<RenderNode> card;
32    void createContent(int width, int height, Canvas& canvas) override {
33        canvas.drawColor(Color::Grey_200, SkBlendMode::kSrcOver);
34
35        sk_sp<Bitmap> hardwareBitmap = BitmapAllocationTestUtils::allocateHardwareBitmap(200, 200,
36                kRGB_565_SkColorType, [](SkBitmap& skBitmap) {
37            skBitmap.eraseColor(Color::White);
38            SkCanvas skCanvas(skBitmap);
39            SkPaint skPaint;
40            skPaint.setColor(Color::Red_500);
41            skCanvas.drawRect(SkRect::MakeWH(100, 100), skPaint);
42            skPaint.setColor(Color::Blue_500);
43            skCanvas.drawRect(SkRect::MakeXYWH(100, 100, 100, 100), skPaint);
44        });
45        canvas.drawBitmap(*hardwareBitmap, 10.0f, 10.0f, nullptr);
46    }
47
48    void doFrame(int frameNr) override { }
49};