tor-browser

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

CompositableHost.cpp (2073B)


      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 #include "CompositableHost.h"
      8 #include "Effects.h"  // for EffectMask, Effect, etc
      9 #include "gfxUtils.h"
     10 #include "mozilla/gfx/gfxVars.h"
     11 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
     12 #include "mozilla/layers/TextureHost.h"     // for TextureHost, etc
     13 #include "mozilla/layers/WebRenderImageHost.h"
     14 #include "mozilla/RefPtr.h"   // for nsRefPtr
     15 #include "nsDebug.h"          // for NS_WARNING
     16 #include "nsISupportsImpl.h"  // for MOZ_COUNT_CTOR, etc
     17 #include "gfxPlatform.h"      // for gfxPlatform
     18 #include "IPDLActor.h"
     19 
     20 namespace mozilla {
     21 
     22 using namespace gfx;
     23 
     24 namespace layers {
     25 
     26 class Compositor;
     27 
     28 CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
     29    : mTextureInfo(aTextureInfo) {
     30  MOZ_COUNT_CTOR(CompositableHost);
     31 }
     32 
     33 CompositableHost::~CompositableHost() { MOZ_COUNT_DTOR(CompositableHost); }
     34 
     35 void CompositableHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures) {
     36 }
     37 
     38 void CompositableHost::RemoveTextureHost(TextureHost* aTexture) {}
     39 
     40 /* static */
     41 already_AddRefed<CompositableHost> CompositableHost::Create(
     42    const TextureInfo& aTextureInfo) {
     43  RefPtr<CompositableHost> result;
     44  switch (aTextureInfo.mCompositableType) {
     45    case CompositableType::IMAGE:
     46      result = new WebRenderImageHost(aTextureInfo);
     47      break;
     48    default:
     49      NS_ERROR("Unknown CompositableType");
     50  }
     51  return result.forget();
     52 }
     53 
     54 void CompositableHost::DumpTextureHost(std::stringstream& aStream,
     55                                       TextureHost* aTexture) {
     56  if (!aTexture) {
     57    return;
     58  }
     59  RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
     60  if (!dSurf) {
     61    return;
     62  }
     63  aStream << gfxUtils::GetAsDataURI(dSurf).get();
     64 }
     65 
     66 }  // namespace layers
     67 }  // namespace mozilla