sergeyv | 91d6354 | 2016-12-14 16:34:55 -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 "TestSceneBase.h" |
sergeyv | 91d6354 | 2016-12-14 16:34:55 -0800 | [diff] [blame] | 18 | #include "tests/common/BitmapAllocationTestUtils.h" |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 19 | #include "utils/Color.h" |
sergeyv | 91d6354 | 2016-12-14 16:34:55 -0800 | [diff] [blame] | 20 | |
| 21 | class HwBitmap565; |
| 22 | |
| 23 | static TestScene::Registrar _HwBitmap565(TestScene::Info{ |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 24 | "hwBitmap565", "Draws composite shader with hardware bitmap", |
| 25 | TestScene::simpleCreateScene<HwBitmap565>}); |
sergeyv | 91d6354 | 2016-12-14 16:34:55 -0800 | [diff] [blame] | 26 | |
| 27 | class HwBitmap565 : public TestScene { |
| 28 | public: |
| 29 | sp<RenderNode> card; |
| 30 | void createContent(int width, int height, Canvas& canvas) override { |
| 31 | canvas.drawColor(Color::Grey_200, SkBlendMode::kSrcOver); |
| 32 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 33 | 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 | }); |
sergeyv | 91d6354 | 2016-12-14 16:34:55 -0800 | [diff] [blame] | 43 | canvas.drawBitmap(*hardwareBitmap, 10.0f, 10.0f, nullptr); |
| 44 | } |
| 45 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 46 | void doFrame(int frameNr) override {} |
sergeyv | 91d6354 | 2016-12-14 16:34:55 -0800 | [diff] [blame] | 47 | }; |