• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "tests/common/BitmapAllocationTestUtils.h"
19 #include "utils/Color.h"
20 
21 class HwBitmap565;
22 
23 static TestScene::Registrar _HwBitmap565(TestScene::Info{
24         "hwBitmap565", "Draws composite shader with hardware bitmap",
25         TestScene::simpleCreateScene<HwBitmap565>});
26 
27 class HwBitmap565 : public TestScene {
28 public:
29     sp<RenderNode> card;
createContent(int width,int height,Canvas & canvas)30     void createContent(int width, int height, Canvas& canvas) override {
31         canvas.drawColor(Color::Grey_200, SkBlendMode::kSrcOver);
32 
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                 });
43         canvas.drawBitmap(*hardwareBitmap, 10.0f, 10.0f, nullptr);
44     }
45 
doFrame(int frameNr)46     void doFrame(int frameNr) override {}
47 };