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"
13 using namespace mozilla::gfx
;
15 X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor
* aCompositor
, gfxXlibSurface
* aSurface
)
16 : mCompositor(aCompositor
),
22 X11TextureSourceBasic::GetSize() const
24 return ToIntSize(mSurface
->GetSize());
28 X11TextureSourceBasic::GetFormat() const
30 gfxContentType type
= mSurface
->GetContentType();
31 return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type
);
35 X11TextureSourceBasic::GetSurface(DrawTarget
* aTarget
)
37 if (!mSourceSurface
) {
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
;
49 X11TextureSourceBasic::SetCompositor(Compositor
* aCompositor
)
51 MOZ_ASSERT(aCompositor
->GetBackendType() == LayersBackend::LAYERS_BASIC
);
52 BasicCompositor
* compositor
= static_cast<BasicCompositor
*>(aCompositor
);
53 mCompositor
= compositor
;
57 X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType 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
;
67 return SurfaceFormat::UNKNOWN
;