Exemple #1
0
void
CachedExtent::Info() const
{
	const char* extentType = "allocated tree block";
	if (IsAllocated() == false && IsData() == false)
		extentType = "free tree block";
	else if (IsAllocated() == false && IsData() == true)
		extentType = "free data extent";
	else if (IsAllocated() == true && IsData() == true)
		extentType = "allocated data extent";

	TRACE("%s at %" B_PRIu64 " length %" B_PRIu64 " refCount %i\n",
		extentType, offset, length, refCount);
}
bool
MacIOSurfaceTextureClientOGL::Lock(OpenMode aMode)
{
  MOZ_ASSERT(!mIsLocked);
  mIsLocked = true;
  return IsValid() && IsAllocated();
}
inline void LHDretrieve_CCDtiming::getDataFromRawData(const void* params){
	LHDretrieve_data::getDataFromRawData();

	exposureTiming.resize(0);
	exposureTime.resize(0);
	
	if(!IsAllocated()) return;
	double threashold = 2500.0;

	double expStart_t=0;
	double expEnd_t=0;
	for(size_t i=0; i<size()-1; ++i){
		if((1.0*data[i] - threashold) * (1.0*data[i+1] - threashold) <= 0.0){
			// rising edge, exposure_start
			if((1.0*data[i] - threashold)<0.0)
				expStart_t = 0.5*get_t(i)+0.5*get_t(i+1);
			else{
				expEnd_t = 0.5*get_t(i)+0.5*get_t(i+1);
				exposureTiming.push_back(0.5*expStart_t+0.5*expEnd_t);
				exposureTime.push_back(expEnd_t-expStart_t);
			}
		}
	}

	avgExposureTime=0.0;
	for(size_t i=0; i<exposureTime.size(); ++i)
		avgExposureTime += exposureTime[i];
	avgExposureTime/=exposureTime.size();
}
void
StreamTextureClientOGL::InitWith(gfx::SurfaceStream* aStream)
{
  MOZ_ASSERT(!IsAllocated());
  mStream = aStream;
  mGL = mStream->GLContext();
}
Exemple #5
0
bool VertexBuffer::Clear()
{
	if (!IsAllocated())
		return false; // Error!
	ForceUnlock();
	if (m_pD3D11Buffer) {
		m_pD3D11Buffer->Release();
		m_pD3D11Buffer = nullptr;
	}
	m_bLockReadOnly = m_bUpdateVBO = false;
	if (m_pData) {
		delete [] m_pData;
		m_pData = nullptr;
	} else {
		// Error!
		return false;
	}

	// Update renderer statistics
	static_cast<PLRenderer::RendererBackend&>(GetRenderer()).GetWritableStatistics().nVertexBufferMem -= m_nSize;

	// Init
	m_nElements = 0;
	m_nSize     = 0;
	m_nUsage    = PLRenderer::Usage::Unknown;
	MemoryManager::Set(m_nOffset, -1, sizeof(int)*NumOfSemantics*MaxPipelineChannels);

	// Done
	return true;
}
void
MacIOSurfaceTextureClientOGL::InitWith(MacIOSurface* aSurface)
{
  MOZ_ASSERT(IsValid());
  MOZ_ASSERT(!IsAllocated());
  mSurface = aSurface;
}
Exemple #7
0
bool CGUITextureBase::AllocateOnDemand()
{
  if (m_visible)
  { // visible, so make sure we're allocated
    if (!IsAllocated() || (m_isAllocated == LARGE && !m_texture.size()))
      return AllocResources();
  }
  else
  { // hidden, so deallocate as applicable
    if (m_allocateDynamically && IsAllocated())
      FreeResources();
    // reset animated textures (animgifs)
    ResetAnimState();
  }

  return false;
}
bool
EGLImageTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  MOZ_ASSERT(IsAllocated());

  aOutDescriptor = EGLImageDescriptor((uintptr_t)mImage, mSize);
  return true;
}
	void Buffer::CopyFrom (const ConstBufferPtr &bufferPtr)
	{
		if (!IsAllocated ())
			Allocate (bufferPtr.Size());
		else if (bufferPtr.Size() > DataSize)
			throw ParameterTooLarge (SRC_POS);

		Memory::Copy (DataPtr, bufferPtr.Get(), bufferPtr.Size());
	}
