1402 aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight); |
1419 aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight); |
1403 if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0)) |
1420 if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0)) |
1404 { |
1421 { |
1405 aCropRect.Intersection( iPicSize); |
1422 aCropRect.Intersection( iPicSize); |
1406 } |
1423 } |
1407 aPixelAspectRatio = TVideoAspectRatio(1,1); |
1424 aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom); |
1408 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL()-- \ |
1425 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \ |
1409 cropRectWidth = %d cropRectHeight = %d --"), this, aCropRect.Width(), aCropRect.Height()); |
1426 cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height()); |
1410 |
1427 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \ |
|
1428 PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator); |
|
1429 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this); |
1411 } |
1430 } |
1412 |
1431 |
1413 void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId) |
1432 void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId) |
1414 { |
1433 { |
1415 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this); |
1434 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this); |
1416 if(!aSurfaceId.IsNull()) |
1435 if(!aSurfaceId.IsNull()) |
1417 { |
1436 { |
1418 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId ); |
1437 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId ); |
1419 iWsSession.UnregisterSurface(0, iSurfaceId); |
1438 TInt numScreens = iWsSession.NumberOfScreens(); |
|
1439 for(TInt i=0;i < numScreens;i++) |
|
1440 { |
|
1441 iWsSession.UnregisterSurface(i, aSurfaceId); |
|
1442 } |
|
1443 iWsSession.Flush(); |
1420 iSurfaceHandler->DestroySurface(aSurfaceId); |
1444 iSurfaceHandler->DestroySurface(aSurfaceId); |
1421 } |
1445 if(iSurfaceId == aSurfaceId) |
1422 |
1446 { |
|
1447 iSurfaceCreatedEventPublished = EFalse; |
|
1448 iSurfaceId = TSurfaceId::CreateNullId(); |
|
1449 iChunk.Close(); |
|
1450 } |
|
1451 } |
1423 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this); |
1452 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this); |
1424 } |
1453 } |
1425 |
1454 |
1426 // === MMmfVideoPropertiesObserver === |
1455 // === MMmfVideoPropertiesObserver === |
1427 |
1456 |
1429 { |
1458 { |
1430 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this); |
1459 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this); |
1431 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \ |
1460 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \ |
1432 iAspectRatioNum = %d, iAspectRatioDenom = %d"), this, |
1461 iAspectRatioNum = %d, iAspectRatioDenom = %d"), this, |
1433 aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom); |
1462 aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom); |
1434 iPicSize = aPictureSize; |
1463 iPicSize = aPictureSize; |
|
1464 iAspectRatioNum = aYuvFormat.iAspectRatioNum; |
|
1465 iAspectRatioDenom = aYuvFormat.iAspectRatioDenom; |
1435 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \ |
1466 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \ |
1436 iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"), |
1467 iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"), |
1437 this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0); |
1468 this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0); |
1438 |
1469 |
1439 if(iVPObserver) |
1470 if(iVPObserver) |
1504 |
1540 |
1505 } |
1541 } |
1506 |
1542 |
1507 void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer) |
1543 void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer) |
1508 { |
1544 { |
1509 PP_DEBUG(_L("CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface ++"), this); |
1545 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this); |
1510 |
1546 |
1511 TSize surfaceSize; |
|
1512 TUint8* lPtr; |
1547 TUint8* lPtr; |
1513 TInt offset; |
1548 TInt offset; |
1514 if(iPicSize.iWidth > iPicSize.iHeight) |
1549 |
1515 { |
1550 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight); |
1516 surfaceSize.iWidth = iPicSize.iWidth; |
|
1517 surfaceSize.iHeight = iPicSize.iWidth; |
|
1518 } |
|
1519 else |
|
1520 { |
|
1521 surfaceSize.iWidth = iPicSize.iHeight; |
|
1522 surfaceSize.iHeight = iPicSize.iHeight; |
|
1523 } |
|
1524 |
1551 |
1525 TInt err = KErrNone; |
1552 TInt err = KErrNone; |
1526 SetSurfaceAttributes(surfaceSize, 1); |
1553 SetSurfaceAttributes(iPicSize, 1); |
1527 |
1554 |
1528 err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId); |
1555 err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId); |
1529 if (err != KErrNone) |
1556 if (err != KErrNone) |
1530 { |
1557 { |
1531 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"), |
1558 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"), |
1532 this, err); |
1559 this, err); |
1533 iProxy->MdvppFatalError(this, err); |
1560 iProxy->MdvppFatalError(this, err); |
1534 return; |
1561 return; |
1535 } |
1562 } |
|
1563 |
|
1564 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); |
|
1565 if (err != KErrNone) |
|
1566 { |
|
1567 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"), |
|
1568 this, err); |
|
1569 iSurfaceHandler->DestroySurface(iSurfaceId); |
|
1570 iSurfaceId = TSurfaceId::CreateNullId(); |
|
1571 iProxy->MdvppFatalError(this, err); |
|
1572 return; |
|
1573 } |
|
1574 |
|
1575 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \ |
|
1576 surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride); |
|
1577 |
|
1578 TInt redrawBufferSize = aRedrawBuffer.Size(); |
|
1579 TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight; |
|
1580 |
|
1581 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize); |
|
1582 |
|
1583 // Check whether redraw buffer will fit onto the surface. |
|
1584 // If this check fails then we won't raise a fatal error - We just won't create the redraw surface |
|
1585 if (redrawBufferSize > surfaceSize) |
|
1586 { |
|
1587 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this); |
|
1588 iSurfaceHandler->DestroySurface(iSurfaceId); |
|
1589 iSurfaceId = TSurfaceId::CreateNullId(); |
|
1590 return; |
|
1591 } |
|
1592 |
1536 err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk); |
1593 err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk); |
1537 if (err != KErrNone) |
1594 if (err != KErrNone) |
1538 { |
1595 { |
1539 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"), |
1596 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"), |
1540 this, err); |
1597 this, err); |
1541 iSurfaceHandler->DestroySurface(iSurfaceId); |
1598 iSurfaceHandler->DestroySurface(iSurfaceId); |
1542 iSurfaceId = TSurfaceId::CreateNullId(); |
1599 iSurfaceId = TSurfaceId::CreateNullId(); |
1543 iProxy->MdvppFatalError(this, err); |
1600 iProxy->MdvppFatalError(this, err); |
1544 return; |
1601 return; |
1545 } |
1602 } |
1546 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); |
|
1547 if (err != KErrNone) |
|
1548 { |
|
1549 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"), |
|
1550 this, err); |
|
1551 iSurfaceHandler->DestroySurface(iSurfaceId); |
|
1552 iSurfaceId = TSurfaceId::CreateNullId(); |
|
1553 iProxy->MdvppFatalError(this, err); |
|
1554 return; |
|
1555 } |
|
1556 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \ |
|
1557 surfaceWidth = %d surfaceHeight = %d --"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight); |
|
1558 |
1603 |
1559 if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone) |
1604 if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone) |
1560 { |
1605 { |
1561 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err); |
1606 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err); |
1562 iSurfaceHandler->DestroySurface(iSurfaceId); |
1607 iSurfaceHandler->DestroySurface(iSurfaceId); |
1563 iSurfaceId = TSurfaceId::CreateNullId(); |
1608 iSurfaceId = TSurfaceId::CreateNullId(); |
|
1609 iChunk.Close(); |
1564 iProxy->MdvppFatalError(this, err); |
1610 iProxy->MdvppFatalError(this, err); |
1565 return; |
1611 return; |
1566 } |
1612 } |
1567 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d aRedrawBuffer.Size()= %d --"), this, offset, aRedrawBuffer.Size()); |
1613 |
1568 |
1614 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset); |
|
1615 |
1569 lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset); |
1616 lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset); |
1570 memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), aRedrawBuffer.Size()); |
1617 memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize); |
1571 |
1618 |
|
1619 iRedrawSurfaceInUse = ETrue; |
|
1620 |
|
1621 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId); |
|
1622 |
1572 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err); |
1623 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err); |
1573 } |
1624 } |
1574 |
1625 |
1575 TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID) |
1626 TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID) |
1576 { |
1627 { |
|
1628 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID ); |
|
1629 |
1577 TInt err = KErrNone; |
1630 TInt err = KErrNone; |
1578 |
1631 |
1579 if(!iSurfaceId.IsNull()) |
1632 if(!iSurfaceId.IsNull()) |
1580 { |
1633 { |
1581 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface Cleaning ReDraw Surface"), this); |
1634 if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished) |
1582 iVideoSurfaceObserver->MmvsoRemoveSurface(); |
1635 { |
|
1636 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Telling client to remove old surface"), this); |
|
1637 iVideoSurfaceObserver->MmvsoRemoveSurface(); |
|
1638 iSurfaceCreatedEventPublished = EFalse; |
|
1639 } |
|
1640 else |
|
1641 { |
|
1642 // We never told the client about the surface, so we must destroy it ourselves |
|
1643 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this); |
|
1644 TInt numScreens = iWsSession.NumberOfScreens(); |
|
1645 for(TInt i=0;i < numScreens;i++) |
|
1646 { |
|
1647 iWsSession.UnregisterSurface(i, iSurfaceId); |
|
1648 } |
|
1649 iWsSession.Flush(); |
|
1650 iSurfaceHandler->DestroySurface(iSurfaceId); |
|
1651 } |
|
1652 |
|
1653 iChunk.Close(); |
1583 } |
1654 } |
1584 |
1655 |
1585 iSurfaceId = aSurfaceID; |
1656 iSurfaceId = aSurfaceID; |
1586 iUsingExternalSurface = ETrue; |
1657 iUsingExternalSurface = ETrue; |
1587 |
1658 iRedrawSurfaceInUse = EFalse; |
1588 |
1659 |
1589 // Create the surface handler if it doesn't exist. |
1660 // Create the surface handler if it doesn't exist. |
1590 if (!iSurfaceHandler) |
1661 if (!iSurfaceHandler) |
1591 { |
1662 { |
1592 TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL()); |
1663 TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL()); |
1593 if (err != KErrNone) |
1664 if (err != KErrNone) |