gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=8 et :
     3  */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #include <d3d10_1.h>
     9 #include <dxgi.h>
    11 #include "mozilla/gfx/Point.h"
    12 #include "mozilla/layers/LayerManagerComposite.h"
    13 #include "mozilla/layers/PLayerTransaction.h"
    14 #include "ShadowLayers.h"
    16 using namespace mozilla::gl;
    18 namespace mozilla {
    19 namespace layers {
    22 /*static*/ void
    23 ShadowLayerForwarder::PlatformSyncBeforeUpdate()
    24 {
    25 }
    27 /*static*/ bool
    28 LayerManagerComposite::SupportsDirectTexturing()
    29 {
    30   return true;
    31 }
    33 /*static*/ void
    34 LayerManagerComposite::PlatformSyncBeforeReplyUpdate()
    35 {
    36 }
    38 bool
    39 GetDescriptor(ID3D10Texture2D* aTexture, SurfaceDescriptorD3D10* aDescr)
    40 {
    41   NS_ABORT_IF_FALSE(aTexture && aDescr, "Params must be nonnull");
    43   HRESULT hr;
    44   IDXGIResource* dr = nullptr;
    45   hr = aTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&dr);
    46   if (!SUCCEEDED(hr) || !dr)
    47     return false;
    49   hr = dr->GetSharedHandle(reinterpret_cast<HANDLE*>(&aDescr->handle()));
    50   return !!SUCCEEDED(hr);
    51 }
    53 already_AddRefed<ID3D10Texture2D>
    54 OpenForeign(ID3D10Device* aDevice, const SurfaceDescriptorD3D10& aDescr)
    55 {
    56   HRESULT hr;
    57   ID3D10Texture2D* tex = nullptr;
    58   hr = aDevice->OpenSharedResource(reinterpret_cast<HANDLE>(aDescr.handle()),
    59                                    __uuidof(ID3D10Texture2D),
    60                                    (void**)&tex);
    61   if (!SUCCEEDED(hr) || !tex)
    62     return nullptr;
    64   return nsRefPtr<ID3D10Texture2D>(tex).forget();
    65 }
    67 } // namespace layers
    68 } // namespace mozilla

mercurial