tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TextureWrapperImage.cpp (1624B)


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