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 #include "TextureWrapperImage.h" 6 7 namespace mozilla { 8 namespace layers { 9 10 using namespace mozilla::gfx; 11 TextureWrapperImage(TextureClient * aClient,const IntRect & aPictureRect)12TextureWrapperImage::TextureWrapperImage(TextureClient* aClient, const IntRect& aPictureRect) 13 : Image(nullptr, ImageFormat::TEXTURE_WRAPPER), 14 mPictureRect(aPictureRect), 15 mTextureClient(aClient) 16 { 17 } 18 ~TextureWrapperImage()19TextureWrapperImage::~TextureWrapperImage() 20 { 21 } 22 23 gfx::IntSize GetSize()24TextureWrapperImage::GetSize() 25 { 26 return mTextureClient->GetSize(); 27 } 28 29 gfx::IntRect GetPictureRect()30TextureWrapperImage::GetPictureRect() 31 { 32 return mPictureRect; 33 } 34 35 already_AddRefed<gfx::SourceSurface> GetAsSourceSurface()36TextureWrapperImage::GetAsSourceSurface() 37 { 38 TextureClientAutoLock autoLock(mTextureClient, OpenMode::OPEN_READ); 39 if (!autoLock.Succeeded()) { 40 return nullptr; 41 } 42 43 RefPtr<DrawTarget> dt = mTextureClient->BorrowDrawTarget(); 44 if (!dt) { 45 return nullptr; 46 } 47 48 return dt->Snapshot(); 49 } 50 51 TextureClient* GetTextureClient(KnowsCompositor * aForwarder)52TextureWrapperImage::GetTextureClient(KnowsCompositor* aForwarder) 53 { 54 return mTextureClient; 55 } 56 57 } // namespace layers 58 } // namespace mozilla 59