PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/core/Processor.h

http://github.com/imageworks/OpenColorIO
C++ Header | 132 lines | 57 code | 29 blank | 46 comment | 0 complexity | ff6cc3d7cafcb0f619ad1f8bb76d54a1 MD5 | raw file
  1/*
  2Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
  3All Rights Reserved.
  4
  5Redistribution and use in source and binary forms, with or without
  6modification, are permitted provided that the following conditions are
  7met:
  8* Redistributions of source code must retain the above copyright
  9  notice, this list of conditions and the following disclaimer.
 10* Redistributions in binary form must reproduce the above copyright
 11  notice, this list of conditions and the following disclaimer in the
 12  documentation and/or other materials provided with the distribution.
 13* Neither the name of Sony Pictures Imageworks nor the names of its
 14  contributors may be used to endorse or promote products derived from
 15  this software without specific prior written permission.
 16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 20OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27*/
 28
 29
 30#ifndef INCLUDED_OCIO_PROCESSOR_H
 31#define INCLUDED_OCIO_PROCESSOR_H
 32
 33#include <sstream>
 34
 35#include <OpenColorIO/OpenColorIO.h>
 36
 37#include "Mutex.h"
 38#include "Op.h"
 39#include "PrivateTypes.h"
 40
 41OCIO_NAMESPACE_ENTER
 42{
 43    class Processor::Impl
 44    {
 45    private:
 46        ProcessorMetadataRcPtr m_metadata;
 47        
 48        OpRcPtrVec m_cpuOps;
 49        
 50        // These 3 op vecs represent the 3 stages in our gpu pipe.
 51        // 1) preprocess shader text
 52        // 2) 3d lut process lookup
 53        // 3) postprocess shader text
 54        
 55        OpRcPtrVec m_gpuOpsHwPreProcess;
 56        OpRcPtrVec m_gpuOpsCpuLatticeProcess;
 57        OpRcPtrVec m_gpuOpsHwPostProcess;
 58        
 59        mutable std::string m_cpuCacheID;
 60        
 61        // Cache the last last queried value,
 62        // for the specified shader description
 63        mutable std::string m_lastShaderDesc;
 64        mutable std::string m_shader;
 65        mutable std::string m_shaderCacheID;
 66        mutable std::vector<float> m_lut3D;
 67        mutable std::string m_lut3DCacheID;
 68        
 69        mutable Mutex m_resultsCacheMutex;
 70        
 71    public:
 72        Impl();
 73        ~Impl();
 74        
 75        bool isNoOp() const;
 76        bool hasChannelCrosstalk() const;
 77        
 78        ConstProcessorMetadataRcPtr getMetadata() const;
 79        
 80        void apply(ImageDesc& img) const;
 81        
 82        void applyRGB(float * pixel) const;
 83        void applyRGBA(float * pixel) const;
 84        const char * getCpuCacheID() const;
 85        
 86        const char * getGpuShaderText(const GpuShaderDesc & gpuDesc) const;
 87        const char * getGpuShaderTextCacheID(const GpuShaderDesc & shaderDesc) const;
 88        
 89        void getGpuLut3D(float* lut3d, const GpuShaderDesc & shaderDesc) const;
 90        const char * getGpuLut3DCacheID(const GpuShaderDesc & shaderDesc) const;
 91        
 92        ////////////////////////////////////////////
 93        //
 94        // Builder functions, Not exposed
 95        
 96        void addColorSpaceConversion(const Config & config,
 97                                     const ConstContextRcPtr & context,
 98                                     const ConstColorSpaceRcPtr & srcColorSpace,
 99                                     const ConstColorSpaceRcPtr & dstColorSpace);
100        
101        void addTransform(const Config & config,
102                          const ConstContextRcPtr & context,
103                          const ConstTransformRcPtr& transform,
104                          TransformDirection direction);
105        
106        void finalize();
107        
108        void calcGpuShaderText(std::ostream & shader,
109                               const GpuShaderDesc & shaderDesc) const;
110    
111    };
112    
113    // TODO: Move these!
114    // TODO: Its not ideal that buildops requires a config to be passed around
115    // but the only alternative is to make build ops a function on it?
116    // and even if it were, what about the build calls it dispatches to...
117    
118    // TODO: all of the build op functions shouldnt take a LocalProcessor class
119    // Instead, they should take an abstract interface class that defines
120    // registerOp(OpRcPtr op), annotateColorSpace, finalizeOps, etc.
121    // of which LocalProcessor happens to be one example.
122    // Then the only location in the codebase that knows of LocalProcessor is
123    // in Config.cpp, which creates one.
124    
125    void BuildOps(OpRcPtrVec & ops,
126                  const Config & config,
127                  const ConstTransformRcPtr & transform,
128                  TransformDirection dir);
129}
130OCIO_NAMESPACE_EXIT
131
132#endif