Bug 1521243 - Show a warning for invalid declarations and filter icon for overridden...
[gecko.git] / gfx / layers / SourceSurfaceVolatileData.cpp
blob2bd1ee5f864afe0243e0a9e9583f1945e3f55ecf
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
13 namespace mozilla {
14 namespace gfx {
16 bool SourceSurfaceVolatileData::Init(const IntSize& aSize, int32_t aStride,
17 SurfaceFormat aFormat) {
18 mSize = aSize;
19 mStride = aStride;
20 mFormat = aFormat;
22 size_t alignment = size_t(1) << gfxAlphaRecovery::GoodAlignmentLog2();
23 mVBuf = new VolatileBuffer();
24 if (MOZ_UNLIKELY(!mVBuf->Init(aStride * aSize.height, alignment))) {
25 mVBuf = nullptr;
26 return false;
29 return true;
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 {
39 if (mVBuf) {
40 aHeapSizeOut += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf);
41 aNonHeapSizeOut += mVBuf->NonHeapSizeOfExcludingThis();
42 #ifdef ANDROID
43 if (!mVBuf->OnHeap()) {
44 // Volatile buffers keep a file handle open on Android.
45 ++aExtHandlesOut;
47 #endif
51 } // namespace gfx
52 } // namespace mozilla