Example #1
0
static void mix_bitmaps(BBitmap* out, BBitmap* b1, BBitmap* b2, uint8 amount)
{
	if( out->BitsLength() != b1->BitsLength() ||
		out->BitsLength() != b2->BitsLength() ||
		out->ColorSpace() != b1->ColorSpace() ||
		out->ColorSpace() != b2->ColorSpace() ) {
		TRESPASS();
		return;
	}
	
	switch( out->ColorSpace() ) {
		case B_RGB32:
		case B_RGBA32:
		case B_RGB32_BIG:
		case B_RGBA32_BIG:
		{
			uint8* sOut = (uint8*)out->Bits();
			uint8* eOut = sOut + out->BitsLength();
			uint8* sB1 = (uint8*)b1->Bits();
			uint8* sB2 = (uint8*)b2->Bits();
			
			while( sOut < eOut ) {
				*sOut = (uint8)( ( ((uint16)*sB1)*(255-amount)
								 + ((uint16)*sB2)*(amount)
								 ) / 255 );
				sOut++;
				sB1++;
				sB2++;
			}
		} break;
		
		default:
			TRESPASS();
	}
}
void
BTrashWatcher::UpdateTrashIcons()
{
	BVolume	boot;
	if (BVolumeRoster().GetBootVolume(&boot) != B_OK)
		return;

	BDirectory trashDir;
	if (FSGetTrashDir(&trashDir, boot.Device()) == B_OK) {
		// pull out the icons for the current trash state from resources and
		// apply them onto the trash directory node
		size_t largeSize = 0;
		size_t smallSize = 0;
		const void *largeData = GetTrackerResources()->LoadResource('ICON',
			fTrashFull ? kResTrashFullIcon : kResTrashIcon, &largeSize);

		const void *smallData = GetTrackerResources()->LoadResource('MICN',
			fTrashFull ? kResTrashFullIcon : kResTrashIcon,  &smallSize);

		if (largeData) 
			trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
				largeData, largeSize);
		else
			TRESPASS();

		if (smallData)
			trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
				smallData, smallSize);
		else
			TRESPASS();
	}
}
void
BTrashWatcher::UpdateTrashIcons()
{
	BVolumeRoster roster;
	BVolume volume;
	roster.Rewind();

	BDirectory trashDir;
	while (roster.GetNextVolume(&volume) == B_OK) {
		if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
			// pull out the icons for the current trash state from resources
			// and apply them onto the trash directory node
			size_t largeSize = 0;
			size_t smallSize = 0;
			const void* largeData
				= GetTrackerResources()->LoadResource('ICON',
					fTrashFull ? R_TrashFullIcon : R_TrashIcon, &largeSize);

			const void* smallData
				= GetTrackerResources()->LoadResource('MICN',
					fTrashFull ? R_TrashFullIcon : R_TrashIcon,  &smallSize);

#ifdef HAIKU_TARGET_PLATFORM_HAIKU
			size_t vectorSize = 0;
			const void* vectorData = GetTrackerResources()->LoadResource(
				B_VECTOR_ICON_TYPE,
				fTrashFull ? R_TrashFullIcon : R_TrashIcon, &vectorSize);

			if (vectorData) {
				trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0,
					vectorData, vectorSize);
			} else
				TRESPASS();
#endif

			if (largeData) {
				trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
					largeData, largeSize);
			} else
				TRESPASS();

			if (smallData) {
				trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
					smallData, smallSize);
			} else
				TRESPASS();
		}
	}
}
static void copyTrespass(
        short * /* dst */,
        const int *const * /* src */,
        unsigned /* nSamples */,
        unsigned /* nChannels */) {
    TRESPASS();
}
void TunnelRenderer::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatQueueBuffer:
        {
            sp<ABuffer> buffer;
            CHECK(msg->findBuffer("buffer", &buffer));

            queueBuffer(buffer);

            if (mStreamSource == NULL) {
                if (mTotalBytesQueued > 0ll) {
                    initPlayer();
                } else {
                    ALOGI("Have %lld bytes queued...", mTotalBytesQueued);
                }
            } else {
                mStreamSource->doSomeWork();
            }
            break;
        }

        default:
            TRESPASS();
    }
}
Example #6
0
status_t
BImageResources::GetBitmapResource(type_code type, int32 id,
                                   BBitmap** out) const
{
    *out = NULL;

    size_t len = 0;
    const void* data = LoadResource(type, id, &len);

    if (data == NULL) {
        TRESPASS();
        return B_ERROR;
    }

    BMemoryIO stream(data, len);

    // Try to read as an archived bitmap.
    stream.Seek(0, SEEK_SET);
    BMessage archive;
    status_t result = archive.Unflatten(&stream);
    if (result != B_OK)
        return result;

    *out = new BBitmap(&archive);
    if (*out == NULL)
        return B_ERROR;

    result = (*out)->InitCheck();
    if (result != B_OK) {
        delete *out;
        *out = NULL;
    }

    return result;
}
Example #7
0
int32
TQueryWalker::CountEntries()
{
	// should not be calling this
	TRESPASS();
	return -1;
}
Example #8
0
void DirectRenderer::onDecoderNotify(const sp<AMessage> &msg) {
    size_t trackIndex;
    CHECK(msg->findSize("trackIndex", &trackIndex));

    int32_t what;
    CHECK(msg->findInt32("what", &what));

    switch (what) {
        case DecoderContext::kWhatOutputBufferReady:
        {
            size_t index;
            CHECK(msg->findSize("index", &index));

            int64_t timeUs;
            CHECK(msg->findInt64("timeUs", &timeUs));

            sp<ABuffer> buffer;
            CHECK(msg->findBuffer("buffer", &buffer));

            queueOutputBuffer(trackIndex, index, timeUs, buffer);
            break;
        }

        default:
            TRESPASS();
    }
}
void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatConnect:
            onConnect(msg);
            break;

        case kWhatDisconnect:
            onDisconnect(msg);
            break;

        case kWhatCompleteConnection:
            onCompleteConnection(msg);
            break;

        case kWhatSendRequest:
            onSendRequest(msg);
            break;

        case kWhatReceiveResponse:
            onReceiveResponse();
            break;

        case kWhatObserveBinaryData:
        {
            CHECK(msg->findMessage("reply", &mObserveBinaryMessage));
            break;
        }

        default:
            TRESPASS();
            break;
    }
}
status_t DashPlayerDriver::seekTo(int msec) {
    int64_t seekTimeUs = msec * 1000ll;

    switch (mState) {
        case UNINITIALIZED:
            return INVALID_OPERATION;
        case STOPPED:
        {
            mStartupSeekTimeUs = seekTimeUs;
            break;
        }
        case PLAYING:
        case PAUSED:
        {
            mAtEOS = false;
            mPlayer->seekToAsync(seekTimeUs);
            break;
        }

        default:
            TRESPASS();
            break;
    }

    return OK;
}
Example #11
0
bool
WidgetAttributeText::CommitEditedText(BTextView*)
{
	// can't do anything here at this point
	TRESPASS();
	return false;
}
Example #12
0
status_t TimedTextDriver::seekToAsync(int64_t timeUs) {
#ifdef MTK_AOSP_ENHANCEMENT
    ALOGD("%s() is called", __FUNCTION__);
#endif
    Mutex::Autolock autoLock(mLock);
    ALOGV("%s() is called", __FUNCTION__);
    switch (mState) {
        case UNINITIALIZED:
            return INVALID_OPERATION;
        case PREPARED:
            mPlayer->seekToAsync(timeUs);
            mPlayer->pause();
            mState = PAUSED;
            return OK;
        case PAUSED:
            mPlayer->seekToAsync(timeUs);
            mPlayer->pause();
            return OK;
        case PLAYING:
            mPlayer->seekToAsync(timeUs);
            return OK;
        defaut:
            TRESPASS();
    }
    return UNKNOWN_ERROR;
}
Example #13
0
void GraphicBufferSource::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatRepeatLastFrame:
        {
            Mutex::Autolock autoLock(mMutex);

            int32_t generation;
            CHECK(msg->findInt32("generation", &generation));

            if (generation != mRepeatLastFrameGeneration) {
                // stale
                break;
            }

            if (!mExecuting || mNumFramesAvailable > 0) {
                break;
            }

            bool success = repeatLatestBuffer_l();

            if (success) {
                ALOGV("repeatLatestBuffer_l SUCCESS");
            } else {
                ALOGV("repeatLatestBuffer_l FAILURE");
                mRepeatBufferDeferred = true;
            }
            break;
        }

        default:
            TRESPASS();
    }
}
// Called on GonkVideoDecoderManager::mManagerLooper thread.
void
GonkVideoDecoderManager::onMessageReceived(const sp<AMessage> &aMessage)
{
  switch (aMessage->what()) {
    case kNotifyCodecReserved:
    {
      // Our decode may have acquired the hardware resource that it needs
      // to start. Notify the state machine to resume loading metadata.
      GVDM_LOG("CodecReserved!");
      mReaderCallback->NotifyResourcesStatusChanged();
      break;
    }

    case kNotifyCodecCanceled:
    {
      mReaderCallback->ReleaseMediaResources();
      break;
    }

    case kNotifyPostReleaseBuffer:
    {
      ReleaseAllPendingVideoBuffers();
      break;
    }

    default:
      TRESPASS();
      break;
  }
}
void SimpleSoftOMXComponent::onSendCommand(
    OMX_COMMANDTYPE cmd, OMX_U32 param) {
    switch (cmd) {
    case OMX_CommandStateSet:
    {
        onChangeState((OMX_STATETYPE)param);
        break;
    }

    case OMX_CommandPortEnable:
    case OMX_CommandPortDisable:
    {
        onPortEnable(param, cmd == OMX_CommandPortEnable);
        break;
    }

    case OMX_CommandFlush:
    {
        onPortFlush(param, true /* sendFlushComplete */);
        break;
    }

    default:
        TRESPASS();
        break;
    }
}
bool ARTSPConnection::notifyResponseListener(
        const sp<ARTSPResponse> &response) {
    ssize_t i = response->mHeaders.indexOfKey("cseq");

    if (i < 0) {
        return true;
    }

    AString value = response->mHeaders.valueAt(i);

    unsigned long cseq;
    if (!ParseSingleUnsignedLong(value.c_str(), &cseq)) {
        return false;
    }

    i = mPendingRequests.indexOfKey(cseq);

    if (i < 0) {
        // Unsolicited response?
        TRESPASS();
    }

    sp<AMessage> reply = mPendingRequests.valueAt(i);
    mPendingRequests.removeItemsAt(i);

    reply->setInt32("result", OK);
    reply->setObject("response", response);
    reply->post();

    return true;
}
Example #17
0
void
TBarWindow::MenusBeginning()
{
	BPath path;
	entry_ref ref;
	BEntry entry;

	if (GetDeskbarSettingsDirectory(path) == B_OK
		&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
		&& entry.SetTo(path.Path(), true) == B_OK
		&& entry.Exists()
		&& entry.GetRef(&ref) == B_OK) {
		sDeskbarMenu->SetNavDir(&ref);
	} else if (GetDeskbarDataDirectory(path) == B_OK
		&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
		&& entry.SetTo(path.Path(), true) == B_OK
		&& entry.Exists()
		&& entry.GetRef(&ref) == B_OK) {
		sDeskbarMenu->SetNavDir(&ref);
	} else {
		//	this really should never happen
		TRESPASS();
		return;
	}

	sDeskbarMenu->ResetTargets();

	fShowingMenu = true;
	BWindow::MenusBeginning();
}
void SimpleSoftOMXComponent::onChangeState(OMX_STATETYPE state) {
    // We shouldn't be in a state transition already.
    CHECK_EQ((int)mState, (int)mTargetState);

    switch (mState) {
    case OMX_StateLoaded:
        CHECK_EQ((int)state, (int)OMX_StateIdle);
        break;
    case OMX_StateIdle:
        CHECK(state == OMX_StateLoaded || state == OMX_StateExecuting);
        break;
    case OMX_StateExecuting:
    {
        CHECK_EQ((int)state, (int)OMX_StateIdle);

        for (size_t i = 0; i < mPorts.size(); ++i) {
            onPortFlush(i, false /* sendFlushComplete */);
        }

        mState = OMX_StateIdle;
        notify(OMX_EventCmdComplete, OMX_CommandStateSet, state, NULL);
        break;
    }

    default:
        TRESPASS();
    }

    mTargetState = state;

    checkTransitions();
}
Example #19
0
status_t TimedTextDriver::unselectTrack(size_t index) {
#ifdef MTK_AOSP_ENHANCEMENT
    ALOGD("%s() index:%d", __FUNCTION__, index);
#endif
    Mutex::Autolock autoLock(mLock);
    ALOGV("%s() is called", __FUNCTION__);
    if (mCurrentTrackIndex != index) {
        return INVALID_OPERATION;
    }
    mCurrentTrackIndex = UINT_MAX;
    switch (mState) {
        case UNINITIALIZED:
            return INVALID_OPERATION;
        case PLAYING:
            mPlayer->setDataSource(NULL);
            mState = UNINITIALIZED;
            return OK;
        case PREPARED:
        case PAUSED:
            mState = UNINITIALIZED;
            return OK;
        default:
            TRESPASS();
    }
    return UNKNOWN_ERROR;
}
Example #20
0
status_t TimedTextDriver::selectTrack(size_t index) {
#ifdef MTK_AOSP_ENHANCEMENT
    ALOGD("%s() index:%d", __FUNCTION__, index);
#endif
    status_t ret = OK;
    Mutex::Autolock autoLock(mLock);
    ALOGV("%s() is called", __FUNCTION__);
    switch (mState) {
        case UNINITIALIZED:
        case PREPARED:
        case PAUSED:
            ret = selectTrack_l(index);
            break;
        case PLAYING:
            mPlayer->pause();
            ret = selectTrack_l(index);
            if (ret != OK) {
                break;
            }
            mPlayer->start();
            break;
        defaut:
            TRESPASS();
    }
    return ret;
}
void SimpleSoftOMXComponent::onMessageReceived(const sp<AMessage> &msg) {
    Mutex::Autolock autoLock(mLock);
    uint32_t msgType = msg->what();
    ALOGV("msgType = %d", msgType);
    switch (msgType) {
    case kWhatSendCommand:
    {
        int32_t cmd, param;
        CHECK(msg->findInt32("cmd", &cmd));
        CHECK(msg->findInt32("param", &param));

        onSendCommand((OMX_COMMANDTYPE)cmd, (OMX_U32)param);
        break;
    }

    case kWhatEmptyThisBuffer:
    case kWhatFillThisBuffer:
    {
        OMX_BUFFERHEADERTYPE *header;
        CHECK(msg->findPointer("header", (void **)&header));

        CHECK(mState == OMX_StateExecuting && mTargetState == mState);

        bool found = false;
        size_t portIndex = (kWhatEmptyThisBuffer == msgType)?
                           header->nInputPortIndex: header->nOutputPortIndex;
        PortInfo *port = &mPorts.editItemAt(portIndex);

        for (size_t j = 0; j < port->mBuffers.size(); ++j) {
            BufferInfo *buffer = &port->mBuffers.editItemAt(j);

            if (buffer->mHeader == header) {
                CHECK(!buffer->mOwnedByUs);

                buffer->mOwnedByUs = true;

                CHECK((msgType == kWhatEmptyThisBuffer
                       && port->mDef.eDir == OMX_DirInput)
                      || (port->mDef.eDir == OMX_DirOutput));

                port->mQueue.push_back(buffer);
                onQueueFilled(portIndex);

                found = true;
                break;
            }
        }

        CHECK(found);
        break;
    }

    default:
        TRESPASS();
        break;
    }
}
Example #22
0
void Serializer::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatAddSource:
        {
            ssize_t index = onAddSource(msg);

            sp<AMessage> response = new AMessage;

            if (index < 0) {
                response->setInt32("err", index);
            } else {
                response->setSize("index", index);
            }

            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            response->postReply(replyID);
            break;
        }

        case kWhatStart:
        case kWhatStop:
        {
            status_t err = (msg->what() == kWhatStart) ? onStart() : onStop();

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);

            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            response->postReply(replyID);
            break;
        }

        case kWhatPoll:
        {
            int32_t generation;
            CHECK(msg->findInt32("generation", &generation));

            if (generation != mPollGeneration) {
                break;
            }

            int64_t delayUs = onPoll();
            if (delayUs >= 0ll) {
                schedulePoll(delayUs);
            }
            break;
        }

        default:
            TRESPASS();
    }
}
// static
sp<HTTPBase> HTTPBase::Create(uint32_t flags) {
#if CHROMIUM_AVAILABLE
    return new ChromiumHTTPDataSource(flags);
#endif
    {
        TRESPASS();

        return NULL;
    }
}
Example #24
0
void SDPLoader::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatLoad:
            onLoad(msg);
            break;

        default:
            TRESPASS();
            break;
    }
}
Example #25
0
BRect
BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
	const BPoseView* view, float textWidth)
{
	BRect result;
	if (view->ViewMode() == kListMode) {
		poseLoc.x += column->Offset();

		switch (fAlignment) {
			case B_ALIGN_LEFT:
				result.left = poseLoc.x;
				result.right = result.left + textWidth + 1;
				break;

			case B_ALIGN_CENTER:
				result.left = poseLoc.x + (column->Width() / 2)
					- (textWidth / 2);
				if (result.left < 0)
					result.left = 0;

				result.right = result.left + textWidth + 1;
				break;

			case B_ALIGN_RIGHT:
				result.right = poseLoc.x + column->Width();
				result.left = result.right - textWidth - 1;
				if (result.left < 0)
					result.left = 0;
				break;

			default:
				TRESPASS();
				break;
		}

		result.bottom = poseLoc.y + (view->ListElemHeight() - 1);
	} else {
		if (view->ViewMode() == kIconMode) {
			// large/scaled icon mode
			result.left = poseLoc.x + (view->IconSizeInt() - textWidth) / 2;
		} else {
			// mini icon mode
			result.left = poseLoc.x + B_MINI_ICON + kMiniIconSeparator;
		}

		result.right = result.left + textWidth;
		result.bottom = poseLoc.y + view->IconPoseHeight();

	}
	result.top = result.bottom - view->FontHeight();

	return result;
}
Example #26
0
void DirectRenderer::DecoderContext::onMessageReceived(
        const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatDecoderNotify:
        {
            onDecoderNotify();
            break;
        }

        default:
            TRESPASS();
    }
}
Example #27
0
// static
sp<HTTPBase> HTTPBase::Create(uint32_t flags) {
#if CHROMIUM_AVAILABLE
        HTTPBase *dataSource = createChromiumHTTPDataSource(flags);
        if (dataSource) {
           return dataSource;
        }
#endif
    {
        TRESPASS();

        return NULL;
    }
}
Example #28
0
BDeskWindow *
TTracker::GetDeskWindow() const
{
	int32 count = fWindowList.CountItems();
	for (int32 index = 0; index < count; index++) {
		BDeskWindow *window = dynamic_cast<BDeskWindow *>
			(fWindowList.ItemAt(index));

		if (window)
			return window;
	}
	TRESPASS();
	return NULL;
}
Example #29
0
void DirectRenderer::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatDecoderNotify:
        {
            onDecoderNotify(msg);
            break;
        }

        case kWhatRenderVideo:
        {
            onRenderVideo();
            break;
        }

        case kWhatQueueAccessUnit:
            onQueueAccessUnit(msg);
            break;

        case kWhatSetFormat:
            onSetFormat(msg);
            break;

#ifdef MTK_AOSP_ENHANCEMENT
        case kWhatPause:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            onPause();

            sp<AMessage> response = new AMessage;
            response->postReply(replyID);
            break;
        }
        case kWhatPlay:
        {
            uint32_t replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            onResume();
            sp<AMessage> response = new AMessage;
            response->postReply(replyID);
            break;
        }
#endif
        default:
            TRESPASS();
    }
}
// Called on GonkVideoDecoderManager::mManagerLooper thread.
void
GonkVideoDecoderManager::onMessageReceived(const sp<AMessage> &aMessage)
{
  switch (aMessage->what()) {
    case kNotifyPostReleaseBuffer:
    {
      ReleaseAllPendingVideoBuffers();
      break;
    }

    default:
      TRESPASS();
      break;
  }
}