Line data Source code
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/. */
5 :
6 : #include "X11TextureSourceBasic.h"
7 : #include "gfxXlibSurface.h"
8 : #include "gfx2DGlue.h"
9 :
10 : namespace mozilla {
11 : namespace layers {
12 :
13 : using namespace mozilla::gfx;
14 :
15 0 : X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
16 0 : : mSurface(aSurface)
17 : {
18 0 : }
19 :
20 : IntSize
21 0 : X11TextureSourceBasic::GetSize() const
22 : {
23 0 : return mSurface->GetSize();
24 : }
25 :
26 : SurfaceFormat
27 0 : X11TextureSourceBasic::GetFormat() const
28 : {
29 0 : gfxContentType type = mSurface->GetContentType();
30 0 : return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
31 : }
32 :
33 : SourceSurface*
34 0 : X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
35 : {
36 0 : if (!mSourceSurface) {
37 : mSourceSurface =
38 0 : Factory::CreateSourceSurfaceForCairoSurface(mSurface->CairoSurface(),
39 0 : GetSize(), GetFormat());
40 : }
41 0 : return mSourceSurface;
42 : }
43 :
44 : SurfaceFormat
45 0 : X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
46 : {
47 0 : switch (aType) {
48 : case gfxContentType::COLOR:
49 0 : return SurfaceFormat::B8G8R8X8;
50 : case gfxContentType::ALPHA:
51 0 : return SurfaceFormat::A8;
52 : case gfxContentType::COLOR_ALPHA:
53 0 : return SurfaceFormat::B8G8R8A8;
54 : default:
55 0 : return SurfaceFormat::UNKNOWN;
56 : }
57 : }
58 :
59 : }
60 : }
|