/*
 * setValue calls onValueChange which will determine how
 * the value is handled. If the value VALUE_MODIFY_IGNORE
 * is returned, the value is silently discarded without
 * changing the value of the JavaScript object. This is
 * useful in the case where the value has already been changed
 * by calling forceSetValue in the overridden onValueChange.
 */
VALUE_MODIFY TiObject::setValue(Handle<Value> value)
{
	clearValue();
    VALUE_MODIFY modify = onValueChange(value_, value);
    if (modify != VALUE_MODIFY_ALLOW)
    {
        if (modify == VALUE_MODIFY_IGNORE)
        {
            modify = VALUE_MODIFY_ALLOW;
        }
        return modify;
    }
    TiObject* parent = getParentObject();
    if (parent != NULL)
    {
        modify = parent->onChildValueChange(this, value_, value);
        parent->release();
        if (modify != VALUE_MODIFY_ALLOW)
        {
            if (modify == VALUE_MODIFY_IGNORE)
            {
                modify = VALUE_MODIFY_ALLOW;
            }
            return modify;
        }
    }
    value_ = Persistent<Value>::New(value);
    return modify;
}
示例#2
0
void MaterialParameter::setValue(int value)
{
    clearValue();

    _value.intValue = value;
    _type = MaterialParameter::INT;
}
示例#3
0
void MaterialParameter::setValue(float value)
{
    clearValue();

    _value.floatValue = value;
    _type = MaterialParameter::FLOAT;
}
示例#4
0
void MaterialParameter::setValue(const int* values, unsigned int count)
{
    clearValue();

    _value.intPtrValue = const_cast<int*> (values);
    _count = count;
    _type = MaterialParameter::INT_ARRAY;
}
示例#5
0
void MaterialParameter::setValue(const float* values, unsigned int count)
{
    clearValue();

    _value.floatPtrValue = const_cast<float*> (values);
    _count = count;
    _type = MaterialParameter::FLOAT_ARRAY;
}
示例#6
0
void MaterialParameter::setValue(const Matrix* values, unsigned int count)
{
    clearValue();

    _value.floatPtrValue = const_cast<Matrix&> (values[0]).m;
    _count = count;
    _type = MaterialParameter::MATRIX;
}
示例#7
0
void MaterialParameter::setValue(const Vector4* values, unsigned int count)
{
    clearValue();

    _value.floatPtrValue = const_cast<float*> (&values[0].x);
    _count = count;
    _type = MaterialParameter::VECTOR4;
}
示例#8
0
bool QgsSpinBox::shouldShowClearForValue( const int value ) const
{
  if ( !mShowClearButton || !isEnabled() )
  {
    return false;
  }
  return value != clearValue();
}
TiObject::~TiObject()
{
	clearValue();
    if (nativeObject_ != NULL)
    {
        nativeObject_->release();
        nativeObject_ = NULL;
    }
}
示例#10
0
void MaterialParameter::setValue(const Texture::Sampler* sampler)
{
    GP_ASSERT(sampler);
    clearValue();

    const_cast<Texture::Sampler*>(sampler)->addRef();
    _value.samplerValue = sampler;
    _type = MaterialParameter::SAMPLER;
}
示例#11
0
void MaterialParameter::setValue(const C3DTexture* texture)
{
    clearValue();

    if (texture)
    {
        _value.textureValue = texture;
        _type = MaterialParameter::TEXTURE;
    }
}
示例#12
0
NS_CC_BEGIN

