1 /* -*- Mode: C++; tab-width: 2; 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 "RenderDcompSurfaceTextureHost.h"
10 #define LOG(msg, ...) \
11 MOZ_LOG(gDcompSurface, LogLevel::Debug, \
12 ("RenderDcompSurfaceTextureHost=%p, handle=%p, size=[%u,%u] " msg, \
13 this, this->mHandle, this->mSize.Width(), this->mSize.Height(), \
16 namespace mozilla::wr
{
18 RenderDcompSurfaceTextureHost::RenderDcompSurfaceTextureHost(
19 HANDLE aHandle
, gfx::IntSize aSize
, gfx::SurfaceFormat aFormat
)
20 : mHandle(aHandle
), mSize(aSize
), mFormat(aFormat
) {
21 MOZ_ASSERT(aHandle
&& aHandle
!= INVALID_HANDLE_VALUE
);
24 IDCompositionSurface
* RenderDcompSurfaceTextureHost::CreateSurfaceFromDevice(
25 IDCompositionDevice
* aDevice
) {
26 // Already created surface, no need to recreate it again.
32 static_cast<IDCompositionSurface
**>(getter_AddRefs(mDcompSurface
));
33 auto hr
= aDevice
->CreateSurfaceFromHandle(
34 mHandle
, reinterpret_cast<IUnknown
**>(surface
));
36 LOG("Failed to create surface from Dcomp handle %p, hr=%lx", mHandle
, hr
);
39 LOG("Created surface %p correctly", surface
);
43 } // namespace mozilla::wr