gfx/layers/basic/X11TextureSourceBasic.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "X11TextureSourceBasic.h"
michael@0 7 #include "mozilla/layers/BasicCompositor.h"
michael@0 8 #include "gfxXlibSurface.h"
michael@0 9 #include "gfx2DGlue.h"
michael@0 10
michael@0 11 using namespace mozilla;
michael@0 12 using namespace mozilla::layers;
michael@0 13 using namespace mozilla::gfx;
michael@0 14
michael@0 15 X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
michael@0 16 : mCompositor(aCompositor),
michael@0 17 mSurface(aSurface)
michael@0 18 {
michael@0 19 }
michael@0 20
michael@0 21 IntSize
michael@0 22 X11TextureSourceBasic::GetSize() const
michael@0 23 {
michael@0 24 return ToIntSize(mSurface->GetSize());
michael@0 25 }
michael@0 26
michael@0 27 SurfaceFormat
michael@0 28 X11TextureSourceBasic::GetFormat() const
michael@0 29 {
michael@0 30 gfxContentType type = mSurface->GetContentType();
michael@0 31 return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
michael@0 32 }
michael@0 33
michael@0 34 SourceSurface*
michael@0 35 X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
michael@0 36 {
michael@0 37 if (!mSourceSurface) {
michael@0 38 NativeSurface surf;
michael@0 39 surf.mFormat = GetFormat();
michael@0 40 surf.mType = NativeSurfaceType::CAIRO_SURFACE;
michael@0 41 surf.mSurface = mSurface->CairoSurface();
michael@0 42 surf.mSize = GetSize();
michael@0 43 mSourceSurface = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
michael@0 44 }
michael@0 45 return mSourceSurface;
michael@0 46 }
michael@0 47
michael@0 48 void
michael@0 49 X11TextureSourceBasic::SetCompositor(Compositor* aCompositor)
michael@0 50 {
michael@0 51 MOZ_ASSERT(aCompositor->GetBackendType() == LayersBackend::LAYERS_BASIC);
michael@0 52 BasicCompositor* compositor = static_cast<BasicCompositor*>(aCompositor);
michael@0 53 mCompositor = compositor;
michael@0 54 }
michael@0 55
michael@0 56 SurfaceFormat
michael@0 57 X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
michael@0 58 {
michael@0 59 switch (aType) {
michael@0 60 case gfxContentType::COLOR:
michael@0 61 return SurfaceFormat::B8G8R8X8;
michael@0 62 case gfxContentType::ALPHA:
michael@0 63 return SurfaceFormat::A8;
michael@0 64 case gfxContentType::COLOR_ALPHA:
michael@0 65 return SurfaceFormat::B8G8R8A8;
michael@0 66 default:
michael@0 67 return SurfaceFormat::UNKNOWN;
michael@0 68 }
michael@0 69 }

mercurial