ui_surface_view.h 4.7 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GRAPHIC_LITE_UI_SURFACE_VIEW_H
#define GRAPHIC_LITE_UI_SURFACE_VIEW_H

/**
 * @addtogroup UI_Components
 * @{
 *
 * @brief Defines UI components such as buttons, texts, images, lists, and progress bars.
 *
 * @since 1.0
 * @version 1.0
 */

/**
 * @file ui_surface_view.h
 *
 * @brief Declares the surface view that interacts with the multimedia to achieve camera preview and video playback.
 *
 * @since 1.0
 * @version 1.0
 */

#include "components/ui_view.h"
邓志豪 已提交
39
#if ENABLE_WINDOW
M
mamingshuai 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
#include "surface.h"

#include <string>

namespace OHOS {
/**
 * @brief Represents a surface view that interacts with the multimedia to achieve camera preview and video playback.
 *
 * @since 1.0
 * @version 1.0
 */
class UISurfaceView : public UIView {
public:
    /**
     * @brief A constructor used to create a <b>UISurfaceView</b> instance.
     *
     * @since 1.0
     * @version 1.0
     */
    UISurfaceView();

    /**
     * @brief A destructor used to delete the <b>UISurfaceView</b> instance.
     *
     * @since 1.0
     * @version 1.0
     */
    ~UISurfaceView();

    /**
     * @brief Obtains the surface, which should be used together with the camera and video modules.
     *
     * @return Returns the surface.
     * @since 1.0
     * @version 1.0
     */
    Surface* GetSurface() const;

    /**
     * @brief Sets the position for this view.
     *
     * @param x Indicates the x-coordinate to set.
     * @param y Indicates the y-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    void SetPosition(int16_t x, int16_t y) override;

    /**
     * @brief Sets the position and size for this view.
     *
     * @param x Indicates the x-coordinate to set.
     * @param y Indicates the y-coordinate to set.
     * @param width Indicates the width to set.
     * @param height Indicates the height to set.
     * @since 1.0
     * @version 1.0
     */
    void SetPosition(int16_t x, int16_t y, int16_t width, int16_t height) override;

    /**
     * @brief Adjusts the size of this view.
     *
     * @param width Indicates the new width.
     * @param height Indicates the new height.
     * @since 1.0
     * @version 1.0
     */
    void Resize(int16_t width, int16_t height) override;

    /**
     * @brief Sets the x-coordinate for this view.
     *
     * @param x Indicates the x-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    void SetX(int16_t x) override;

    /**
     * @brief Sets the y-coordinate for this view.
     *
     * @param y Indicates the y-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    void SetY(int16_t y) override;

    /**
     * @brief Sets the width for this view.
     *
     * @param width Indicates the width to set.
     * @since 1.0
     * @version 1.0
     */
    void SetWidth(int16_t width) override;

    /**
     * @brief Sets the height for this view.
     *
     * @param height Indicates the height to set.
     * @since 1.0
     * @version 1.0
     */
    void SetHeight(int16_t height) override;

    /**
     * @brief Called before this view is drawn. This function is used to check whether the parent view of this view
     *        needs to be redrawn so that the drawing process is optimized.
     *
     * @param invalidatedArea Indicates the area to draw.
     * @return Returns <b>true</b> if the parent view needs to be redrawn; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool OnPreDraw(Rect& invalidatedArea) const override;

    /**
     * @brief Called when this view is drawn.
     *
     * @param invalidatedArea Indicates the area to draw.
     * @since 1.0
     * @version 1.0
     */
N
niulihua 已提交
164
    void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override;
M
mamingshuai 已提交
165 166

private:
N
niulihua 已提交
167
    void Draw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
M
mamingshuai 已提交
168 169 170 171 172 173 174 175 176

    Surface* surface_;
    const std::string REGION_POSITION_X = "region_position_x";
    const std::string REGION_POSITION_Y = "region_position_y";
    const std::string REGION_WIDTH = "region_width";
    const std::string REGION_HEIGHT = "region_height";
    const uint8_t DEFAULT_QUEUE_SIZE = 2;
};
} // namespace OHOS
邓志豪 已提交
177
#endif // ENABLE_WINDOW
M
mamingshuai 已提交
178
#endif // GRAPHIC_LITE_UI_SURFACE_VIEW_H