/src/mozilla-central/gfx/webrender_bindings/RenderTextureHostWrapper.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 "RenderTextureHostWrapper.h" |
8 | | |
9 | | #include "mozilla/gfx/Logging.h" |
10 | | #include "mozilla/layers/ImageDataSerializer.h" |
11 | | #include "mozilla/layers/SourceSurfaceSharedData.h" |
12 | | #include "mozilla/webrender/RenderThread.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace wr { |
16 | | |
17 | | RenderTextureHostWrapper::RenderTextureHostWrapper() |
18 | | : mInited(false) |
19 | | , mLocked(false) |
20 | 0 | { |
21 | 0 | MOZ_COUNT_CTOR_INHERITED(RenderTextureHostWrapper, RenderTextureHost); |
22 | 0 | } |
23 | | |
24 | | RenderTextureHostWrapper::~RenderTextureHostWrapper() |
25 | 0 | { |
26 | 0 | MOZ_COUNT_DTOR_INHERITED(RenderTextureHostWrapper, RenderTextureHost); |
27 | 0 | } |
28 | | |
29 | | wr::WrExternalImage |
30 | | RenderTextureHostWrapper::Lock(uint8_t aChannelIndex, |
31 | | gl::GLContext* aGL, |
32 | | wr::ImageRendering aRendering) |
33 | 0 | { |
34 | 0 | if (!mTextureHost) { |
35 | 0 | MOZ_ASSERT_UNREACHABLE("unexpected to happen"); |
36 | 0 | return InvalidToWrExternalImage(); |
37 | 0 | } |
38 | 0 |
|
39 | 0 | mLocked = true; |
40 | 0 | return mTextureHost->Lock(aChannelIndex, aGL, aRendering); |
41 | 0 | } |
42 | | |
43 | | void |
44 | | RenderTextureHostWrapper::Unlock() |
45 | 0 | { |
46 | 0 | if (mTextureHost) { |
47 | 0 | mTextureHost->Unlock(); |
48 | 0 | } |
49 | 0 | mLocked = false; |
50 | 0 | } |
51 | | |
52 | | void |
53 | | RenderTextureHostWrapper::ClearCachedResources() |
54 | 0 | { |
55 | 0 | if (mTextureHost) { |
56 | 0 | mTextureHost->ClearCachedResources(); |
57 | 0 | } |
58 | 0 | } |
59 | | |
60 | | void |
61 | | RenderTextureHostWrapper::UpdateRenderTextureHost(RenderTextureHost* aTextureHost) |
62 | 0 | { |
63 | 0 | MOZ_ASSERT(!mInited || RenderThread::IsInRenderThread()); |
64 | 0 | MOZ_RELEASE_ASSERT(!mLocked); |
65 | 0 |
|
66 | 0 | mInited = true; |
67 | 0 | mTextureHost = aTextureHost; |
68 | 0 | } |
69 | | |
70 | | } // namespace wr |
71 | | } // namespace mozilla |