Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / basic / X11TextureSourceBasic.cpp
blob4eb06890829dd62812af163da10951dca2526a8e
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/. */
6 #include "X11TextureSourceBasic.h"
7 #include "gfxXlibSurface.h"
8 #include "gfx2DGlue.h"
10 namespace mozilla {
11 namespace layers {
13 using namespace mozilla::gfx;
15 X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
16 : mCompositor(aCompositor),
17 mSurface(aSurface)
21 IntSize
22 X11TextureSourceBasic::GetSize() const
24 return ToIntSize(mSurface->GetSize());
27 SurfaceFormat
28 X11TextureSourceBasic::GetFormat() const
30 gfxContentType type = mSurface->GetContentType();
31 return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
34 SourceSurface*
35 X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
37 if (!mSourceSurface) {
38 NativeSurface surf;
39 surf.mFormat = GetFormat();
40 surf.mType = NativeSurfaceType::CAIRO_SURFACE;
41 surf.mSurface = mSurface->CairoSurface();
42 surf.mSize = GetSize();
43 mSourceSurface = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
45 return mSourceSurface;
48 void
49 X11TextureSourceBasic::SetCompositor(Compositor* aCompositor)
51 MOZ_ASSERT(aCompositor->GetBackendType() == LayersBackend::LAYERS_BASIC);
52 BasicCompositor* compositor = static_cast<BasicCompositor*>(aCompositor);
53 mCompositor = compositor;
56 SurfaceFormat
57 X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
59 switch (aType) {
60 case gfxContentType::COLOR:
61 return SurfaceFormat::B8G8R8X8;
62 case gfxContentType::ALPHA:
63 return SurfaceFormat::A8;
64 case gfxContentType::COLOR_ALPHA:
65 return SurfaceFormat::B8G8R8A8;
66 default:
67 return SurfaceFormat::UNKNOWN;