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