blob: cbdb756b8fa7a9c2dab6edca31ddedfea7214ef2 [file] [log] [blame]
sergeyv91d63542016-12-14 16:34:55 -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 "TestSceneBase.h"
sergeyv91d63542016-12-14 16:34:55 -080018#include "tests/common/BitmapAllocationTestUtils.h"
John Reck1bcacfd2017-11-03 10:12:19 -070019#include "utils/Color.h"
sergeyv91d63542016-12-14 16:34:55 -080020
21class HwBitmap565;
22
23static TestScene::Registrar _HwBitmap565(TestScene::Info{
John Reck1bcacfd2017-11-03 10:12:19 -070024 "hwBitmap565", "Draws composite shader with hardware bitmap",
25 TestScene::simpleCreateScene<HwBitmap565>});
sergeyv91d63542016-12-14 16:34:55 -080026
27class HwBitmap565 : public TestScene {
28public:
29 sp<RenderNode> card;
30 void createContent(int width, int height, Canvas& canvas) override {
31 canvas.drawColor(Color::Grey_200, SkBlendMode::kSrcOver);
32
John Reck1bcacfd2017-11-03 10:12:19 -070033 sk_sp<Bitmap> hardwareBitmap = BitmapAllocationTestUtils::allocateHardwareBitmap(
34 200, 200, kRGB_565_SkColorType, [](SkBitmap& skBitmap) {
35 skBitmap.eraseColor(Color::White);
36 SkCanvas skCanvas(skBitmap);
37 SkPaint skPaint;
38 skPaint.setColor(Color::Red_500);
39 skCanvas.drawRect(SkRect::MakeWH(100, 100), skPaint);
40 skPaint.setColor(Color::Blue_500);
41 skCanvas.drawRect(SkRect::MakeXYWH(100, 100, 100, 100), skPaint);
42 });
sergeyv91d63542016-12-14 16:34:55 -080043 canvas.drawBitmap(*hardwareBitmap, 10.0f, 10.0f, nullptr);
44 }
45
John Reck1bcacfd2017-11-03 10:12:19 -070046 void doFrame(int frameNr) override {}
sergeyv91d63542016-12-14 16:34:55 -080047};