WebRenderDrawEventRecorder.h (1641B)
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef MOZILLA_LAYERS_WEBRENDERDRAWTARGETRECORDER_H 7 #define MOZILLA_LAYERS_WEBRENDERDRAWTARGETRECORDER_H 8 9 #include "mozilla/gfx/DrawEventRecorder.h" 10 #include "mozilla/gfx/InlineTranslator.h" 11 #include "mozilla/webrender/webrender_ffi.h" 12 13 namespace mozilla { 14 namespace layers { 15 16 struct BlobFont { 17 wr::FontInstanceKey mFontInstanceKey; 18 gfx::ReferencePtr mScaledFontPtr; 19 }; 20 21 class WebRenderDrawEventRecorder final : public gfx::DrawEventRecorderMemory { 22 public: 23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebRenderDrawEventRecorder, final) 24 25 explicit WebRenderDrawEventRecorder( 26 const gfx::SerializeResourcesFn& aSerialize) 27 : DrawEventRecorderMemory(aSerialize) {} 28 29 gfx::RecorderType GetRecorderType() const final { 30 return gfx::RecorderType::WEBRENDER; 31 } 32 33 void StoreSourceSurfaceRecording(gfx::SourceSurface* aSurface, 34 const char* aReason) final; 35 36 private: 37 virtual ~WebRenderDrawEventRecorder() = default; 38 }; 39 40 class WebRenderTranslator final : public gfx::InlineTranslator { 41 public: 42 explicit WebRenderTranslator(gfx::DrawTarget* aDT, 43 void* aFontContext = nullptr) 44 : InlineTranslator(aDT, aFontContext) {} 45 46 already_AddRefed<gfx::SourceSurface> LookupExternalSurface( 47 uint64_t aKey) final; 48 }; 49 50 } // namespace layers 51 } // namespace mozilla 52 53 #endif