tor-browser

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

Sampler.cpp (4193B)


      1 //
      2 // Copyright 2013 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 // Sampler.cpp : Implements the Sampler class, which represents a GLES 3
      8 // sampler object. Sampler objects store some state needed to sample textures.
      9 
     10 #include "libANGLE/Sampler.h"
     11 #include "libANGLE/angletypes.h"
     12 #include "libANGLE/renderer/GLImplFactory.h"
     13 #include "libANGLE/renderer/SamplerImpl.h"
     14 
     15 namespace gl
     16 {
     17 
     18 Sampler::Sampler(rx::GLImplFactory *factory, SamplerID id)
     19    : RefCountObject(factory->generateSerial(), id),
     20      mState(),
     21      mDirty(true),
     22      mSampler(factory->createSampler(mState)),
     23      mLabel()
     24 {}
     25 
     26 Sampler::~Sampler()
     27 {
     28    SafeDelete(mSampler);
     29 }
     30 
     31 void Sampler::onDestroy(const Context *context)
     32 {
     33    if (mSampler)
     34    {
     35        mSampler->onDestroy(context);
     36    }
     37 }
     38 
     39 angle::Result Sampler::setLabel(const Context *context, const std::string &label)
     40 {
     41    mLabel = label;
     42 
     43    if (mSampler)
     44    {
     45        return mSampler->onLabelUpdate(context);
     46    }
     47    return angle::Result::Continue;
     48 }
     49 
     50 const std::string &Sampler::getLabel() const
     51 {
     52    return mLabel;
     53 }
     54 
     55 void Sampler::setMinFilter(const Context *context, GLenum minFilter)
     56 {
     57    mState.setMinFilter(minFilter);
     58    signalDirtyState();
     59 }
     60 
     61 GLenum Sampler::getMinFilter() const
     62 {
     63    return mState.getMinFilter();
     64 }
     65 
     66 void Sampler::setMagFilter(const Context *context, GLenum magFilter)
     67 {
     68    mState.setMagFilter(magFilter);
     69    signalDirtyState();
     70 }
     71 
     72 GLenum Sampler::getMagFilter() const
     73 {
     74    return mState.getMagFilter();
     75 }
     76 
     77 void Sampler::setWrapS(const Context *context, GLenum wrapS)
     78 {
     79    mState.setWrapS(wrapS);
     80    signalDirtyState();
     81 }
     82 
     83 GLenum Sampler::getWrapS() const
     84 {
     85    return mState.getWrapS();
     86 }
     87 
     88 void Sampler::setWrapT(const Context *context, GLenum wrapT)
     89 {
     90    mState.setWrapT(wrapT);
     91    signalDirtyState();
     92 }
     93 
     94 GLenum Sampler::getWrapT() const
     95 {
     96    return mState.getWrapT();
     97 }
     98 
     99 void Sampler::setWrapR(const Context *context, GLenum wrapR)
    100 {
    101    mState.setWrapR(wrapR);
    102    signalDirtyState();
    103 }
    104 
    105 GLenum Sampler::getWrapR() const
    106 {
    107    return mState.getWrapR();
    108 }
    109 
    110 void Sampler::setMaxAnisotropy(const Context *context, float maxAnisotropy)
    111 {
    112    mState.setMaxAnisotropy(maxAnisotropy);
    113    signalDirtyState();
    114 }
    115 
    116 float Sampler::getMaxAnisotropy() const
    117 {
    118    return mState.getMaxAnisotropy();
    119 }
    120 
    121 void Sampler::setMinLod(const Context *context, GLfloat minLod)
    122 {
    123    mState.setMinLod(minLod);
    124    signalDirtyState();
    125 }
    126 
    127 GLfloat Sampler::getMinLod() const
    128 {
    129    return mState.getMinLod();
    130 }
    131 
    132 void Sampler::setMaxLod(const Context *context, GLfloat maxLod)
    133 {
    134    mState.setMaxLod(maxLod);
    135    signalDirtyState();
    136 }
    137 
    138 GLfloat Sampler::getMaxLod() const
    139 {
    140    return mState.getMaxLod();
    141 }
    142 
    143 void Sampler::setCompareMode(const Context *context, GLenum compareMode)
    144 {
    145    mState.setCompareMode(compareMode);
    146    signalDirtyState();
    147 }
    148 
    149 GLenum Sampler::getCompareMode() const
    150 {
    151    return mState.getCompareMode();
    152 }
    153 
    154 void Sampler::setCompareFunc(const Context *context, GLenum compareFunc)
    155 {
    156    mState.setCompareFunc(compareFunc);
    157    signalDirtyState();
    158 }
    159 
    160 GLenum Sampler::getCompareFunc() const
    161 {
    162    return mState.getCompareFunc();
    163 }
    164 
    165 void Sampler::setSRGBDecode(const Context *context, GLenum sRGBDecode)
    166 {
    167    mState.setSRGBDecode(sRGBDecode);
    168    signalDirtyState();
    169 }
    170 
    171 GLenum Sampler::getSRGBDecode() const
    172 {
    173    return mState.getSRGBDecode();
    174 }
    175 
    176 void Sampler::setBorderColor(const Context *context, const ColorGeneric &color)
    177 {
    178    mState.setBorderColor(color);
    179    signalDirtyState();
    180 }
    181 
    182 const ColorGeneric &Sampler::getBorderColor() const
    183 {
    184    return mState.getBorderColor();
    185 }
    186 
    187 const SamplerState &Sampler::getSamplerState() const
    188 {
    189    return mState;
    190 }
    191 
    192 rx::SamplerImpl *Sampler::getImplementation() const
    193 {
    194    return mSampler;
    195 }
    196 
    197 angle::Result Sampler::syncState(const Context *context)
    198 {
    199    ASSERT(isDirty());
    200    angle::Result result = mSampler->syncState(context, mDirty);
    201    mDirty               = result != angle::Result::Continue;
    202    return result;
    203 }
    204 
    205 void Sampler::signalDirtyState()
    206 {
    207    mDirty = true;
    208    onStateChange(angle::SubjectMessage::DirtyBitsFlagged);
    209 }
    210 
    211 }  // namespace gl