bool
SurfaceTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  MOZ_ASSERT(IsAllocated());

  aOutDescriptor = SurfaceTextureDescriptor((uintptr_t)mSurfTex.get(),
                                            mSize);
  return true;
}
IMAGE_PTR AtrousGabor::AccessGaussianBuffer(int level)
{	
	if(!IsAllocated())
		throw "Resources not allocated";

	if( (level < 0) || (level >= m_i_scales))
		throw "Invalid Argument";

	return gausslevel[level];
}
bool
EGLImageTextureClient::Lock(OpenMode mode)
  {
    MOZ_ASSERT(!mIsLocked);
    if (!IsValid() || !IsAllocated()) {
      return false;
    }
    mIsLocked = true;
    return true;
  }
bool
EGLImageTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  MOZ_ASSERT(IsAllocated());

  const EGLImageImage::Data* data = mImage->GetData();
  aOutDescriptor = EGLImageDescriptor((uintptr_t)data->mImage, (uintptr_t)data->mSync, mSize);
  return true;
}
IMAGE_PTR AtrousGabor::AccessGaussianLevel(int level)
{	
	if(!IsAllocated())
		throw "Resources not allocated";

	if( (level < 0) || (level >= m_i_scales))
		throw "Invalid Argument";

	return gausslevel[level] + m_i_border*m_i_stridepix + m_i_border;
}
Exemple #15
0
static int freehostmem(lua_State *L, ud_t *ud)
    {
    hostmem_t* hostmem = (hostmem_t*)ud->handle;
    int allocated = IsAllocated(ud);
    if(!freeuserdata(L, ud, "hostmem")) return 0;
    if(allocated)
        AlignedFree(hostmem->ptr);
    Free(L, hostmem);
    return 0;
    }
