1326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams/*
2a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk * Copyright (C) 2011 The Android Open Source Project
3326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
4326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Licensed under the Apache License, Version 2.0 (the "License");
5326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * you may not use this file except in compliance with the License.
6326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * You may obtain a copy of the License at
7326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
8326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *      http://www.apache.org/licenses/LICENSE-2.0
9326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
10326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Unless required by applicable law or agreed to in writing, software
11326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * distributed under the License is distributed on an "AS IS" BASIS,
12326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * See the License for the specific language governing permissions and
14326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * limitations under the License.
15326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams */
16326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
17326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#ifndef ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
18326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
19326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
207f126c78a107257090c6675ea40ffac41516a9dcAlex Sakhartchouk#include "rsProgramBase.h"
21fb6b614bcea88a587a7ea4530be45ff0ffa0210eAlex Sakhartchouk#include "rsStream.h"
22326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
23326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams// ---------------------------------------------------------------------------
24326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace android {
25326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace renderscript {
26326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
27ccc010bb7c0f89e162bf60033968a20be90a903aJason Samsclass ProgramStoreState;
28407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk/*****************************************************************************
29407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk * CAUTION
30407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk *
31407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk * Any layout changes for this class may require a corresponding change to be
32407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
33407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk * a partial copy of the information below.
34407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk *
35407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk *****************************************************************************/
367f126c78a107257090c6675ea40ffac41516a9dcAlex Sakhartchoukclass ProgramStore : public ProgramBase {
37326e0ddf89e8df2837752fbfd7a014814b32082cJason Samspublic:
388feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams    struct Hal {
398feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams        mutable void *drv;
408feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams
418feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams        struct State {
428feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool ditherEnable;
43326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
448feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            //bool blendEnable;
458feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool colorRWriteEnable;
468feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool colorGWriteEnable;
478feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool colorBWriteEnable;
488feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool colorAWriteEnable;
498feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            RsBlendSrcFunc blendSrc;
508feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            RsBlendDstFunc blendDst;
51326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
528feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            //bool depthTestEnable;
538feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            bool depthWriteEnable;
548feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams            RsDepthFunc depthFunc;
558feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams        };
568feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams        State state;
578feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams    };
588feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams    Hal mHal;
598feea4e0dec48ea03bd6d32706d058b86dddc5baJason Sams
60407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk    virtual void setup(const Context *, ProgramStoreState *);
61407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk
62e3150cfb3edb028407669e4a65e087eae77e718cJason Sams    virtual void serialize(Context *rsc, OStream *stream) const;
63407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk    virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
64407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk    static ProgramStore *createFromStream(Context *rsc, IStream *stream);
65407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk    static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
66407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk                                                       bool colorMaskR, bool colorMaskG,
67407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk                                                       bool colorMaskB, bool colorMaskA,
68407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk                                                       bool depthMask, bool ditherEnable,
69407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk                                                       RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
70407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk                                                       RsDepthFunc depthFunc);
71407f8ca5a1cd2269dba356f40ab32a5ff934a6a2Alex Sakhartchouk    void init();
728feea4e0dec48ea03bd6d32706d058b86dddc5baJason Samsprotected:
73c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk    virtual void preDestroy() const;
74c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk    virtual ~ProgramStore();
75c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk
76c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchoukprivate:
77c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk    ProgramStore(Context *,
78c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk                 bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
79c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk                 bool depthMask, bool ditherEnable,
80c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk                 RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
81c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk                 RsDepthFunc depthFunc);
82326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams};
83326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
84afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchoukclass ProgramStoreState {
85326e0ddf89e8df2837752fbfd7a014814b32082cJason Samspublic:
86ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ProgramStoreState();
87ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ~ProgramStoreState();
88771565f47fc44608444c00aa8fa3bda769ceaeceJason Sams    void init(Context *rsc);
89f2649a961db2995e9e24a6c98f8a419f1496c1b7Jason Sams    void deinit(Context *rsc);
90326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
91ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ObjectBaseRef<ProgramStore> mDefault;
92ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ObjectBaseRef<ProgramStore> mLast;
93c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk
94c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk    // Cache of all existing store programs.
95c700e649ca44d0dcff8b271e42d949ea72fe3c63Alex Sakhartchouk    Vector<ProgramStore *> mStorePrograms;
96326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams};
97326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
98326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams}
99326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams}
100326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#endif
101326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
102326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
103326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
104