TextureRecorded.h (2604B)
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 https://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_layers_TextureRecorded_h 8 #define mozilla_layers_TextureRecorded_h 9 10 #include "TextureClient.h" 11 #include "mozilla/layers/CanvasChild.h" 12 #include "mozilla/layers/LayersTypes.h" 13 14 namespace mozilla { 15 namespace layers { 16 17 class RecordedTextureData final : public TextureData { 18 public: 19 RecordedTextureData(already_AddRefed<CanvasChild> aCanvasChild, 20 gfx::IntSize aSize, gfx::SurfaceFormat aFormat, 21 TextureType aTextureType, 22 TextureType aWebglTextureType = TextureType::Unknown); 23 24 void FillInfo(TextureData::Info& aInfo) const final; 25 26 void InvalidateContents() final; 27 28 bool Lock(OpenMode aMode) final; 29 30 void Unlock() final; 31 32 already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() final; 33 34 void EndDraw() final; 35 36 void ReturnDrawTarget(already_AddRefed<gfx::DrawTarget> aDT) final; 37 38 already_AddRefed<gfx::SourceSurface> BorrowSnapshot() final; 39 40 void ReturnSnapshot(already_AddRefed<gfx::SourceSurface> aSnapshot) final; 41 42 void Deallocate(LayersIPCChannel* aAllocator) final; 43 44 bool Serialize(SurfaceDescriptor& aDescriptor) final; 45 46 void OnForwardedToHost() final; 47 48 TextureFlags GetTextureFlags() const final; 49 50 bool RequiresRefresh() const final; 51 52 already_AddRefed<FwdTransactionTracker> UseCompositableForwarder( 53 CompositableForwarder* aForwarder) final; 54 55 RecordedTextureData* AsRecordedTextureData() final { return this; } 56 57 const RemoteTextureOwnerId mRemoteTextureOwnerId; 58 59 protected: 60 friend class gfx::DrawTargetRecording; 61 62 void DrawTargetWillChange(); 63 64 private: 65 DISALLOW_COPY_AND_ASSIGN(RecordedTextureData); 66 67 ~RecordedTextureData() override; 68 69 void DetachSnapshotWrapper(bool aInvalidate = false, bool aRelease = true); 70 71 RefPtr<CanvasChild> mCanvasChild; 72 gfx::IntSize mSize; 73 gfx::SurfaceFormat mFormat; 74 RefPtr<gfx::DrawTargetRecording> mDT; 75 RefPtr<gfx::SourceSurface> mSnapshot; 76 RefPtr<gfx::SourceSurface> mSnapshotWrapper; 77 OpenMode mLockedMode; 78 RemoteTextureId mLastRemoteTextureId; 79 RefPtr<layers::FwdTransactionTracker> mFwdTransactionTracker; 80 bool mUsedRemoteTexture = false; 81 bool mInvalidContents = true; 82 bool mInited = false; 83 }; 84 85 } // namespace layers 86 } // namespace mozilla 87 88 #endif // mozilla_layers_TextureRecorded_h