blob: 39522b3c0ddae125d7c8e4941a170a67f55236b5 [file] [log] [blame]
Greg Daniel8cd3edf2017-01-09 14:15:41 -05001/*
2 * Copyright (C) 2017 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#pragma once
18
19#include "Layer.h"
20
Greg Daniel45ec62b2017-01-04 14:27:00 -050021#include <SkImage.h>
Greg Daniel8cd3edf2017-01-09 14:15:41 -050022
23namespace android {
24namespace uirenderer {
25/**
26 * A layer has dimensions and is backed by a VkImage.
27 */
28class VkLayer : public Layer {
29public:
30 VkLayer(RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight)
31 : Layer(renderState, Api::Vulkan) {}
32
33 virtual ~VkLayer() {}
34
35 uint32_t getWidth() const override {
36 return mWidth;
37 }
38
39 uint32_t getHeight() const override {
40 return mHeight;
41 }
42
43 void setSize(uint32_t width, uint32_t height) override {
44 mWidth = width;
45 mHeight = height;
46 }
47
48 void setBlend(bool blend) override {
49 mBlend = blend;
50 }
51
52 bool isBlend() const override {
53 return mBlend;
54 }
55
Greg Daniel45ec62b2017-01-04 14:27:00 -050056 sk_sp<SkImage> getImage() {
57 return mImage;
Greg Daniel8cd3edf2017-01-09 14:15:41 -050058 }
59
Greg Daniel45ec62b2017-01-04 14:27:00 -050060 void updateTexture();
61
62 // If we've destroyed the vulkan context (VkInstance, VkDevice, etc.), we must make sure to
63 // destroy any VkImages that were made with that context.
64 void onVkContextDestroyed();
65
Greg Daniel8cd3edf2017-01-09 14:15:41 -050066private:
67 int mWidth;
68 int mHeight;
69 bool mBlend;
70
Greg Daniel45ec62b2017-01-04 14:27:00 -050071 sk_sp<SkImage> mImage;
Greg Daniel8cd3edf2017-01-09 14:15:41 -050072
73}; // struct VkLayer
74
75}; // namespace uirenderer
76}; // namespace android