void Layer::dump(String8& result, char* buffer, size_t SIZE) const { LayerBaseClient::dump(result, buffer, SIZE); sp<const GraphicBuffer> buf0(mActiveBuffer); uint32_t w0=0, h0=0, s0=0, f0=0; if (buf0 != 0) { w0 = buf0->getWidth(); h0 = buf0->getHeight(); s0 = buf0->getStride(); f0 = buf0->format; } snprintf(buffer, SIZE, " " "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," " transform-hint=0x%02x, queued-frames=%d\n", mFormat, w0, h0, s0,f0, getTransformHint(), mQueuedFrames); result.append(buffer); if (mSurfaceTexture != 0) { mSurfaceTexture->dump(result, " ", buffer, SIZE); } }
void Layer::dump(String8& result, Colorizer& colorizer) const { const Layer::State& s(getDrawingState()); colorizer.colorize(result, Colorizer::GREEN); result.appendFormat( "+ %s %p (%s)\n", getTypeId(), this, getName().string()); colorizer.reset(result); s.activeTransparentRegion.dump(result, "transparentRegion"); visibleRegion.dump(result, "visibleRegion"); sp<Client> client(mClientRef.promote()); result.appendFormat( " " "layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), crop=(%4d,%4d,%4d,%4d), " "isOpaque=%1d, invalidate=%1d, " "alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n" " client=%p\n", s.layerStack, s.z, s.transform.tx(), s.transform.ty(), s.active.w, s.active.h, s.active.crop.left, s.active.crop.top, s.active.crop.right, s.active.crop.bottom, isOpaque(), contentDirty, s.alpha, s.flags, s.transform[0][0], s.transform[0][1], s.transform[1][0], s.transform[1][1], client.get()); sp<const GraphicBuffer> buf0(mActiveBuffer); uint32_t w0=0, h0=0, s0=0, f0=0; if (buf0 != 0) { w0 = buf0->getWidth(); h0 = buf0->getHeight(); s0 = buf0->getStride(); f0 = buf0->format; } result.appendFormat( " " "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," " queued-frames=%d, mRefreshPending=%d\n", mFormat, w0, h0, s0,f0, mQueuedFrames, mRefreshPending); if (mSurfaceFlingerConsumer != 0) { mSurfaceFlingerConsumer->dump(result, " "); } }
void Layer::dump(String8& result, char* buffer, size_t SIZE) const { LayerBaseClient::dump(result, buffer, SIZE); sp<const GraphicBuffer> buf0(mActiveBuffer); uint32_t w0=0, h0=0, s0=0, f0=0; if (buf0 != 0) { w0 = buf0->getWidth(); h0 = buf0->getHeight(); s0 = buf0->getStride(); f0 = buf0->format; } snprintf(buffer, SIZE, " " "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," " queued-frames=%d, mRefreshPending=%d\n", mFormat, w0, h0, s0,f0, mQueuedFrames, mRefreshPending); result.append(buffer); // [MTK] {{{ snprintf(buffer, SIZE, "secure=%d", mSecure); result.append(buffer); // [MTK] }}} if (mSurfaceTexture != 0) { mSurfaceTexture->dump(result, " ", buffer, SIZE); } // [MTK] {{{ char value[PROPERTY_VALUE_MAX]; int layerdump; property_get("debug.sf.layerdump", value, "0"); layerdump = atoi(value); // check if the identity to dump, or -1 for all if ((-1 == layerdump) || (getIdentity() == (uint32_t)layerdump)) { mSurfaceTexture->dumpAux(); dumpActiveBuffer(); } // [MTK] }}} }
static bool testIsEqFile(const char* fileName0,const char* fileName1){ FILE* file0=fopen(fileName0, "rb"); FILE* file1=fopen(fileName1, "rb"); assert(file0); assert(file1); bool result=true; std::vector<unsigned char> buf0(1*1024*1024); std::vector<unsigned char> buf1=buf0; while (true) { long bufSize0=fread(&buf0[0],1,buf0.size(),file0); long bufSize1=fread(&buf1[0],1,buf1.size(),file1); if (bufSize0!=bufSize1) { result=false; break; } if (buf0!=buf1) { result=false; break; } if (bufSize0==0) { break; } } fclose(file0); fclose(file1); return result; }
void Layer::dump(String8& result, char* buffer, size_t SIZE) const { LayerBaseClient::dump(result, buffer, SIZE); ClientRef::Access sharedClient(mUserClientRef); SharedBufferServer* lcblk(sharedClient.get()); uint32_t totalTime = 0; if (lcblk) { SharedBufferStack::Statistics stats = lcblk->getStats(); totalTime= stats.totalTime; result.append( lcblk->dump(" ") ); } sp<const GraphicBuffer> buf0(getBuffer(0)); sp<const GraphicBuffer> buf1(getBuffer(1)); uint32_t w0=0, h0=0, s0=0; uint32_t w1=0, h1=0, s1=0; if (buf0 != 0) { w0 = buf0->getWidth(); h0 = buf0->getHeight(); s0 = buf0->getStride(); } if (buf1 != 0) { w1 = buf1->getWidth(); h1 = buf1->getHeight(); s1 = buf1->getStride(); } snprintf(buffer, SIZE, " " "format=%2d, [%3ux%3u:%3u] [%3ux%3u:%3u]," " freezeLock=%p, dq-q-time=%u us\n", mFormat, w0, h0, s0, w1, h1, s1, getFreezeLock().get(), totalTime); result.append(buffer); }
Region Layer::latchBuffer(bool& recomputeVisibleRegions) { ATRACE_CALL(); Region outDirtyRegion; if (mQueuedFrames > 0) { // if we've already called updateTexImage() without going through // a composition step, we have to skip this layer at this point // because we cannot call updateTeximage() without a corresponding // compositionComplete() call. // we'll trigger an update in onPreComposition(). if (mRefreshPending) { return outDirtyRegion; } // Capture the old state of the layer for comparisons later const bool oldOpacity = isOpaque(); sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer; // signal another event if we have more frames pending if (android_atomic_dec(&mQueuedFrames) > 1) { mFlinger->signalLayerUpdate(); } struct Reject : public SurfaceTexture::BufferRejecter { Layer::State& front; Layer::State& current; bool& recomputeVisibleRegions; Reject(Layer::State& front, Layer::State& current, bool& recomputeVisibleRegions) : front(front), current(current), recomputeVisibleRegions(recomputeVisibleRegions) { } virtual bool reject(const sp<GraphicBuffer>& buf, const BufferQueue::BufferItem& item) { if (buf == NULL) { return false; } uint32_t bufWidth = buf->getWidth(); uint32_t bufHeight = buf->getHeight(); // check that we received a buffer of the right size // (Take the buffer's orientation into account) if (item.mTransform & Transform::ROT_90) { swap(bufWidth, bufHeight); } bool isFixedSize = item.mScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE; if (front.active != front.requested) { if (isFixedSize || (bufWidth == front.requested.w && bufHeight == front.requested.h)) { // Here we pretend the transaction happened by updating the // current and drawing states. Drawing state is only accessed // in this thread, no need to have it locked front.active = front.requested; // We also need to update the current state so that // we don't end-up overwriting the drawing state with // this stale current state during the next transaction // // NOTE: We don't need to hold the transaction lock here // because State::active is only accessed from this thread. current.active = front.active; // recompute visible region recomputeVisibleRegions = true; } ALOGD_IF(DEBUG_RESIZE, "latchBuffer/reject: buffer (%ux%u, tr=%02x), scalingMode=%d\n" " drawing={ active ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n" " requested={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }}\n", bufWidth, bufHeight, item.mTransform, item.mScalingMode, front.active.w, front.active.h, front.active.crop.left, front.active.crop.top, front.active.crop.right, front.active.crop.bottom, front.active.crop.getWidth(), front.active.crop.getHeight(), front.requested.w, front.requested.h, front.requested.crop.left, front.requested.crop.top, front.requested.crop.right, front.requested.crop.bottom, front.requested.crop.getWidth(), front.requested.crop.getHeight()); } if (!isFixedSize) { if (front.active.w != bufWidth || front.active.h != bufHeight) { // reject this buffer return true; } } return false; } }; Reject r(mDrawingState, currentState(), recomputeVisibleRegions); #ifndef STE_HARDWARE if (mSurfaceTexture->updateTexImage(&r, true) < NO_ERROR) { #else if (mSurfaceTexture->updateTexImage(&r, true, true) < NO_ERROR) { #endif // something happened! recomputeVisibleRegions = true; return outDirtyRegion; } // update the active buffer mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); if (mActiveBuffer == NULL) { // this can only happen if the very first buffer was rejected. return outDirtyRegion; } mRefreshPending = true; mFrameLatencyNeeded = true; if (oldActiveBuffer == NULL) { // the first time we receive a buffer, we need to trigger a // geometry invalidation. recomputeVisibleRegions = true; } Rect crop(mSurfaceTexture->getCurrentCrop()); const uint32_t transform(mSurfaceTexture->getCurrentTransform()); const uint32_t scalingMode(mSurfaceTexture->getCurrentScalingMode()); if ((crop != mCurrentCrop) || (transform != mCurrentTransform) || (scalingMode != mCurrentScalingMode)) { mCurrentCrop = crop; mCurrentTransform = transform; mCurrentScalingMode = scalingMode; recomputeVisibleRegions = true; } if (oldActiveBuffer != NULL) { uint32_t bufWidth = mActiveBuffer->getWidth(); uint32_t bufHeight = mActiveBuffer->getHeight(); if (bufWidth != uint32_t(oldActiveBuffer->width) || bufHeight != uint32_t(oldActiveBuffer->height)) { recomputeVisibleRegions = true; } } mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); if (oldOpacity != isOpaque()) { recomputeVisibleRegions = true; } glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // FIXME: postedRegion should be dirty & bounds const Layer::State& front(drawingState()); Region dirtyRegion(Rect(front.active.w, front.active.h)); // transform the dirty region to window-manager space outDirtyRegion = (front.transform.transform(dirtyRegion)); } return outDirtyRegion; } void Layer::dump(String8& result, char* buffer, size_t SIZE) const { LayerBaseClient::dump(result, buffer, SIZE); sp<const GraphicBuffer> buf0(mActiveBuffer); uint32_t w0=0, h0=0, s0=0, f0=0; if (buf0 != 0) { w0 = buf0->getWidth(); h0 = buf0->getHeight(); s0 = buf0->getStride(); f0 = buf0->format; } snprintf(buffer, SIZE, " " "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," " queued-frames=%d, mRefreshPending=%d\n", mFormat, w0, h0, s0,f0, mQueuedFrames, mRefreshPending); result.append(buffer); if (mSurfaceTexture != 0) { mSurfaceTexture->dump(result, " ", buffer, SIZE); } }
// ---------------------------------------------------------------------------- // Message dispatcher // ---------------------------------------------------------------------------- // void CMPXPlaybackSession::DispatchMessageL( const RMessage2& aMessage, TInt& aMsgHandleResult ) { aMsgHandleResult = KErrNone; // // All methods apart from the player creation methods, require a player // TInt op=aMessage.Function(); if (op != EPbsSetMode) { CheckPlayerL(); } MPX_DEBUG3("-->CMPXPlaybackSession::DispatchMessageL %d, this 0x%08x", op, this); switch(op) { case EPbsSetMode: { SetModeL(aMessage); break; } case EPbsGetClients: { RArray<TProcessId> procArray; ::CopyArrayL<TProcessId>( iPlayer->ClientList()->ClientProcessList(), procArray ); TProcessId lastPid = static_cast<CMPXPlaybackServer*>( const_cast<CServer2*>(Server()))->LastActiveProcessId(); TInt index( procArray.Find( lastPid )); if ( KErrNotFound != index && index ) { procArray.Remove( index ); procArray.Insert( lastPid, 0 ); } ::CreateBufferL<TProcessId>( procArray.Array(), iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); procArray.Close(); break; } case EPbsGetSyncBuffer: { aMessage.WriteL(0,iSyncBuffer->Ptr(0)); delete iSyncBuffer; iSyncBuffer = NULL; break; } case EPbsGetAsyncBuffer: { //In case of other application leaving, causing us to leave //we could have a task that does not get removed from the top of the queue //but the data for that task has been deleted. //When the task runs again, there will be no data causing a panic - leave if this occurs User::LeaveIfNull(iAsyncBuffer); aMessage.WriteL(0,iAsyncBuffer->Ptr(0)); delete iAsyncBuffer; iAsyncBuffer = NULL; break; } case EPbsInitFromCollection: { MPXUser::CreateBufferL(aMessage, 0, iSyncBuffer); CMPXCollectionPlaylist* p = NULL; ::NewFromBufferL(*iSyncBuffer, p); delete iSyncBuffer; iSyncBuffer = NULL; CleanupStack::PushL(p); iPlayer->InitL(*p,aMessage.Int1()); CleanupStack::PopAndDestroy(p); } break; case EPbsInitFromUri: { CBufBase* buf0(NULL); MPXUser::CreateBufferL(aMessage,0,buf0); CleanupStack::PushL(buf0); // Type parameter is optional if ( aMessage.GetDesLength( 1 ) > 0 ) { CBufBase* buf1(NULL); MPXUser::CreateBufferL(aMessage,1,buf1); CleanupStack::PushL(buf1); iPlayer->InitL(MPXUser::Ptr(buf0->Ptr(0)), buf1->Ptr(0)); CleanupStack::PopAndDestroy(buf1); } else { MPX_DEBUG2("CMPXPlaybackSession::DispatchMessageL %d: Type is empty", op); iPlayer->InitL( MPXUser::Ptr( buf0->Ptr(0) ), KNullDesC8 ); } CleanupStack::PopAndDestroy(buf0); } break; case EPbsInitFromFile: { InitFromFileL(aMessage); break; } case EPbsInitStreamingFromUri: { CBufBase* buf0(NULL); MPXUser::CreateBufferL(aMessage,0,buf0); CleanupStack::PushL(buf0); // Type parameter is optional if ( aMessage.GetDesLength( 1 ) > 0 ) { CBufBase* buf1(NULL); MPXUser::CreateBufferL(aMessage,1,buf1); CleanupStack::PushL(buf1); iPlayer->InitStreamingL(MPXUser::Ptr(buf0->Ptr(0)), buf1->Ptr(0), aMessage.Int2()); CleanupStack::PopAndDestroy(buf1); } else { MPX_DEBUG2("CMPXPlaybackSession::DispatchMessageL %d: Type is empty", op); iPlayer->InitStreamingL( MPXUser::Ptr( buf0->Ptr(0) ), KNullDesC8, aMessage.Int2() ); } CleanupStack::PopAndDestroy(buf0); break; } case EPbsInitStreamingFromFile: { RFile file; User::LeaveIfError(file.AdoptFromClient(aMessage,0,1)); iPlayer->InitStreamingL(file, aMessage.Int2()); file.Close(); break; } case EPbsCancelRequest: { CancelRequests(); break; } case EPbsGetState: { aMsgHandleResult = iPlayer->State(); break; } case EPbsSetProperty: { iPlayer->SetL(static_cast<TMPXPlaybackProperty>(aMessage.Int0()), aMessage.Int1()); break; } case EPbsGetProperty: { SetAsync(aMessage); iPlayer->PropertyL( static_cast<TMPXPlaybackProperty>(aMessage.Int0()),*this); break; } case EPbsGetPlayerTypes: { RArray<TMPXPlaybackPlayerType> pluginTypes; CleanupClosePushL(pluginTypes); RArray<TInt> types; CleanupClosePushL(types); iPlayer->PluginHandler()->GetPluginTypes(types); for (TInt i=0; i< types.Count(); ++i) { pluginTypes.AppendL( static_cast<TMPXPlaybackPlayerType>(types[i])); } CleanupStack::PopAndDestroy(&types); ::CreateBufferL<TMPXPlaybackPlayerType>( pluginTypes.Array(), iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); CleanupStack::PopAndDestroy(&pluginTypes); break; } case EPbsGetPlayerTypeDisplayName: { const TDesC& playerName = iPlayer->PluginHandler()->PlayerName( static_cast<TMPXPlaybackPlayerType>(aMessage.Int0())); aMsgHandleResult = 0; if (playerName.Length()>0) { MPXUser::CreateBufferL(playerName, iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); } break; } case EPbsGetAllPlayersUids: { RArray<TUid> uids; CleanupClosePushL(uids); iPlayer->PluginHandler()->GetPluginUids(uids); ::CreateBufferL<TUid>( uids.Array(), iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); CleanupStack::PopAndDestroy(&uids); break; } case EPbsGetPlayersUidsForType: { aMsgHandleResult = CreatePlayerUidsBufferL(aMessage); break; } case EPbsGetSubPlayerNamesByUid: { SetAsync(aMessage); iPlayer->SubPlayerNamesL(TUid::Uid(aMessage.Int0()),*this); break; } case EPbsSelectPlayerByType: { iPlayer->PluginHandler()->SelectPlayersL( static_cast<TMPXPlaybackPlayerType>(aMessage.Int0())); break; } case EPbsSelectPlayerByUid: { iPlayer->PluginHandler()->SelectPlayerL(TUid::Uid(aMessage.Int0())); break; } case EPbsSelectSubPlayer: { iPlayer->PluginHandler()->SelectSubPlayerL( TUid::Uid(aMessage.Int0()),aMessage.Int1()); break; } case EPbsClearPlayerSelection: { iPlayer->PluginHandler()->ClearSelectPlayersL(); break; } case EPbsGetSelection: { GetSelectionL(aMessage); break; } case EPbsPlayerFound: { aMsgHandleResult = iPlayer->PluginHandler()->PlayerFound(); break; } case EPbsGetPlayerType: { aMsgHandleResult = iPlayer->PluginHandler()->PluginType(); break; } case EPbsGetTypeName: { MPXUser::CreateBufferL(iPlayer->PluginHandler()->PlayerName(), iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); break; } case EPbsGetSubPlayerIndex: { aMsgHandleResult = iPlayer->PluginHandler()->SubPlayer(); break; } case EPbsGetPlayerUid: { TPckgC<TInt> uidPkg((iPlayer->PluginHandler()->PluginUid()).iUid); aMessage.Write(0,uidPkg); break; } case EPbsGetCollectionPlaylist: { aMsgHandleResult = 0; if (iPlayer->Playlist()) { ::CreateBufferL<CMPXCollectionPlaylist>(*(iPlayer->Playlist()), iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); } break; } case EPbsGetFile: { const RFile& file = iPlayer->File(); if (file.SubSessionHandle()) { aMsgHandleResult = file.TransferToClient(aMessage,0); //message completed } else { TPckgC<TInt> handle(KErrNotFound); aMessage.Write(0, handle); } break; } case EPbsGetUri: { aMsgHandleResult=0; if (iPlayer->Uri().Length()>0) { MPXUser::CreateBufferL(iPlayer->Uri(),iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); } break; } case EPbsGetMedia: { SetAsync( aMessage ); CMPXCommand* cmd( CMPXCommand::NewL( aMessage.Int1() ) ); CleanupStack::PushL( cmd ); iPlayer->MediaL( *this, *cmd ); CleanupStack::PopAndDestroy( cmd ); break; } case EPbsGetSupportedMimeTypes: { CDesCArray* mimeTypes = iPlayer->PluginHandler()->SupportedMimeTypesL(); CleanupStack::PushL(mimeTypes); MPXUser::CreateBufferL((const MDesCArray*)mimeTypes, iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); CleanupStack::PopAndDestroy(mimeTypes); } break; case EPbsGetSupportedExtensions: { CDesCArray* exts = iPlayer->PluginHandler()->SupportedExtensionsL(); CleanupStack::PushL(exts); MPXUser::CreateBufferL((const MDesCArray*)exts, iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); CleanupStack::PopAndDestroy(exts); } break; case EPbsGetSupportedSchemas: { CDesCArray* schemas = iPlayer->PluginHandler()->SupportedSchemasL(); CleanupStack::PushL(schemas); MPXUser::CreateBufferL((const MDesCArray*)schemas, iSyncBuffer); aMsgHandleResult = iSyncBuffer->Size(); CleanupStack::PopAndDestroy(schemas); } break; case EPbsGetNextMessage: { ASSERT(iMessageQueue); iMessageQueue->SendNext(aMessage); iCompleteRequest=EFalse; break; } case EPbsCancelGetMessage: { ASSERT(iMessageQueue); iMessageQueue->Reset(); break; } case EPbsCommand: { CMPXCommand* cmd( NULL ); ::NewFromMessageL<CMPXMedia>(aMessage, 1, cmd); CleanupStack::PushL(cmd); iPlayer->CommandL(*cmd, *iMessageQueue); CleanupStack::PopAndDestroy(cmd); break; } #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API case EPbsInitFromFile64: { RFile64 file; User::LeaveIfError(file.AdoptFromClient(aMessage,0,1)); iPlayer->Init64L(file); file.Close(); break; } case EPbsInitStreamingFromFile64: { RFile64 file; User::LeaveIfError(file.AdoptFromClient(aMessage,0,1)); iPlayer->InitStreaming64L(file, aMessage.Int2()); file.Close(); break; } case EPbsGetFile64: { const RFile64& file = iPlayer->File64(); if (file.SubSessionHandle()) { aMsgHandleResult = file.TransferToClient(aMessage,0); //message completed } else { TPckgC<TInt> handle(KErrNotFound); aMessage.Write(0, handle); } break; } #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API case EPbsSetPrimaryClient: { aMsgHandleResult = iPlayer->ClientList()->SetPrimaryClient(*iMessageQueue); break; } default: { PanicClient(aMessage,KErrNotSupported); break; } } MPX_DEBUG1("<---CMPXPlaybackSession::DispatchMessageL"); }