/src/mozilla-central/gfx/webrender_bindings/RenderSharedSurfaceTextureHost.cpp
Line | Count | Source (jump to first uncovered line) |
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 "RenderSharedSurfaceTextureHost.h" |
8 | | |
9 | | #include "mozilla/gfx/Logging.h" |
10 | | #include "mozilla/layers/ImageDataSerializer.h" |
11 | | #include "mozilla/layers/SourceSurfaceSharedData.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace wr { |
15 | | |
16 | | RenderSharedSurfaceTextureHost::RenderSharedSurfaceTextureHost(gfx::SourceSurfaceSharedDataWrapper* aSurface) |
17 | | : mSurface(aSurface) |
18 | | , mMap() |
19 | | , mLocked(false) |
20 | 0 | { |
21 | 0 | MOZ_COUNT_CTOR_INHERITED(RenderSharedSurfaceTextureHost, RenderTextureHost); |
22 | 0 | MOZ_ASSERT(aSurface); |
23 | 0 | } |
24 | | |
25 | | RenderSharedSurfaceTextureHost::~RenderSharedSurfaceTextureHost() |
26 | 0 | { |
27 | 0 | MOZ_COUNT_DTOR_INHERITED(RenderSharedSurfaceTextureHost, RenderTextureHost); |
28 | 0 | } |
29 | | |
30 | | wr::WrExternalImage |
31 | | RenderSharedSurfaceTextureHost::Lock(uint8_t aChannelIndex, |
32 | | gl::GLContext* aGL, |
33 | | wr::ImageRendering aRendering) |
34 | 0 | { |
35 | 0 | if (!mLocked) { |
36 | 0 | if (NS_WARN_IF(!mSurface->Map(gfx::DataSourceSurface::MapType::READ_WRITE, |
37 | 0 | &mMap))) { |
38 | 0 | return InvalidToWrExternalImage(); |
39 | 0 | } |
40 | 0 | mLocked = true; |
41 | 0 | } |
42 | 0 |
|
43 | 0 | return RawDataToWrExternalImage(mMap.mData, |
44 | 0 | mMap.mStride * mSurface->GetSize().height); |
45 | 0 | } |
46 | | |
47 | | void |
48 | | RenderSharedSurfaceTextureHost::Unlock() |
49 | 0 | { |
50 | 0 | if (mLocked) { |
51 | 0 | mSurface->Unmap(); |
52 | 0 | mLocked = false; |
53 | 0 | } |
54 | 0 | } |
55 | | |
56 | | } // namespace wr |
57 | | } // namespace mozilla |