VirtualBox

Changeset 24539 in vbox


Ignore:
Timestamp:
Nov 10, 2009 11:59:03 AM (15 years ago)
Author:
vboxsync
Message:

Saved state screenshot API (xTracker 4364).

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r24490 r24539  
    666666    AssertRCReturn(rc, rc);
    667667
    668 #if 0
    669668    /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
    670669    rc = SSMR3RegisterExternal(pVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
     
    674673
    675674    AssertRCReturn(rc, rc);
    676 #endif
    677675
    678676    return VINF_SUCCESS;
  • trunk/src/VBox/Main/MachineImpl.cpp

    r24528 r24539  
    39233923static int readSavedDisplayScreenshot(Utf8Str *pStateFilePath, uint32_t u32Type, uint8_t **ppu8Data, uint32_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height)
    39243924{
     3925    LogFlowFunc(("u32Type = %d [%s]\n", u32Type, pStateFilePath->raw()));
     3926
    39253927    /* @todo cache read data */
    39263928    if (pStateFilePath->isEmpty())
     
    39843986                            /* No saved state data. */
    39853987                            rc = VERR_NOT_SUPPORTED;
    3986                             break;
    39873988                        }
     3989
     3990                        break;
    39883991                    }
    39893992                    else
     
    40214024        *pu32Width = u32Width;
    40224025        *pu32Height = u32Height;
    4023     }
    4024 
     4026        LogFlowFunc(("cbData %d, u32Width %d, u32Height %d\n", cbData, u32Width, u32Height));
     4027    }
     4028
     4029    LogFlowFunc(("rc %Rrc\n", rc));
    40254030    return rc;
    40264031}
     
    40564061                         tr("Saved screenshot data is not available (%Rrc)"), vrc);
    40574062
     4063    *aSize = cbData;
     4064    *aWidth = u32Width;
     4065    *aHeight = u32Height;
     4066
    40584067    freeSavedDisplayScreenshot(pu8Data);
    40594068
     
    40614070}
    40624071
    4063 STDMETHODIMP Machine::ReadSavedThumbnail(BYTE *aAddress, ULONG aSize)
     4072STDMETHODIMP Machine::ReadSavedThumbnailToArray(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData))
    40644073{
    40654074    LogFlowThisFunc(("\n"));
    40664075
    4067     CheckComArgNotNull(aAddress);
     4076    CheckComArgNotNull(aWidth);
     4077    CheckComArgNotNull(aHeight);
     4078    CheckComArgExpr(aData, !ComSafeArrayOutIsNull(aData));
    40684079
    40694080    AutoCaller autoCaller(this);
     
    40824093        return setError (VBOX_E_IPRT_ERROR,
    40834094                         tr("Saved screenshot data is not available (%Rrc)"), vrc);
    4084     if (aSize != cbData)
    4085         return setError (E_INVALIDARG,
    4086                          tr("Invalid size of data buffer: %d"), aSize);
    4087 
    4088     memcpy(aAddress, pu8Data, cbData);
     4095
     4096    *aWidth = u32Width;
     4097    *aHeight = u32Height;
     4098
     4099    com::SafeArray<BYTE> bitmap(cbData);
     4100    /* Convert pixels to format expected by the API caller. */
     4101    if (aBGR)
     4102    {
     4103        /* [0] B, [1] G, [2] R, [3] A. */
     4104        for (unsigned i = 0; i < cbData; i += 4)
     4105        {
     4106            bitmap[i]     = pu8Data[i];
     4107            bitmap[i + 1] = pu8Data[i + 1];
     4108            bitmap[i + 2] = pu8Data[i + 2];
     4109            bitmap[i + 3] = 0xff;
     4110        }
     4111    }
     4112    else
     4113    {
     4114        /* [0] R, [1] G, [2] B, [3] A. */
     4115        for (unsigned i = 0; i < cbData; i += 4)
     4116        {
     4117            bitmap[i]     = pu8Data[i + 2];
     4118            bitmap[i + 1] = pu8Data[i + 1];
     4119            bitmap[i + 2] = pu8Data[i];
     4120            bitmap[i + 3] = 0xff;
     4121        }
     4122    }
     4123    bitmap.detachTo(ComSafeArrayOutArg(aData));
    40894124
    40904125    freeSavedDisplayScreenshot(pu8Data);
     
    40934128}
    40944129
    4095 STDMETHODIMP Machine::ReadSavedThumbnailToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData))
     4130STDMETHODIMP Machine::QuerySavedScreenshotPNGSize(ULONG *aSize, ULONG *aWidth, ULONG *aHeight)
    40964131{
    40974132    LogFlowThisFunc(("\n"));
    40984133
     4134    CheckComArgNotNull(aSize);
    40994135    CheckComArgNotNull(aWidth);
    41004136    CheckComArgNotNull(aHeight);
    4101     CheckComArgSafeArrayNotNull(aData);
    41024137
    41034138    AutoCaller autoCaller(this);
     
    41114146    uint32_t u32Height = 0;
    41124147
    4113     int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 0 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);
     4148    int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);
    41144149
    41154150    if (RT_FAILURE(vrc))
     
    41174152                         tr("Saved screenshot data is not available (%Rrc)"), vrc);
    41184153
     4154    *aSize = cbData;
    41194155    *aWidth = u32Width;
    41204156    *aHeight = u32Height;
    41214157
    4122     com::SafeArray<BYTE> bitmap(cbData);
    4123     /* Convert pixels to format expected by the API caller: [0] R, [1] G, [2] B, [3] A. */
    4124     for (unsigned i = 0; i < cbData; i += 4)
    4125     {
    4126         bitmap[i]     = pu8Data[i + 2];
    4127         bitmap[i + 1] = pu8Data[i + 1];
    4128         bitmap[i + 2] = pu8Data[i];
    4129         bitmap[i + 3] = 0xff;
    4130     }
    4131     bitmap.detachTo(ComSafeArrayOutArg(aData));
    4132 
    41334158    freeSavedDisplayScreenshot(pu8Data);
    41344159
     
    41364161}
    41374162
    4138 STDMETHODIMP Machine::QuerySavedScreenshotPNGSize(ULONG *aSize, ULONG *aWidth, ULONG *aHeight)
     4163STDMETHODIMP Machine::ReadSavedScreenshotPNGToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData))
    41394164{
    41404165    LogFlowThisFunc(("\n"));
    41414166
    4142     CheckComArgNotNull(aSize);
    41434167    CheckComArgNotNull(aWidth);
    41444168    CheckComArgNotNull(aHeight);
    4145 
    4146     AutoCaller autoCaller(this);
    4147     CheckComRCReturnRC(autoCaller.rc());
    4148 
    4149     AutoReadLock alock(this);
    4150 
    4151     uint8_t *pu8Data = NULL;
    4152     uint32_t cbData = 0;
    4153     uint32_t u32Width = 0;
    4154     uint32_t u32Height = 0;
    4155 
    4156     int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);
    4157 
    4158     if (RT_FAILURE(vrc))
    4159         return setError (VBOX_E_IPRT_ERROR,
    4160                          tr("Saved screenshot data is not available (%Rrc)"), vrc);
    4161 
    4162     freeSavedDisplayScreenshot(pu8Data);
    4163 
    4164     return S_OK;
    4165 }
    4166 
    4167 STDMETHODIMP Machine::ReadSavedScreenshotPNG(BYTE *aAddress, ULONG aSize)
    4168 {
    4169     LogFlowThisFunc(("\n"));
    4170 
    4171     CheckComArgNotNull(aAddress);
    4172 
    4173     AutoCaller autoCaller(this);
    4174     CheckComRCReturnRC(autoCaller.rc());
    4175 
    4176     AutoReadLock alock(this);
    4177 
    4178     uint8_t *pu8Data = NULL;
    4179     uint32_t cbData = 0;
    4180     uint32_t u32Width = 0;
    4181     uint32_t u32Height = 0;
    4182 
    4183     int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);
    4184 
    4185     if (RT_FAILURE(vrc))
    4186         return setError (VBOX_E_IPRT_ERROR,
    4187                          tr("Saved screenshot data is not available (%Rrc)"), vrc);
    4188     if (aSize != cbData)
    4189         return setError (E_INVALIDARG,
    4190                          tr("Invalid size of data buffer: %d"), aSize);
    4191 
    4192     memcpy(aAddress, pu8Data, cbData);
    4193 
    4194     freeSavedDisplayScreenshot(pu8Data);
    4195 
    4196     return S_OK;
    4197 }
    4198 
    4199 STDMETHODIMP Machine::ReadSavedScreenshotPNGToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData))
    4200 {
    4201     LogFlowThisFunc(("\n"));
    4202 
    4203     CheckComArgNotNull(aWidth);
    4204     CheckComArgNotNull(aHeight);
    4205     CheckComArgSafeArrayNotNull(aData);
     4169    CheckComArgExpr(aData, !ComSafeArrayOutIsNull(aData));
    42064170
    42074171    AutoCaller autoCaller(this);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r24526 r24539  
    41054105  <interface
    41064106     name="IMachine" extends="$unknown"
    4107      uuid="c5669e1a-491a-4367-99c6-28110dd474c6"
     4107     uuid="99404f50-dd10-40d3-889b-dd2f79f1e95e"
    41084108     wsmap="managed"
    41094109     >
     
    57965796    </method>
    57975797
    5798     <method name="readSavedThumbnail">
    5799       <desc>
    5800         Reads a saved thumbnail bitmap from saved state.
    5801         A pixel consists of 4 bytes in order: B, G, R, 0.
    5802 
    5803         <note>This API can be used only by the COM/XPCOM C++ API as it
    5804             requires pointer support. Use <link to="#readSavedThumbnailToArray" />
    5805             with other language bindings.
    5806         </note>
    5807       </desc>
    5808       <param name="address" type="octet" mod="ptr" dir="in">
    5809         <desc>
    5810           Buffer allocated by caller. Size must be at least equal
    5811           to value returned by querySavedThumbnailSize.
    5812         </desc>
    5813       </param>
    5814       <param name="size" type="unsigned long" dir="in">
    5815         <desc>
    5816           Size of buffer allocated by caller. If the buffer is too small,
    5817           the method fails.
    5818         </desc>
    5819       </param>
    5820     </method>
    5821 
    58225798    <method name="readSavedThumbnailToArray">
    58235799      <desc>
    5824         Thumbnail is retrieved to an array of bytes in uncompressed 32-bit RGBA format.
    5825         A pixel consists of 4 bytes in order: R, G, B, 0xFF.
    5826 
    5827         This API is slow, but could be the only option to get image
    5828         for scriptable languages not allowed to manipulate with addresses
    5829         directly.
    5830       </desc>
     5800        Thumbnail is retrieved to an array of bytes in uncompressed 32-bit BGRA or RGBA format.
     5801      </desc>
     5802      <param name="BGR" type="boolean" dir="in">
     5803        <desc>
     5804          How to order bytes in the pixel. A pixel consists of 4 bytes. If this parameter is true, then
     5805          bytes order is: B, G, R, 0xFF. If this parameter is false, then bytes order is: R, G, B, 0xFF.
     5806        </desc>
     5807      </param>
    58315808      <param name="width" type="unsigned long" dir="out">
    58325809        <desc>
     
    58675844    </method>
    58685845
    5869     <method name="readSavedScreenshotPNG">
    5870       <desc>
    5871         Reads a saved screenshot in PNG format from saved state.
    5872 
    5873         <note>This API can be used only by the COM/XPCOM C++ API as it
    5874             requires pointer support. Use <link to="#readSavedScreenshotPNGToArray" />
    5875             with other language bindings.
    5876         </note>
    5877       </desc>
    5878       <param name="address" type="octet" mod="ptr" dir="in">
    5879         <desc>
    5880           Buffer allocated by caller. Size must be at least equal
    5881           to value returned by querySavedScreenshotPNGSize.
    5882         </desc>
    5883       </param>
    5884       <param name="size" type="unsigned long" dir="in">
    5885         <desc>
    5886           Size of buffer allocated by caller. If the buffer is too small,
    5887           the method fails.
    5888         </desc>
    5889       </param>
    5890     </method>
    5891 
    58925846    <method name="readSavedScreenshotPNGToArray">
    58935847      <desc>
    58945848        Screenshot in PNG format is retrieved to an array of bytes.
    5895 
    5896         This API is slow, but could be the only option to get image
    5897         for scriptable languages not allowed to manipulate with addresses
    5898         directly.
    58995849      </desc>
    59005850      <param name="width" type="unsigned long" dir="out">
  • trunk/src/VBox/Main/include/MachineImpl.h

    r24493 r24539  
    630630
    631631    STDMETHOD(QuerySavedThumbnailSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
    632     STDMETHOD(ReadSavedThumbnail)(BYTE *aAddress, ULONG aSize);
    633     STDMETHOD(ReadSavedThumbnailToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
     632    STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
    634633    STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
    635     STDMETHOD(ReadSavedScreenshotPNG)(BYTE *aAddress, ULONG aSize);
    636634    STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
    637635
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette