tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ShaderImpl.h (2179B)


      1 //
      2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // ShaderImpl.h: Defines the abstract rx::ShaderImpl class.
      8 
      9 #ifndef LIBANGLE_RENDERER_SHADERIMPL_H_
     10 #define LIBANGLE_RENDERER_SHADERIMPL_H_
     11 
     12 #include <functional>
     13 
     14 #include "common/angleutils.h"
     15 #include "libANGLE/Shader.h"
     16 #include "libANGLE/WorkerThread.h"
     17 
     18 namespace gl
     19 {
     20 class ShCompilerInstance;
     21 }  // namespace gl
     22 
     23 namespace rx
     24 {
     25 
     26 using UpdateShaderStateFunctor = std::function<void(bool compiled, ShHandle handle)>;
     27 class WaitableCompileEvent : public angle::WaitableEvent
     28 {
     29  public:
     30    WaitableCompileEvent(std::shared_ptr<angle::WaitableEvent> waitableEvent);
     31    ~WaitableCompileEvent() override;
     32 
     33    void wait() override;
     34 
     35    bool isReady() override;
     36 
     37    virtual bool getResult() = 0;
     38 
     39    virtual bool postTranslate(std::string *infoLog) = 0;
     40 
     41    const std::string &getInfoLog();
     42 
     43  protected:
     44    std::shared_ptr<angle::WaitableEvent> mWaitableEvent;
     45    std::string mInfoLog;
     46 };
     47 
     48 class ShaderImpl : angle::NonCopyable
     49 {
     50  public:
     51    ShaderImpl(const gl::ShaderState &state) : mState(state) {}
     52    virtual ~ShaderImpl() {}
     53 
     54    virtual void destroy() {}
     55 
     56    virtual std::shared_ptr<WaitableCompileEvent> compile(const gl::Context *context,
     57                                                          gl::ShCompilerInstance *compilerInstance,
     58                                                          ShCompileOptions *options) = 0;
     59 
     60    virtual std::string getDebugInfo() const = 0;
     61 
     62    const gl::ShaderState &getState() const { return mState; }
     63 
     64    virtual angle::Result onLabelUpdate(const gl::Context *context);
     65 
     66  protected:
     67    std::shared_ptr<WaitableCompileEvent> compileImpl(const gl::Context *context,
     68                                                      gl::ShCompilerInstance *compilerInstance,
     69                                                      const std::string &source,
     70                                                      ShCompileOptions *compileOptions);
     71 
     72    const gl::ShaderState &mState;
     73 };
     74 
     75 }  // namespace rx
     76 
     77 #endif  // LIBANGLE_RENDERER_SHADERIMPL_H_