1/*
2 * Copyright (C) 2012 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#ifndef __ANDROID_TYPE_H__
18#define __ANDROID_TYPE_H__
19
20#include <rs.h>
21#include "RenderScript.h"
22#include "Element.h"
23
24namespace android {
25namespace renderscriptCpp {
26
27class Type : public BaseObj {
28protected:
29    friend class Allocation;
30
31    uint32_t mDimX;
32    uint32_t mDimY;
33    uint32_t mDimZ;
34    bool mDimMipmaps;
35    bool mDimFaces;
36    size_t mElementCount;
37    sp<const Element> mElement;
38
39    void calcElementCount();
40    virtual void updateFromNative();
41
42public:
43
44    sp<const Element> getElement() const {
45        return mElement;
46    }
47
48    uint32_t getX() const {
49        return mDimX;
50    }
51
52    uint32_t getY() const {
53        return mDimY;
54    }
55
56    uint32_t getZ() const {
57        return mDimZ;
58    }
59
60    bool hasMipmaps() const {
61        return mDimMipmaps;
62    }
63
64    bool hasFaces() const {
65        return mDimFaces;
66    }
67
68    size_t getCount() const {
69        return mElementCount;
70    }
71
72    size_t getSizeBytes() const {
73        return mElementCount * mElement->getSizeBytes();
74    }
75
76
77    Type(void *id, RenderScript *rs);
78
79
80    class Builder {
81    protected:
82        RenderScript *mRS;
83        uint32_t mDimX;
84        uint32_t mDimY;
85        uint32_t mDimZ;
86        bool mDimMipmaps;
87        bool mDimFaces;
88        sp<const Element> mElement;
89
90    public:
91        Builder(RenderScript *rs, sp<const Element> e);
92
93        void setX(uint32_t value);
94        void setY(int value);
95        void setMipmaps(bool value);
96        void setFaces(bool value);
97        sp<const Type> create();
98    };
99
100};
101
102}
103}
104#endif
105