AsyncImagePipelineOp.h (2720B)
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_AsyncImagePipelineOp_H 8 #define MOZILLA_GFX_AsyncImagePipelineOp_H 9 10 #include <queue> 11 12 #include "mozilla/layers/TextureHost.h" 13 #include "mozilla/webrender/webrender_ffi.h" 14 #include "Units.h" 15 16 namespace mozilla { 17 18 namespace wr { 19 struct Transaction; 20 } // namespace wr 21 22 namespace layers { 23 24 class AsyncImagePipelineManager; 25 class TextureHost; 26 27 class AsyncImagePipelineOp { 28 public: 29 enum class Tag { 30 ApplyAsyncImageForPipeline, 31 RemoveAsyncImagePipeline, 32 }; 33 34 const Tag mTag; 35 36 AsyncImagePipelineManager* const mAsyncImageManager; 37 const wr::PipelineId mPipelineId; 38 const CompositableTextureHostRef mTextureHost; 39 40 private: 41 AsyncImagePipelineOp(const Tag aTag, 42 AsyncImagePipelineManager* aAsyncImageManager, 43 const wr::PipelineId& aPipelineId, 44 TextureHost* aTextureHost) 45 : mTag(aTag), 46 mAsyncImageManager(aAsyncImageManager), 47 mPipelineId(aPipelineId), 48 mTextureHost(aTextureHost) { 49 MOZ_ASSERT(mTag == Tag::ApplyAsyncImageForPipeline); 50 } 51 52 AsyncImagePipelineOp(const Tag aTag, 53 AsyncImagePipelineManager* aAsyncImageManager, 54 const wr::PipelineId& aPipelineId) 55 : mTag(aTag), 56 mAsyncImageManager(aAsyncImageManager), 57 mPipelineId(aPipelineId) { 58 MOZ_ASSERT(mTag == Tag::RemoveAsyncImagePipeline); 59 } 60 61 public: 62 static AsyncImagePipelineOp ApplyAsyncImageForPipeline( 63 AsyncImagePipelineManager* aAsyncImageManager, 64 const wr::PipelineId& aPipelineId, TextureHost* aTextureHost) { 65 return AsyncImagePipelineOp(Tag::ApplyAsyncImageForPipeline, 66 aAsyncImageManager, aPipelineId, aTextureHost); 67 } 68 69 static AsyncImagePipelineOp RemoveAsyncImagePipeline( 70 AsyncImagePipelineManager* aAsyncImageManager, 71 const wr::PipelineId& aPipelineId) { 72 return AsyncImagePipelineOp(Tag::RemoveAsyncImagePipeline, 73 aAsyncImageManager, aPipelineId); 74 } 75 }; 76 77 struct AsyncImagePipelineOps { 78 explicit AsyncImagePipelineOps(wr::Transaction* aTransaction) 79 : mTransaction(aTransaction) {} 80 81 void HandleOps(wr::TransactionBuilder& aTxn); 82 83 wr::Transaction* const mTransaction; 84 std::queue<AsyncImagePipelineOp> mList; 85 }; 86 87 } // namespace layers 88 } // namespace mozilla 89 90 #endif // MOZILLA_GFX_AsyncImagePipelineOp_H