Exemple #16
0
bool
SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  if (!IsAllocated()) {
    return false;
  }
  aOutDescriptor = SharedTextureDescriptor(mShareType, mHandle, mSize, mInverted);
  return true;
}
bool
StreamTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  if (!IsAllocated()) {
    return false;
  }

  gfx::SurfaceStreamHandle handle = mStream->GetShareHandle();
  aOutDescriptor = SurfaceStreamDescriptor(handle, false);
  return true;
}
Exemple #18
0
bool
MemoryTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
{
  MOZ_ASSERT(IsValid());
  if (!IsAllocated() || GetFormat() == gfx::FORMAT_UNKNOWN) {
    return false;
  }
  aDescriptor = SurfaceDescriptorMemory(reinterpret_cast<uintptr_t>(mBuffer),
                                        GetFormat());
  return true;
}
Exemple #19
0
bool
ShmemTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
{
  MOZ_ASSERT(IsValid());
  if (!IsAllocated() || GetFormat() == gfx::FORMAT_UNKNOWN) {
    return false;
  }

  aDescriptor = SurfaceDescriptorShmem(mShmem, GetFormat());

  return true;
}
bool
MacIOSurfaceTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  if (!IsAllocated()) {
    return false;
  }
  aOutDescriptor = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(),
                                                 mSurface->GetContentsScaleFactor(),
                                                 mSurface->HasAlpha());
  return true;
}
bool
SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  if (!IsAllocated()) {
    return false;
  }
  nsIntSize nsSize(mSize.width, mSize.height);
  aOutDescriptor = SharedTextureDescriptor(mIsCrossProcess ? gl::GLContext::CrossProcess
                                                           : gl::GLContext::SameProcess,
                                           mHandle, nsSize, mInverted);
  return true;
}
Exemple #22
0
gfx::DrawTarget*
DIBTextureClient::BorrowDrawTarget()
{
  MOZ_ASSERT(mIsLocked && IsAllocated());

  if (!mDrawTarget) {
    mDrawTarget =
      gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mSurface, mSize);
  }

  return mDrawTarget;
}
Exemple #23
0
bool
TextureClient::ShouldDeallocateInDestructor() const
{
  if (!IsAllocated()) {
    return false;
  }

  // If we're meant to be deallocated by the host,
  // but we haven't been shared yet, then we should
  // deallocate on the client instead.
  return !IsSharedWithCompositor();
}
void
SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
                                 gfx::IntSize aSize,
                                 bool aIsCrossProcess,
                                 bool aInverted)
{
  MOZ_ASSERT(!IsAllocated());
  mHandle = aHandle;
  mSize = aSize;
  mIsCrossProcess = aIsCrossProcess;
  mInverted = aInverted;
}
Exemple #25
0
bool
TextureClientD3D11::Lock(OpenMode aMode)
{
  if (!IsAllocated()) {
    return false;
  }
  MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");

  if (mTexture) {
    MOZ_ASSERT(!mTexture10);
    mIsLocked = LockD3DTexture(mTexture.get());
  } else {
    MOZ_ASSERT(!mTexture);
    mIsLocked = LockD3DTexture(mTexture10.get());
  }
  if (!mIsLocked) {
    return false;
  }

  if (NS_IsMainThread()) {
    // Make sure that successful write-lock means we will have a DrawTarget to
    // write into.
    if (aMode & OpenMode::OPEN_WRITE) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
    }

    if (mNeedsClear) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
      mNeedsClear = false;
    }
    if (mNeedsClearWhite) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->FillRect(Rect(0, 0, GetSize().width, GetSize().height), ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
      mNeedsClearWhite = false;
    }
  }

  return true;
}
Exemple #26
0
 void
 SparseMatrix::ToHostMatrix(float** mat, int* rows, int* cols) const
 {
     const float nan = std::numeric_limits<float>::quiet_NaN();
     *mat = new float[Rows() * Columns()];
     *rows = Rows();
     *cols = Columns();
     for (int i = 0; i < Rows(); i++) {
         for (int j = 0; j < Columns(); j++) {
             (*mat)[i * Columns() + j] = IsAllocated(i, j) ? Get(i, j) : nan;
         }
     }
 }
IMAGE_PTR AtrousGabor::AccessGaborImagLevel(int level)
{
	if((m_i_orientations == 0)||(m_i_wavelengths == 0) )
		throw "Object not configured for gabor computations";

	if(!IsAllocated())
		throw "Resources not allocated";

	if( (level < 0) || (level >= m_i_orientations*m_i_kernels))
		throw "Invalid Argument";

	return imaglevel[level]  + m_i_border*m_i_stridepix + m_i_border;
}
IMAGE_PTR AtrousGabor::AccessLaplacianBuffer(int level)
{
	if(!IsAllocated())
		throw "Resources not allocated";

	if(m_i_orientations == 0)
		throw "Object not configured for laplacian computations";

	if( (level < 0) || (level >= m_i_scales))
		throw "Invalid Argument";

	return laplevel[level];
}
IMAGE_PTR AtrousGabor::AccessGaborEnergyBuffer(int level)
{
	if((m_i_orientations == 0)||(m_i_wavelengths == 0) )
		throw "Object not configured for gabor computations";

	if(!IsAllocated())
		throw "Resources not allocated";

	if( (level < 0) || (level >= m_i_orientations*m_i_kernels))
		throw "Invalid Argument";

	return gaborlevel[level];
}
Exemple #30
0
bool
DIBTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
  MOZ_ASSERT(IsValid());
  if (!IsAllocated()) {
    return false;
  }
  MOZ_ASSERT(mSurface);
  // The host will release this ref when it receives the surface descriptor.
  // We AddRef in case we die before the host receives the pointer.
  aOutDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
  mSurface->AddRef();
  return true;
}