2018-02-02 20:07:36 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2017-10-30 20:10:29 +03:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "RenderSharedSurfaceTextureHost.h"
|
|
|
|
|
|
|
|
#include "mozilla/gfx/Logging.h"
|
|
|
|
#include "mozilla/layers/ImageDataSerializer.h"
|
|
|
|
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace wr {
|
|
|
|
|
2018-04-13 16:01:28 +03:00
|
|
|
RenderSharedSurfaceTextureHost::RenderSharedSurfaceTextureHost(
|
|
|
|
gfx::SourceSurfaceSharedDataWrapper* aSurface)
|
2017-10-30 20:10:29 +03:00
|
|
|
: mSurface(aSurface), mMap(), mLocked(false) {
|
|
|
|
MOZ_COUNT_CTOR_INHERITED(RenderSharedSurfaceTextureHost, RenderTextureHost);
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderSharedSurfaceTextureHost::~RenderSharedSurfaceTextureHost() {
|
|
|
|
MOZ_COUNT_DTOR_INHERITED(RenderSharedSurfaceTextureHost, RenderTextureHost);
|
|
|
|
}
|
|
|
|
|
2018-09-03 22:43:31 +03:00
|
|
|
wr::WrExternalImage RenderSharedSurfaceTextureHost::Lock(
|
|
|
|
uint8_t aChannelIndex, gl::GLContext* aGL, wr::ImageRendering aRendering) {
|
2017-10-30 20:10:29 +03:00
|
|
|
if (!mLocked) {
|
|
|
|
if (NS_WARN_IF(!mSurface->Map(gfx::DataSourceSurface::MapType::READ_WRITE,
|
|
|
|
&mMap))) {
|
2018-01-11 15:20:53 +03:00
|
|
|
return InvalidToWrExternalImage();
|
2017-10-30 20:10:29 +03:00
|
|
|
}
|
|
|
|
mLocked = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RawDataToWrExternalImage(mMap.mData,
|
|
|
|
mMap.mStride * mSurface->GetSize().height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderSharedSurfaceTextureHost::Unlock() {
|
|
|
|
if (mLocked) {
|
|
|
|
mSurface->Unmap();
|
|
|
|
mLocked = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|