RenderCompositorRecordedFrame.h (1436B)
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/. */ 6 7 #ifndef MOZILLA_GFX_RENDERCOMPOSITOR_RECORDEDFRAME_H 8 #define MOZILLA_GFX_RENDERCOMPOSITOR_RECORDEDFRAME_H 9 10 #include "mozilla/layers/CompositionRecorder.h" 11 12 namespace mozilla { 13 14 namespace wr { 15 16 class RenderCompositorRecordedFrame final : public layers::RecordedFrame { 17 public: 18 RenderCompositorRecordedFrame( 19 const TimeStamp& aTimeStamp, 20 RefPtr<layers::profiler_screenshots::AsyncReadbackBuffer>&& aBuffer) 21 : RecordedFrame(aTimeStamp), mBuffer(aBuffer) {} 22 23 virtual already_AddRefed<gfx::DataSourceSurface> GetSourceSurface() override { 24 if (mSurface) { 25 return do_AddRef(mSurface); 26 } 27 28 gfx::IntSize size = mBuffer->Size(); 29 mSurface = gfx::Factory::CreateDataSourceSurface( 30 size, gfx::SurfaceFormat::B8G8R8A8, 31 /* aZero = */ false); 32 33 if (!mBuffer->MapAndCopyInto(mSurface, size)) { 34 mSurface = nullptr; 35 return nullptr; 36 } 37 38 return do_AddRef(mSurface); 39 } 40 41 private: 42 RefPtr<layers::profiler_screenshots::AsyncReadbackBuffer> mBuffer; 43 RefPtr<gfx::DataSourceSurface> mSurface; 44 }; 45 46 } // namespace wr 47 } // namespace mozilla 48 49 #endif