Bug 1883287 - Don't wait for the hidden window to be created on Linux to load the...
[gecko.git] / gfx / layers / TextureWrapperImage.cpp
blob152885d6d9bbdca0af6a7adccb48b25860982944
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 #include "TextureWrapperImage.h"
8 namespace mozilla {
9 namespace layers {
11 using namespace mozilla::gfx;
13 TextureWrapperImage::TextureWrapperImage(TextureClient* aClient,
14 const IntRect& aPictureRect)
15 : Image(nullptr, ImageFormat::TEXTURE_WRAPPER),
16 mPictureRect(aPictureRect),
17 mTextureClient(aClient) {}
19 TextureWrapperImage::~TextureWrapperImage() = default;
21 gfx::IntSize TextureWrapperImage::GetSize() const {
22 return mTextureClient->GetSize();
25 gfx::IntRect TextureWrapperImage::GetPictureRect() const {
26 return mPictureRect;
29 already_AddRefed<gfx::SourceSurface> TextureWrapperImage::GetAsSourceSurface() {
30 TextureClientAutoLock autoLock(mTextureClient, OpenMode::OPEN_READ);
31 if (!autoLock.Succeeded()) {
32 return nullptr;
35 RefPtr<DrawTarget> dt = mTextureClient->BorrowDrawTarget();
36 if (!dt) {
37 return nullptr;
40 return dt->Snapshot();
43 TextureClient* TextureWrapperImage::GetTextureClient(
44 KnowsCompositor* aKnowsCompositor) {
45 return mTextureClient;
48 void TextureWrapperImage::OnPrepareForwardToHost() {
49 mTextureClient->OnPrepareForwardToHost();
52 void TextureWrapperImage::OnAbandonForwardToHost() {
53 mTextureClient->OnAbandonForwardToHost();
56 } // namespace layers
57 } // namespace mozilla