MaterialParameter::MaterialParameter(const char* name)
:_type(MaterialParameter::NONE)
,_count(1)
,_dynamic(false)
,_name(name)
,_uniform(nullptr)
{
    clearValue();
}
示例#13
0
void MaterialParameter::setValue(const C3DSampler* sampler)
{
    clearValue();

    if (sampler)
    {
        const_cast<C3DSampler*>(sampler)->retain();
        _value.samplerValue = sampler;
        _type = MaterialParameter::SAMPLER;
    }
}
示例#14
0
void QgsFilterLineEdit::mousePressEvent( QMouseEvent* e )
{
  if ( !mFocusInEvent )
    QLineEdit::mousePressEvent( e );
  else
    mFocusInEvent = false;

  if ( shouldShowClear() && clearRect().contains( e->pos() ) )
  {
    clearValue();
  }
}
示例#15
0
void MaterialParameter::setValue(const Vector4& value)
{
    clearValue();

    // Copy data by-value into a dynamic array.
    float* array = new float[4];
    memcpy(array, &value.x, sizeof(float) * 4);

    _value.floatPtrValue = array;
    _dynamic = true;
    _count = 1;
    _type = MaterialParameter::VECTOR4;
}
示例#16
0
Texture::Sampler* MaterialParameter::setValue(const char* texturePath, bool generateMipmaps)
{
    GP_ASSERT(texturePath);
    clearValue();

    Texture::Sampler* sampler = Texture::Sampler::create(texturePath, generateMipmaps);
    if (sampler)
    {
        _value.samplerValue = sampler;
        _type = MaterialParameter::SAMPLER;
    }
    return sampler;
}
示例#17
0
void MaterialParameter::setValue(const Texture::Sampler** samplers, unsigned int count)
{
    GP_ASSERT(samplers);
    clearValue();

    for (unsigned int i = 0; i < count; ++i)
    {
        const_cast<Texture::Sampler*>(samplers[i])->addRef();
    }
    _value.samplerArrayValue = samplers;
    _count = count;
    _type = MaterialParameter::SAMPLER_ARRAY;
}
// reset the parser
JSONStreamingParser &JSONStreamingParser::reset(void)
{
	state = PARSER_IDLE;
	flags = 0;
	level = 0;
	levels = 0;
	
	// clear stored name and value
	clearName();
	clearValue();

	return *this;
}
示例#19
0
int QgsSpinBox::valueFromText( const QString &text ) const
{
  if ( !mExpressionsEnabled )
  {
    return QSpinBox::valueFromText( text );
  }

  QString trimmedText = stripped( text );
  if ( trimmedText.isEmpty() )
  {
    return mShowClearButton ? clearValue() : value();
  }

  return std::round( QgsExpression::evaluateToDouble( trimmedText, value() ) );
}
// execute callback and clear name/value
void JSONStreamingParser::doCallback(const char *val)
{
	if(callback)
	{
		const char *nam = name;
		if(!nam)
			nam = "";
		if(!val)
			val = value;
		if(!val)
			val = "";
		callback(0, level, nam, val, callbackObject);
	}
	clearName();
	clearValue();
}
示例#21
0
IRenderer::Impl::Impl(HWND hwnd, U32 windowWidth, U32 windowHeight, IRenderer* pRenderer)
	: m_viewport(static_cast<F32>(windowWidth), static_cast<F32>(windowHeight))
	, m_scissorRect(windowWidth, windowHeight)
	, m_psoManager(&m_device, &m_resCache, &m_rootSignature)
	, m_pRenderer(pRenderer)
{
	// TEMP: Select the second(integrated card) adapter due to some problem with nvidia I can't pinpoint.
	auto pAdapter = m_hwCaps.GetDisplayAdapter(1).Get();
	m_device.Init(pAdapter.Get());
	m_hwCaps.CheckMSAASupport(m_device.Get());

	m_commandQueue.Init(m_device.Get());
	m_swapChain.Init(m_device.Get(), m_commandQueue.Get(), hwnd);
	m_commandAllocator.Init(m_device.Get());

	CreateRootSignature();

	// Create Resources
	ResourceConfig descCB(ResourceType::BUFFER, sizeof(XMFLOAT4X4));
	m_viewProjConstBuffer.CreateCommited(m_device.Get(), descCB, &m_pViewProjDataBegin);

	// Create Descriptor Heaps
	m_cbDescHeap.Init(m_device.Get(), DescHeapType::CB_SR_UA, MAX_RENDER_ITEMS, true);
	m_dsvDescHeap.Init(m_device.Get(), DescHeapType::DEPTH_STENCIL, 1);

	// Create Depth Buffer
	ClearValue clearValue(DXGI_FORMAT_D32_FLOAT, 1.0f);
	ResourceConfig dbConfig(ResourceType::TEXTURE2D, 800, 600, DXGI_FORMAT_R32_TYPELESS, TextureLayout::UNKNOWN, ResourceFlag::ALLOW_DEPTH_STENCIL);
	m_depthBuffer.CreateCommited(m_device.Get(), dbConfig, nullptr, nullptr, 0, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_DEPTH_WRITE, &clearValue);

	DepthStencilView dsvDesc;
	m_device.Get()->CreateDepthStencilView(m_depthBuffer.Get(), &dsvDesc, m_dsvDescHeap.GetCPUHandle(0));

	// Create a command list 
	m_commandList.Init(m_device.Get(), m_commandAllocator.Get());
	m_commandList.Close();

	// Create synchronization objects
	m_fence.Init(m_device.Get(), 0);
	m_currentFence = 1;
	m_handleEvent = CreateEventEx(nullptr, FALSE, FALSE, EVENT_ALL_ACCESS);

	// Synchronize
	WaitForGPU();

	m_resCache.Init(m_device.Get());
}
示例#22
0
C3DSampler* MaterialParameter::setValue(const char* texturePath, bool generateMipmaps)
{
    if (texturePath)
    {
        clearValue();

        C3DSampler* sampler = C3DSampler::create(texturePath, generateMipmaps);
        if (sampler)
        {
            _value.samplerValue = sampler;
            _type = MaterialParameter::SAMPLER;
        }
        return sampler;
    }

    return nullptr;
}
示例#23
0
void MaterialParameter::setValue(const Matrix& value)
{
    // If this parameter is already storing a single dynamic matrix, no need to clear it.
    if (!(_dynamic && _count == 1 && _type == MaterialParameter::MATRIX && _value.floatPtrValue != NULL))
    {
        clearValue();

        // Allocate a new dynamic matrix.
        _value.floatPtrValue = new float[16];
    }

    memcpy(_value.floatPtrValue, value.m, sizeof(float) * 16);

    _dynamic = true;
    _count = 1;
    _type = MaterialParameter::MATRIX;
}
示例#24
0
//
// qname - name of Q
// data  - Data to send (array of unsigned chars)
// len   - Length of data
//
// Returns length 0f data sent or an error (<0)
//
int enQueue(int ser, char *qname, char *data, int len) {
  char cmdBuffer[255];
  Value v;
  int status;

  sprintf(cmdBuffer,"LPUSH %s %s", qname,data);
  redisCommand(ser,(char *)cmdBuffer);
  v=redisReply(ser);
  //
  // Check type for error
  //

  if(v.type == ERROR) {
    fprintf(stderr,"ERROR: enQueue ><\n");
  }
  clearValue(v);
  return(status);
}
示例#25
0
void MaterialParameter::setMatrixArray(const Matrix* values, unsigned int count, bool copy)
{
    GP_ASSERT(values);
    clearValue();

    if (copy)
    {
        _value.floatPtrValue = new float[16 * count];
        memcpy(_value.floatPtrValue, const_cast<Matrix&> (values[0]).m, sizeof(float) * 16 * count);
        _dynamic = true;
    }
    else
    {
        _value.floatPtrValue = const_cast<Matrix&> (values[0]).m;
    }

    _count = count;
    _type = MaterialParameter::MATRIX;
}
示例#26
0
void MaterialParameter::setVector4Array(const Vector4* values, unsigned int count, bool copy)
{
    GP_ASSERT(values);
    clearValue();

    if (copy)
    {
        _value.floatPtrValue = new float[4 * count];
        memcpy(_value.floatPtrValue, const_cast<float*> (&values[0].x), sizeof(float) * 4 * count);
        _dynamic = true;
    }
    else
    {
        _value.floatPtrValue = const_cast<float*> (&values[0].x);
    }

    _count = count;
    _type = MaterialParameter::VECTOR4;
}
示例#27
0
void MaterialParameter::setIntArray(const int* values, unsigned int count, bool copy)
{
    GP_ASSERT(values);
    clearValue();

    if (copy)
    {
        _value.intPtrValue = new int[count];
        memcpy(_value.intPtrValue, values, sizeof(int) * count);
        _dynamic = true;
    }
    else
    {
        _value.intPtrValue = const_cast<int*> (values);
    }

    _count = count;
    _type = MaterialParameter::INT_ARRAY;
}
示例#28
0
void MaterialParameter::setFloatArray(const float* values, unsigned int count, bool copy)
{
    GP_ASSERT(values);
    clearValue();

    if (copy)
    {
        _value.floatPtrValue = new float[count];
        memcpy(_value.floatPtrValue, values, sizeof(float) * count);
        _dynamic = true;
    }
    else
    {
        _value.floatPtrValue = const_cast<float*> (values);
    }

    _count = count;
    _type = MaterialParameter::FLOAT_ARRAY;
}
示例#29
0
//
// TODO Need to add a timeout.  Only wait for specified tome, then return a failure.
//
int redisPing(int ser) {
  char cmdBuffer[255];
  Value v;
  int status=0;

  bzero(cmdBuffer,255);
  strcpy(cmdBuffer,(char *)"PING");
  redisCommand(ser,(char *)cmdBuffer);
  v=redisReply(ser);

  if( v.type== STATUS) {
    if ( !strcmp(v.x.string,(char *)"PONG")) {
      status = 1;
    } else {
      status = 0;
    }
  }

  clearValue(v);
  return(status);
}
示例#30
0
void MaterialParameter::setSamplerArray(const Texture::Sampler** values, unsigned int count, bool copy)
{
    GP_ASSERT(values);
    clearValue();

    if (copy)
    {
        _value.samplerArrayValue = new const Texture::Sampler*[count];
        memcpy(_value.samplerArrayValue, values, sizeof(Texture::Sampler*) * count);
        _dynamic = true;
    }
    else
    {
        _value.samplerArrayValue = values;
    }

    for (unsigned int i = 0; i < count; ++i)
    {
        const_cast<Texture::Sampler*>(_value.samplerArrayValue[i])->addRef();
    }

    _count = count;
    _type = MaterialParameter::SAMPLER_ARRAY;
}