1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SourceSurfaceVolatileData.h"
9 #include "gfxAlphaRecovery.h"
10 #include "mozilla/Likely.h"
11 #include "mozilla/Types.h" // for decltype
16 bool SourceSurfaceVolatileData::Init(const IntSize
& aSize
, int32_t aStride
,
17 SurfaceFormat aFormat
) {
22 size_t alignment
= size_t(1) << gfxAlphaRecovery::GoodAlignmentLog2();
23 mVBuf
= new VolatileBuffer();
24 if (MOZ_UNLIKELY(!mVBuf
->Init(aStride
* aSize
.height
, alignment
))) {
32 void SourceSurfaceVolatileData::GuaranteePersistance() {
33 MOZ_ASSERT_UNREACHABLE("Should use SourceSurfaceRawData wrapper!");
36 void SourceSurfaceVolatileData::AddSizeOfExcludingThis(
37 MallocSizeOf aMallocSizeOf
, size_t& aHeapSizeOut
, size_t& aNonHeapSizeOut
,
38 size_t& aExtHandlesOut
, uint64_t& aExtIdOut
) const {
40 aHeapSizeOut
+= mVBuf
->HeapSizeOfExcludingThis(aMallocSizeOf
);
41 aNonHeapSizeOut
+= mVBuf
->NonHeapSizeOfExcludingThis();
43 if (!mVBuf
->OnHeap()) {
44 // Volatile buffers keep a file handle open on Android.
52 } // namespace mozilla