コード例 #1
0
already_AddRefed<gfxASurface>
ContentClientRemote::CreateBuffer(ContentType aType,
                                  const nsIntRect& aRect,
                                  uint32_t aFlags)
{
  NS_ABORT_IF_FALSE(!mIsNewBuffer,
                    "Bad! Did we create a buffer twice without painting?");

  mIsNewBuffer = true;

  if (mTextureClient) {
    mOldTextures.AppendElement(mTextureClient);
    DestroyBuffers();
  }
  mTextureClient = CreateTextureClient(TEXTURE_CONTENT, aFlags | HostRelease);

  mContentType = aType;
  mSize = gfx::IntSize(aRect.width, aRect.height);
  mTextureClient->EnsureAllocated(mSize, mContentType);
  // note that LockSurfaceDescriptor doesn't actually lock anything
  MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->LockSurfaceDescriptor()));

  CreateFrontBufferAndNotify(aRect, aFlags | HostRelease);

  nsRefPtr<gfxASurface> ret = mTextureClient->LockSurface();
  return ret.forget();
}
コード例 #2
0
ファイル: ContentClient.cpp プロジェクト: miketaylr/gecko-dev
void
ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
                                               const IntRect& aRect,
                                               uint32_t aFlags)
{
  // If we hit this assertion, then it might be due to an empty transaction
  // followed by a real transaction. Our buffers should be created (but not
  // painted in the empty transaction) and then painted (but not created) in the
  // real transaction. That is kind of fragile, and this assert will catch
  // circumstances where we screw that up, e.g., by unnecessarily recreating our
  // buffers.
  MOZ_ASSERT(!mIsNewBuffer,
             "Bad! Did we create a buffer twice without painting?");

  mIsNewBuffer = true;

  DestroyBuffers();

  mSurfaceFormat = aFormat;
  mSize = IntSize(aRect.width, aRect.height);
  mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags);

  if (aFlags & BUFFER_COMPONENT_ALPHA) {
    mTextureFlags |= TextureFlags::COMPONENT_ALPHA;
  }

  CreateBackBuffer(mBufferRect);
}
コード例 #3
0
TorcOMXPort::~TorcOMXPort()
{
    DestroyBuffers();

    delete m_lock;
    delete m_wait;
}
コード例 #4
0
void
ContentClientRemoteBuffer::BuildDeprecatedTextureClients(ContentType aType,
                                               const nsIntRect& aRect,
                                               uint32_t aFlags)
{
  NS_ABORT_IF_FALSE(!mIsNewBuffer,
                    "Bad! Did we create a buffer twice without painting?");

  mIsNewBuffer = true;

  if (mDeprecatedTextureClient) {
    mOldTextures.AppendElement(mDeprecatedTextureClient);
    if (mDeprecatedTextureClientOnWhite) {
      mOldTextures.AppendElement(mDeprecatedTextureClientOnWhite);
    }
    DestroyBuffers();
  }

  mContentType = aType;
  mSize = gfx::IntSize(aRect.width, aRect.height);
  mTextureInfo.mTextureFlags = aFlags | TEXTURE_DEALLOCATE_HOST;

  if (!CreateAndAllocateDeprecatedTextureClient(mDeprecatedTextureClient)) {
    return;
  }
  
  if (aFlags & BUFFER_COMPONENT_ALPHA) {
    if (!CreateAndAllocateDeprecatedTextureClient(mDeprecatedTextureClientOnWhite)) {
      return;
    }
    mTextureInfo.mTextureFlags |= TEXTURE_COMPONENT_ALPHA;
  }

  CreateFrontBufferAndNotify(aRect);
}
コード例 #5
0
OffscreenBuffer::OffscreenBuffer(int maxWidth, int maxHeight)
{
   glGenFramebuffers(1, &fboID);
   glGenRenderbuffers(1, &renderBufferID);
   glGenRenderbuffers(1, &depthBufferID);
   glGenBuffers(1, &pixelPackBufferID);

   glBindBuffer(GL_PIXEL_PACK_BUFFER, pixelPackBufferID);
   glBufferData(GL_PIXEL_PACK_BUFFER, 4, 0, GL_STREAM_READ);
   glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

   Bind();

   glBindRenderbuffer(GL_RENDERBUFFER, renderBufferID);
   glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, maxWidth, maxHeight);
   glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBufferID);

   glBindRenderbuffer(GL_RENDERBUFFER, depthBufferID);
   glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, maxWidth, maxHeight);
   glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBufferID);

   glBindRenderbuffer(GL_RENDERBUFFER, 0);

   GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

   OffscreenBuffer::Unbind();

   if (status != GL_FRAMEBUFFER_COMPLETE)
   {
      DestroyBuffers();

      throw Exception("Framebuffer incomplete");
   }
}
コード例 #6
0
ファイル: Connection.cpp プロジェクト: lemonxiao0/peerproject
// Delete this CConnection object
CConnection::~CConnection()
{
	m_bAutoDelete = FALSE;

	CConnection::Close();

	// Delete and mark null the input and output buffers
	DestroyBuffers();
}
コード例 #7
0
ファイル: Connection.cpp プロジェクト: lemonxiao0/peerproject
// Call to copy a connection object to this one (do)
// Takes another connection object
void CConnection::AttachTo(CConnection* pConnection)
{
	// Make sure the socket isn't valid yet
	ASSERT( ! IsValid() );								// Make sure the socket here isn't valid yet
	ASSERT( AfxIsValidAddress( pConnection, sizeof( *pConnection ) ) );
	ASSERT( pConnection->IsValid() );					// And make sure a CConnection object socket exists

	DestroyBuffers();

	CQuickLock oOutputLock( *pConnection->m_pOutputSection );
	CQuickLock oInputLock( *pConnection->m_pInputSection );

	// Copy values from the given CConnection object to this one
	m_pHost				= pConnection->m_pHost;
	m_sAddress			= pConnection->m_sAddress;
	m_sCountry			= pConnection->m_sCountry;
	m_sCountryName		= pConnection->m_sCountryName;
	m_hSocket			= pConnection->m_hSocket;
	m_bInitiated		= pConnection->m_bInitiated;
	m_bConnected		= pConnection->m_bConnected;
	m_tConnected		= pConnection->m_tConnected;
	m_pInputSection		= pConnection->m_pInputSection;
	m_pInput			= pConnection->m_pInput;
	m_pOutputSection	= pConnection->m_pOutputSection;
	m_pOutput			= pConnection->m_pOutput;
	m_sUserAgent		= pConnection->m_sUserAgent;
	m_bClientExtended	= pConnection->m_bClientExtended;
	m_nQueuedRun		= pConnection->m_nQueuedRun;
	if ( m_nProtocol <= PROTOCOL_NULL && pConnection->m_nProtocol > PROTOCOL_NULL )
		m_nProtocol		= pConnection->m_nProtocol;
	m_nDelayCloseReason	= pConnection->m_nDelayCloseReason;

	// Record the current time in the input and output TCP bandwidth meters
	m_mInput.tLast = m_mOutput.tLast = GetTickCount();

	// Invalidate the socket in the given connection object so it's just here now
	pConnection->m_hSocket	= INVALID_SOCKET;

	// Null the input and output pointers
	pConnection->m_pInput	= NULL;
	pConnection->m_pOutput	= NULL;

	// Zero the memory of the input and output TCPBandwidthMeter objects
	ZeroMemory( &pConnection->m_mInput, sizeof( m_mInput ) );
	ZeroMemory( &pConnection->m_mOutput, sizeof( m_mOutput ) );
}
コード例 #8
0
void
ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
        const nsIntRect& aRect,
        uint32_t aFlags)
{
    // If we hit this assertion, then it might be due to an empty transaction
    // followed by a real transaction. Our buffers should be created (but not
    // painted in the empty transaction) and then painted (but not created) in the
    // real transaction. That is kind of fragile, and this assert will catch
    // circumstances where we screw that up, e.g., by unnecessarily recreating our
    // buffers.
    NS_ABORT_IF_FALSE(!mIsNewBuffer,
                      "Bad! Did we create a buffer twice without painting?");

    mIsNewBuffer = true;

    DestroyBuffers();

    mSurfaceFormat = aFormat;
    mSize = gfx::IntSize(aRect.width, aRect.height);
    mTextureInfo.mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags);

    if (!CreateAndAllocateTextureClient(mTextureClient, TEXTURE_ON_BLACK) ||
            !AddTextureClient(mTextureClient)) {
        AbortTextureClientCreation();
        return;
    }

    if (aFlags & BUFFER_COMPONENT_ALPHA) {
        if (!CreateAndAllocateTextureClient(mTextureClientOnWhite, TEXTURE_ON_WHITE) ||
                !AddTextureClient(mTextureClientOnWhite)) {
            AbortTextureClientCreation();
            return;
        }
        mTextureInfo.mTextureFlags |= TEXTURE_COMPONENT_ALPHA;
    }

    CreateFrontBuffer(aRect);
}
コード例 #9
0
ファイル: ContentClient.cpp プロジェクト: memorais/TC2_impl
void
ContentClientRemote::BuildTextureClient(ContentType aType,
                                        const nsIntRect& aRect,
                                        uint32_t aFlags)
{
  NS_ABORT_IF_FALSE(!mIsNewBuffer,
                    "Bad! Did we create a buffer twice without painting?");

  mIsNewBuffer = true;

  if (mTextureClient) {
    mOldTextures.AppendElement(mTextureClient);
    DestroyBuffers();
  }
  mTextureInfo.mTextureFlags = aFlags | HostRelease;
  mTextureClient = CreateTextureClient(TEXTURE_CONTENT);

  mContentType = aType;
  mSize = gfx::IntSize(aRect.width, aRect.height);
  mTextureClient->EnsureAllocated(mSize, mContentType);
  MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->GetDescriptor()));

  CreateFrontBufferAndNotify(aRect);
}
コード例 #10
0
ファイル: Connection.cpp プロジェクト: lemonxiao0/peerproject
// Connect this CConnection object to a remote computer on the Internet
// Takes pAddress, a Windows Sockets structure that holds an IP address, and takes the port number seprately
// Returns true if connected
BOOL CConnection::ConnectTo(const IN_ADDR* pAddress, WORD nPort)
{
	// Make sure the socket isn't already connected somehow
	if ( IsValid() )
		return FALSE;

	// Make sure we have an address and a nonzero port number
	if ( pAddress == NULL || nPort == 0 )
		return FALSE;

	// S_un.S_addr is the IP as a single unsigned 4-byte long
	if ( pAddress->S_un.S_addr == 0 )
		return FALSE;

	// The IP address is in the security list of government and corporate addresses we want to avoid
	if ( Security.IsDenied( pAddress ) )
	{
		// Report that we aren't connecting to this IP address and return false
		theApp.Message( MSG_ERROR, IDS_NETWORK_SECURITY_OUTGOING, (LPCTSTR)CString( inet_ntoa( *pAddress ) ) );
		return FALSE;
	}

	// The IN_ADDR structure we just got passed isn't the same as the one already stored in this object
	if ( pAddress != &m_pHost.sin_addr )
	{
		// Zero the memory of the entire SOCKADDR_IN structure m_pHost, and then copy in the sin_addr part
		ZeroMemory( &m_pHost, sizeof( m_pHost ) );
		m_pHost.sin_addr = *pAddress;
	}

	// Fill in more parts of the m_pHost structure
	m_pHost.sin_family	= AF_INET;							// PF_INET means just normal IPv4, not IPv6 yet
	m_pHost.sin_port	= htons( nPort );					// Copy the port number into the m_pHost structure
	m_sAddress			= inet_ntoa( m_pHost.sin_addr );	// Save the IP address as a string of text
	UpdateCountry();

	// Create a socket and store it in m_hSocket
	// Normal IPv4 not IPv6, and the two-way sequenced reliable byte streams of TCP, not the datagrams of UDP
	m_hSocket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP );

	// Choose asynchronous, non-blocking reading and writing on our new socket
	DWORD dwValue = 1;
	ioctlsocket( m_hSocket, FIONBIO, &dwValue );
		// Call Windows Sockets ioctlsocket to control the input/output mode of our new socket
		// Give it our new socket
		// Select the option for blocking i/o, should the program wait on read and write calls, or keep going?
		// Nonzero, it should keep going

	// If the OutHost string in connection settings has an IP address written in it
	if ( Settings.Connection.OutHost.GetLength() )
	{
		// Read the text and copy the IP address and port into a new local MFC SOCKADDR_IN structure called pOutgoing
		SOCKADDR_IN pOutgoing;
		Network.Resolve( Settings.Connection.OutHost, 0, &pOutgoing );

		// S_addr is the IP address as a single long number, if it's not zero
		if ( pOutgoing.sin_addr.S_un.S_addr )
		{
			// Call bind in Windows Sockets to associate the local address with the socket
			bind(
				m_hSocket,					// Our socket
				(SOCKADDR*)&pOutgoing,		// The IP address this computer appears to have on the Internet (do)
				sizeof( SOCKADDR_IN ) );	// Tell bind how many bytes it can read at the pointer
		}
	}

	DestroyBuffers();

	// Try to connect to the remote computer
	if ( WSAConnect(
		m_hSocket,					// Our socket
		(SOCKADDR*)&m_pHost,		// The remote IP address and port number
		sizeof( SOCKADDR_IN ),		// How many bytes the function can read
		NULL, NULL, NULL, NULL ) )	// No advanced features
	{
		// If no error occurs, WSAConnect returns 0, so if we're here an error happened
		int nError = WSAGetLastError();		// Get the last Windows Sockets error number

		// An error of "would block" is normal because connections can't be made instantly and this is a non-blocking socket
		if ( nError != WSAEWOULDBLOCK )
		{
			CNetwork::CloseSocket( m_hSocket, true );

			if ( nError != 0 )
				Statistics.Current.Connections.Errors++;

			return FALSE;
		}
	}

	CreateBuffers();

	// Record that we initiated this connection, and when it happened
	m_bInitiated	= TRUE;
	m_tConnected	= GetTickCount();

	// Record one more outgoing connection in the statistics
	Statistics.Current.Connections.Outgoing++;

	// Connection successfully attempted
	return TRUE;
}
コード例 #11
0
OffscreenBuffer::~OffscreenBuffer()
{
   DestroyBuffers();
}