Example #1
0
    void BPBinderCallback::AddBoundBP( UINT64 address, Module* mod, ModuleBinding* binding )
    {
        HRESULT hr = S_OK;
        RefPtr<CodeContext>             code;
        RefPtr<BreakpointResolution>    res;
        CComPtr<IDebugBreakpointResolution2>    breakpointResolution;
        CComPtr<IDebugCodeContext2>     codeContext;
        BpResolutionLocation            resLoc;
        RefPtr<BoundBreakpoint>         boundBP;
        ArchData*                       archData = NULL;

        hr = MakeCComObject( code );
        if ( FAILED( hr ) )
            return;

        // TODO: maybe we should be able to customize the code context with things like function and module

        archData = mCurProg->GetCoreProcess()->GetArchData();

        hr = code->Init( (Address64) address, mod, mDocContextInterface, archData->GetPointerSize() );
        if ( FAILED( hr ) )
            return;

        hr = code->QueryInterface( __uuidof( IDebugCodeContext2 ), (void**) &codeContext );
        _ASSERT( hr == S_OK );

        hr = MakeCComObject( res );
        if ( FAILED( hr ) )
            return;

        hr = BpResolutionLocation::InitCode( resLoc, codeContext );
        if ( FAILED( hr ) )
            return;

        hr = res->Init( resLoc, mCurProgInterface, NULL );
        if ( FAILED( hr ) )
            return;

        hr = res->QueryInterface( 
            __uuidof( IDebugBreakpointResolution2 ), (void**) &breakpointResolution );
        _ASSERT( hr == S_OK );

        hr = MakeCComObject( boundBP );
        if ( FAILED( hr ) )
            return;

        const DWORD Id = mPendingBP->GetNextBPId();
        boundBP->Init( 
            Id, (Address64) address, mPendingBP, breakpointResolution, mCurProg.Get() );

        binding->BoundBPs.push_back( boundBP );
    }
Example #2
0
void
DrawTargetD2D1::MaskSurface(const Pattern &aSource,
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions)
{
  RefPtr<ID2D1Bitmap> bitmap;

  RefPtr<ID2D1Image> image = GetImageForSurface(aMask, ExtendMode::CLAMP);

  PrepareForDrawing(aOptions.mCompositionOp, aSource);

  // FillOpacityMask only works if the antialias mode is MODE_ALIASED
  mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);

  IntSize size = aMask->GetSize();
  Rect maskRect = Rect(0.f, 0.f, Float(size.width), Float(size.height));
  image->QueryInterface((ID2D1Bitmap**)&bitmap);
  if (!bitmap) {
    gfxWarning() << "FillOpacityMask only works with Bitmap source surfaces.";
    return;
  }

  Rect dest = Rect(aOffset.x, aOffset.y, Float(size.width), Float(size.height));
  RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aSource, aOptions.mAlpha);
  mDC->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS, D2DRect(dest), D2DRect(maskRect));

  mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);

  FinalizeDrawing(aOptions.mCompositionOp, aSource);
}
nsresult nsImportFieldMap::Create(nsIStringBundle *aBundle, nsISupports *aOuter,
                                  REFNSIID aIID, void **aResult) {
  if (aOuter) return NS_ERROR_NO_AGGREGATION;

  RefPtr<nsImportFieldMap> it = new nsImportFieldMap(aBundle);
  return it->QueryInterface(aIID, aResult);
}
Example #4
0
    HRESULT Property::EnumChildren( 
        DEBUGPROP_INFO_FLAGS dwFields,
        DWORD dwRadix,
        REFGUID guidFilter,
        DBG_ATTRIB_FLAGS dwAttribFilter,
        LPCOLESTR pszNameFilter,
        DWORD dwTimeout,
        IEnumDebugPropertyInfo2** ppEnum )
    {
        HRESULT                         hr = S_OK;
        RefPtr<EnumDebugPropertyInfo2>  enumProps;
        RefPtr<MagoEE::IEEDEnumValues>  enumVals;

        hr = MagoEE::EnumValueChildren( 
            mExprContext, 
            mFullExprText, 
            mObjVal.ObjVal, 
            mExprContext->GetTypeEnv(),
            mExprContext->GetStringTable(),
            mFormatOpts,
            enumVals.Ref() );
        if ( FAILED( hr ) )
            return hr;

        hr = MakeCComObject( enumProps );
        if ( FAILED( hr ) )
            return hr;

        MagoEE::FormatOptions fmtopts (dwRadix);
        hr = enumProps->Init( enumVals, mExprContext, dwFields, fmtopts );
        if ( FAILED( hr ) )
            return hr;

        return enumProps->QueryInterface( __uuidof( IEnumDebugPropertyInfo2 ), (void**) ppEnum );
    }
Example #5
0
already_AddRefed<nsISupports>
CallbackObjectHolderBase::ToXPCOMCallback(CallbackObject* aCallback,
                                          const nsIID& aIID) const
{
  MOZ_ASSERT(NS_IsMainThread());
  if (!aCallback) {
    return nullptr;
  }

  // We don't init the AutoJSAPI with our callback because we don't want it
  // reporting errors to its global's onerror handlers.
  AutoJSAPI jsapi;
  jsapi.Init();
  JSContext* cx = jsapi.cx();

  JS::Rooted<JSObject*> callback(cx, aCallback->CallbackOrNull());

  JSAutoCompartment ac(cx, callback);
  RefPtr<nsXPCWrappedJS> wrappedJS;
  nsresult rv =
    nsXPCWrappedJS::GetNewOrUsed(callback, aIID, getter_AddRefs(wrappedJS));
  if (NS_FAILED(rv) || !wrappedJS) {
    return nullptr;
  }

  nsCOMPtr<nsISupports> retval;
  rv = wrappedJS->QueryInterface(aIID, getter_AddRefs(retval));
  if (NS_FAILED(rv)) {
    return nullptr;
  }

  return retval.forget();
}
Example #6
0
    void EventCallback::OnModuleUnload( IProcess* process, Address baseAddr )
    {
        OutputDebugStringA( "EventCallback::OnModuleUnload\n" );

        HRESULT     hr = S_OK;
        RefPtr<ModuleLoadEvent>     event;
        RefPtr<Program>             prog;
        RefPtr<Module>              mod;
        CComPtr<IDebugModule2>      mod2;

        if ( !mEngine->FindProgram( process->GetId(), prog ) )
            return;

        if ( !prog->FindModule( baseAddr, mod ) )
            return;

        prog->DeleteModule( mod.Get() );

        mEngine->UnbindPendingBPsFromModule( mod.Get(), prog.Get() );

        hr = MakeCComObject( event );
        if ( FAILED( hr ) )
            return;

        hr = mod->QueryInterface( __uuidof( IDebugModule2 ), (void**) &mod2 );
        if ( FAILED( hr ) )
            return;

        // TODO: message
        event->Init( mod2, NULL, false );

        SendEvent( event.Get(), prog.Get(), NULL );
    }
void
SharedSurface_ANGLEShareHandle::ConsumerAcquireImpl()
{
    if (!mConsumerTexture) {
        RefPtr<ID3D11Texture2D> tex;
        HRESULT hr = gfxWindowsPlatform::GetPlatform()->GetD3D11Device()->OpenSharedResource(mShareHandle,
                                                                                             __uuidof(ID3D11Texture2D),
                                                                                             (void**)(ID3D11Texture2D**)byRef(tex));
        if (SUCCEEDED(hr)) {
            mConsumerTexture = tex;
            RefPtr<IDXGIKeyedMutex> mutex;
            hr = tex->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));

            if (SUCCEEDED(hr)) {
                mConsumerKeyedMutex = mutex;
            }
        }
    }

    if (mConsumerKeyedMutex) {
      HRESULT hr = mConsumerKeyedMutex->AcquireSync(0, 10000);
      if (hr == WAIT_TIMEOUT) {
        MOZ_CRASH();
      }
    }
}
Example #8
0
already_AddRefed<IMediaSeeking>
AudioSinkInputPin::GetConnectedPinSeeking()
{
  RefPtr<IPin> peer = GetConnected();
  if (!peer)
    return nullptr;
  RefPtr<IMediaSeeking> seeking;
  peer->QueryInterface(static_cast<IMediaSeeking**>(byRef(seeking)));
  return seeking.forget();
}
Example #9
0
bool
DeviceManagerDx::CreateDevice(IDXGIAdapter* aAdapter,
                                 D3D_DRIVER_TYPE aDriverType,
                                 UINT aFlags,
                                 HRESULT& aResOut,
                                 RefPtr<ID3D11Device>& aOutDevice)
{
#ifdef BREAK_ON_D3D_ERROR
  aFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

  MOZ_SEH_TRY {
    aResOut = sD3D11CreateDeviceFn(
      aAdapter, aDriverType, nullptr,
      aFlags,
      mFeatureLevels.Elements(), mFeatureLevels.Length(),
      D3D11_SDK_VERSION, getter_AddRefs(aOutDevice), nullptr, nullptr);
  } MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
    return false;
  }

#ifdef BREAK_ON_D3D_ERROR
  do {
    if (!aOutDevice)
      break;

    RefPtr<ID3D11Debug> debug;
    if(!SUCCEEDED( aOutDevice->QueryInterface(__uuidof(ID3D11Debug), getter_AddRefs(debug)) ))
      break;

    RefPtr<ID3D11InfoQueue> infoQueue;
    if(!SUCCEEDED( debug->QueryInterface(__uuidof(ID3D11InfoQueue), getter_AddRefs(infoQueue)) ))
      break;

    infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true);
    infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true);
    infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true);
  } while (false);
#endif

  return true;
}
nsresult
nsScriptableInputStream::Create(nsISupports* aOuter, REFNSIID aIID,
                                void** aResult)
{
  if (aOuter) {
    return NS_ERROR_NO_AGGREGATION;
  }

  RefPtr<nsScriptableInputStream> sis = new nsScriptableInputStream();
  return sis->QueryInterface(aIID, aResult);
}
Example #11
0
bool
D3D11DXVA2Manager::SupportsConfig(IMFMediaType* aType, float aFramerate)
{
  MOZ_ASSERT(NS_IsMainThread());
  gfx::D3D11VideoCrashGuard crashGuard;
  if (crashGuard.Crashed()) {
    NS_WARNING("DXVA2D3D9 crash detected");
    return false;
  }

  RefPtr<ID3D11VideoDevice> videoDevice;
  HRESULT hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(getter_AddRefs(videoDevice)));
  NS_ENSURE_TRUE(SUCCEEDED(hr), false);

  D3D11_VIDEO_DECODER_DESC desc;
  desc.Guid = mDecoderGUID;

  UINT32 width = 0;
  UINT32 height = 0;
  hr = MFGetAttributeSize(aType, MF_MT_FRAME_SIZE, &width, &height);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
  desc.SampleWidth = width;
  desc.SampleHeight = height;

  desc.OutputFormat = DXGI_FORMAT_NV12;

  // AMD cards with UVD3 or earlier perform poorly trying to decode 1080p60 in hardware,
  // so use software instead. Pick 45 as an arbitrary upper bound for the framerate we can
  // handle.
  if (mIsAMDPreUVD4 &&
    (desc.SampleWidth >= 1920 || desc.SampleHeight >= 1088) &&
    aFramerate > 45) {
    return false;
  }

  UINT configCount = 0;
  hr = videoDevice->GetVideoDecoderConfigCount(&desc, &configCount);
  NS_ENSURE_TRUE(SUCCEEDED(hr), false);

  for (UINT i = 0; i < configCount; i++) {
    D3D11_VIDEO_DECODER_CONFIG config;
    hr = videoDevice->GetVideoDecoderConfig(&desc, i, &config);
    if (SUCCEEDED(hr)) {
      RefPtr<ID3D11VideoDecoder> decoder;
      hr = videoDevice->CreateVideoDecoder(&desc, &config, decoder.StartAssignment());
      if (SUCCEEDED(hr) && decoder) {
        return true;
      }
    }
  }
  return false;
}
Example #12
0
    HRESULT BPBinderCallback::MakeDocContext( MagoST::ISession* session, uint16_t compIx, uint16_t fileIx, const MagoST::LineNumber& lineNumber )
    {
        _ASSERT( session != NULL );
        _ASSERT( compIx != 0 );

        HRESULT         hr = S_OK;
        CComBSTR        filename;
        CComBSTR        langName;
        GUID            langGuid;
        TEXT_POSITION   posBegin = { 0 };
        TEXT_POSITION   posEnd = { 0 };
        RefPtr<BPDocumentContext>             docCtx;

        // already exists; don't need to make a new one
        if ( mDocContext.Get() != NULL )
            return S_FALSE;

        MagoST::FileInfo    fileInfo = { 0 };

        hr = session->GetFileInfo( compIx, fileIx, fileInfo );
        if ( FAILED( hr ) )
            return hr;

        hr = Utf8To16( fileInfo.Name.ptr, fileInfo.Name.length, filename.m_str );
        if ( FAILED( hr ) )
            return hr;

        // TODO:
        //compiland->get_language();

        posBegin.dwLine = lineNumber.Number;
        posEnd.dwLine = lineNumber.Number; // NumberEnd;?

        // AD7 lines are 0-based, DIA ones are 1-based
        posBegin.dwLine--;
        posEnd.dwLine--;

        hr = MakeCComObject( docCtx );
        if ( FAILED( hr ) )
            return hr;

        hr = docCtx->Init( mPendingBP, filename, posBegin, posEnd, langName, langGuid );
        if ( FAILED( hr ) )
            return hr;

        hr = docCtx->QueryInterface( __uuidof( IDebugDocumentContext2 ), (void**) &mDocContextInterface );
        _ASSERT( hr == S_OK );

        mDocContext = docCtx;

        return hr;
    }
// factory method for constructing a nsStringInputStream object
nsresult
nsStringInputStreamConstructor(nsISupports* aOuter, REFNSIID aIID,
                               void** aResult)
{
  *aResult = nullptr;

  if (NS_WARN_IF(aOuter)) {
    return NS_ERROR_NO_AGGREGATION;
  }

  RefPtr<nsStringInputStream> inst = new nsStringInputStream();
  return inst->QueryInterface(aIID, aResult);
}
Example #14
0
HRESULT
D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
                               const nsIntRect& aRegion,
                               ImageContainer* aContainer,
                               Image** aOutImage)
{
  NS_ENSURE_TRUE(aVideoSample, E_POINTER);
  NS_ENSURE_TRUE(aContainer, E_POINTER);
  NS_ENSURE_TRUE(aOutImage, E_POINTER);

  // Our video frame is stored in a non-sharable ID3D11Texture2D. We need
  // to create a copy of that frame as a sharable resource, save its share
  // handle, and put that handle into the rendering pipeline.

  ImageFormat format = ImageFormat::D3D11_SHARE_HANDLE_TEXTURE;
  nsRefPtr<Image> image(aContainer->CreateImage(format));
  NS_ENSURE_TRUE(image, E_FAIL);
  NS_ASSERTION(image->GetFormat() == ImageFormat::D3D11_SHARE_HANDLE_TEXTURE,
               "Wrong format?");

  D3D11ShareHandleImage* videoImage = static_cast<D3D11ShareHandleImage*>(image.get());
  HRESULT hr = videoImage->SetData(D3D11ShareHandleImage::Data(mTextureClientAllocator,
                                                               gfx::IntSize(mWidth, mHeight),
                                                               aRegion));
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

  hr = mTransform->Input(aVideoSample);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

  RefPtr<IMFSample> sample;
  RefPtr<ID3D11Texture2D> texture = videoImage->GetTexture();
  hr = CreateOutputSample(sample, texture);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

  RefPtr<IDXGIKeyedMutex> keyedMutex;
  hr = texture->QueryInterface(static_cast<IDXGIKeyedMutex**>(byRef(keyedMutex)));
  NS_ENSURE_TRUE(SUCCEEDED(hr) && keyedMutex, hr);

  hr = keyedMutex->AcquireSync(0, INFINITE);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

  hr = mTransform->Output(&sample);

  keyedMutex->ReleaseSync(0);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);

  image.forget(aOutImage);

  return S_OK;
}
/* static */ nsresult
RequestContextService::Create(nsISupports *aOuter, const nsIID& aIID, void **aResult)
{
  MOZ_ASSERT(NS_IsMainThread());
  if (aOuter != nullptr) {
    return NS_ERROR_NO_AGGREGATION;
  }

  RefPtr<RequestContextService> svc = new RequestContextService();
  nsresult rv = svc->Init();
  NS_ENSURE_SUCCESS(rv, rv);

  return svc->QueryInterface(aIID, aResult);
}
//static
nsresult
FileSystemDataSource::Create(nsISupports* aOuter, const nsIID& aIID, void **aResult)
{
    NS_ENSURE_NO_AGGREGATION(aOuter);

    RefPtr<FileSystemDataSource> self = new FileSystemDataSource();
    if (!self)
        return NS_ERROR_OUT_OF_MEMORY;
     
    nsresult rv = self->Init();
    NS_ENSURE_SUCCESS(rv, rv);

    return self->QueryInterface(aIID, aResult);
}
void
RootAccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
  MOZ_ASSERT(aOutAccessible);
  if (!aOutAccessible) {
    return;
  }

  if (mInterceptor &&
      SUCCEEDED(mInterceptor->Resolve(IID_IAccessible, aOutAccessible))) {
    return;
  }

  *aOutAccessible = nullptr;

  RefPtr<IAccessible> rootAccessible;
  RootAccessible::GetNativeInterface((void**)getter_AddRefs(rootAccessible));

  if (!mozilla::BrowserTabsRemoteAutostart() || XRE_IsContentProcess()) {
    // We only need to wrap this interface if our process is non-content e10s
    rootAccessible.forget(aOutAccessible);
    return;
  }

  // Otherwise, we need to wrap that IAccessible with an interceptor
  RefPtr<IInterceptorSink> eventSink(MakeAndAddRef<ChildIDThunk>());

  RefPtr<IAccessible> interceptor;
  HRESULT hr = CreateInterceptor<IAccessible>(
      STAUniquePtr<IAccessible>(rootAccessible.forget().take()), eventSink,
      getter_AddRefs(interceptor));
  if (FAILED(hr)) {
    return;
  }

  RefPtr<IWeakReferenceSource> weakRefSrc;
  hr = interceptor->QueryInterface(IID_IWeakReferenceSource,
                                   (void**)getter_AddRefs(weakRefSrc));
  if (FAILED(hr)) {
    return;
  }

  hr = weakRefSrc->GetWeakReference(getter_AddRefs(mInterceptor));
  if (FAILED(hr)) {
    return;
  }

  interceptor.forget(aOutAccessible);
}
Example #18
0
static already_AddRefed<Interface> QueryInterface(
    const ProxyAccessible* aProxy) {
  RefPtr<IAccessible> acc;
  if (!aProxy->GetCOMInterface((void**)getter_AddRefs(acc))) {
    return nullptr;
  }

  RefPtr<Interface> acc2;
  if (FAILED(acc->QueryInterface(InterfaceIID<Interface>::Value(),
                                 (void**)getter_AddRefs(acc2)))) {
    return nullptr;
  }

  return acc2.forget();
}
Example #19
0
static nsresult
nsSambaNTLMAuthConstructor(nsISupports *outer, REFNSIID iid, void **result)
{
  if (outer)
    return NS_ERROR_NO_AGGREGATION;

  RefPtr<nsAuthSambaNTLM> auth = new nsAuthSambaNTLM();
  if (!auth)
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv = auth->SpawnNTLMAuthHelper();
  if (NS_FAILED(rv)) {
    // Failure here probably means that cached credentials were not available
    return rv;
  }

  return auth->QueryInterface(iid, result);
}
HRESULT
AgileReference::Resolve(REFIID aIid, void** aOutInterface)
{
  MOZ_ASSERT(aOutInterface);
  MOZ_ASSERT(mAgileRef || mGitCookie);

  if (!aOutInterface) {
    return E_INVALIDARG;
  }

  *aOutInterface = nullptr;

  if (mAgileRef) {
    // IAgileReference lets you directly resolve the interface you want...
    return mAgileRef->Resolve(aIid, aOutInterface);
  }

  if (!mGitCookie) {
    return E_UNEXPECTED;
  }

  IGlobalInterfaceTable* git = ObtainGit();
  MOZ_ASSERT(git);
  if (!git) {
    return E_UNEXPECTED;
  }

  RefPtr<IUnknown> originalInterface;
  HRESULT hr = git->GetInterfaceFromGlobal(mGitCookie, mIid,
                                           getter_AddRefs(originalInterface));
  if (FAILED(hr)) {
    return hr;
  }

  if (aIid == mIid) {
    originalInterface.forget(aOutInterface);
    return S_OK;
  }

  // ...Whereas the GIT requires us to obtain the same interface that we
  // requested and then QI for the desired interface afterward.
  return originalInterface->QueryInterface(aIid, aOutInterface);
}
Example #21
0
    HRESULT Property::GetMemoryContext( 
        IDebugMemoryContext2** ppMemory )
    {
        OutputDebugStringA( "Property::GetMemoryContext\n" );

        if ( ppMemory == NULL )
            return E_INVALIDARG;

        HRESULT hr = S_OK;
        RefPtr<CodeContext> codeCxt;
        Address64 addr = 0;

        // TODO: let the EE figure this out
        if ( mObjVal.ObjVal._Type->IsPointer() )
        {
            addr = (Address64) mObjVal.ObjVal.Value.Addr;
        }
        else if ( mObjVal.ObjVal._Type->IsIntegral() )
        {
            addr = (Address64) mObjVal.ObjVal.Value.UInt64Value;
        }
        else if ( mObjVal.ObjVal._Type->IsSArray() )
        {
            addr = (Address64) mObjVal.ObjVal.Addr;
        }
        else if ( mObjVal.ObjVal._Type->IsDArray() )
        {
            addr = (Address64) mObjVal.ObjVal.Value.Array.Addr;
        }
        else
            return S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;

        hr = MakeCComObject( codeCxt );
        if ( FAILED( hr ) )
            return hr;

        hr = codeCxt->Init( addr, NULL, NULL, mPtrSize );
        if ( FAILED( hr ) )
            return hr;

        return codeCxt->QueryInterface( __uuidof( IDebugMemoryContext2 ), (void**) ppMemory );
    }
Example #22
0
void ProxyAccessible::Language(nsString& aLocale) {
  aLocale.Truncate();

  RefPtr<IAccessible> acc;
  if (!GetCOMInterface((void**)getter_AddRefs(acc))) {
    return;
  }

  RefPtr<IAccessible2> acc2;
  if (FAILED(acc->QueryInterface(IID_IAccessible2,
                                 (void**)getter_AddRefs(acc2)))) {
    return;
  }

  IA2Locale locale;
  HRESULT hr = acc2->get_locale(&locale);

  _bstr_t langWrap(locale.language, false);
  _bstr_t countryWrap(locale.country, false);
  _bstr_t variantWrap(locale.variant, false);

  if (FAILED(hr)) {
    return;
  }

  // The remaining code should essentially be the inverse of the
  // ia2Accessible::get_locale conversion to IA2Locale.

  if (!!variantWrap) {
    aLocale = (wchar_t*)variantWrap;
    return;
  }

  if (!!langWrap) {
    aLocale = (wchar_t*)langWrap;
    if (!!countryWrap) {
      aLocale += L"-";
      aLocale += (wchar_t*)countryWrap;
    }
  }
}
Example #23
0
nsresult
nsObserverService::Create(nsISupports* aOuter, const nsIID& aIID,
                          void** aInstancePtr)
{
  LOG(("nsObserverService::Create()"));

  RefPtr<nsObserverService> os = new nsObserverService();

  if (!os) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // The memory reporter can not be immediately registered here because
  // the nsMemoryReporterManager may attempt to get the nsObserverService
  // during initialization, causing a recursive GetService.
  NS_DispatchToCurrentThread(
    NewRunnableMethod("nsObserverService::RegisterReporter",
                      os,
                      &nsObserverService::RegisterReporter));

  return os->QueryInterface(aIID, aInstancePtr);
}
bool
DeviceAttachmentsD3D11::InitSyncObject()
{
  // Sync object is not supported on WARP.
  if (DeviceManagerDx::Get()->IsWARP()) {
    return true;
  }

  // It's okay to do this on Windows 8. But for now we'll just bail
  // whenever we're using WARP.
  CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1,
                             D3D11_BIND_SHADER_RESOURCE |
                             D3D11_BIND_RENDER_TARGET);
  desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;

  RefPtr<ID3D11Texture2D> texture;
  HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture));
  if (Failed(hr, "create sync texture")) {
    return false;
  }

  hr = texture->QueryInterface((IDXGIResource**)getter_AddRefs(mSyncTexture));
  if (Failed(hr, "QI sync texture")) {
    return false;
  }

  hr = mSyncTexture->GetSharedHandle(&mSyncHandle);
  if (FAILED(hr) || !mSyncHandle) {
    gfxCriticalError() << "Failed to get SharedHandle for sync texture. Result: "
                       << hexa(hr);
    NS_DispatchToMainThread(NS_NewRunnableFunction([] () -> void {
      Accumulate(Telemetry::D3D11_SYNC_HANDLE_FAILURE, 1);
    }));
    return false;
  }

  return true;
}
Example #25
0
    HRESULT StackFrame::GetCodeContext( 
       IDebugCodeContext2** ppCodeCxt )
    {
        if ( ppCodeCxt == NULL )
            return E_INVALIDARG;

        HRESULT hr = S_OK;
        RefPtr<CodeContext> codeContext;

        hr = MakeCComObject( codeContext );
        if ( FAILED( hr ) )
            return hr;

        CComPtr<IDebugDocumentContext2> docContext;
        hr = GetDocumentContext( &docContext );
        // there doesn't have to be a document context

        hr = codeContext->Init( mPC, mModule, docContext, mPtrSize );
        if ( FAILED( hr ) )
            return hr;

        return codeContext->QueryInterface( __uuidof( IDebugCodeContext2 ), (void**) ppCodeCxt );
    }
Example #26
0
    void EventCallback::OnModuleUnloadInternal( DWORD uniquePid, Address64 baseAddr )
    {
        OutputDebugStringA( "EventCallback::OnModuleUnload\n" );

        HRESULT     hr = S_OK;
        RefPtr<ModuleLoadEvent>     event;
        RefPtr<Program>             prog;
        RefPtr<Module>              mod;
        CComPtr<IDebugModule2>      mod2;
        CComBSTR                    msg;

        if ( !mEngine->FindProgram( uniquePid, prog ) )
            return;

        if ( !prog->FindModule( baseAddr, mod ) )
            return;

        prog->DeleteModule( mod.Get() );

        mEngine->UnbindPendingBPsFromModule( mod.Get(), prog.Get() );

        hr = MakeCComObject( event );
        if ( FAILED( hr ) )
            return;

        hr = mod->QueryInterface( __uuidof( IDebugModule2 ), (void**) &mod2 );
        if ( FAILED( hr ) )
            return;

        mod->GetPath( msg );
        msg.Append( L" unloaded.");

        event->Init( mod2, msg.m_str, false );

        SendEvent( event.Get(), prog.Get(), NULL );
    }
Example #27
0
void ProxyAccessible::Attributes(nsTArray<Attribute>* aAttrs) const {
  aAttrs->Clear();

  RefPtr<IAccessible> acc;
  if (!GetCOMInterface((void**)getter_AddRefs(acc))) {
    return;
  }

  RefPtr<IAccessible2> acc2;
  if (FAILED(acc->QueryInterface(IID_IAccessible2,
                                 (void**)getter_AddRefs(acc2)))) {
    return;
  }

  BSTR attrs;
  HRESULT hr = acc2->get_attributes(&attrs);
  _bstr_t attrsWrap(attrs, false);
  if (FAILED(hr)) {
    return;
  }

  ConvertBSTRAttributesToArray(
      nsDependentString((wchar_t*)attrs, attrsWrap.length()), aAttrs);
}
Example #28
0
    HRESULT StackFrame::GetDocumentContext( 
       IDebugDocumentContext2** ppCxt )
    {
        if ( ppCxt == NULL )
            return E_INVALIDARG;

        HRESULT hr = S_OK;
        RefPtr<SingleDocumentContext>   docContext;
        LineInfo    line;

        hr = MakeCComObject( docContext );
        if ( FAILED( hr ) )
            return hr;

        hr = GetLineInfo( line );
        if ( FAILED( hr ) )
            return hr;

        hr = docContext->Init( line.Filename, line.LineBegin, line.LineEnd, line.LangName, line.LangGuid );
        if ( FAILED( hr ) )
            return hr;

        return docContext->QueryInterface( __uuidof( IDebugDocumentContext2 ), (void**) ppCxt );
    }
Example #29
0
    HRESULT BPBinderCallback::MakeErrorBP( Error& errDesc, RefPtr<ErrorBreakpoint>& errorBP )
    {
        HRESULT         hr = S_OK;
        const wchar_t*  msg = NULL;
        BP_ERROR_TYPE   errType = errDesc.Type | errDesc.Sev;
        RefPtr<ErrorBreakpoint>                     errBP;
        RefPtr<ErrorBreakpointResolution>           errBPRes;
        BpResolutionLocation                        bpResLoc;
        CComPtr<IDebugErrorBreakpointResolution2>   errBPResInterface;
        CComPtr<IDebugPendingBreakpoint2>           pendBPInterface;

        hr = mPendingBP->QueryInterface( __uuidof( IDebugPendingBreakpoint2 ), (void**) &pendBPInterface );
        _ASSERT( hr == S_OK );

        hr = MakeCComObject( errBPRes );
        if ( FAILED( hr ) )
            return true;

        msg = GetString( errDesc.StrId );

        hr = errBPRes->Init( bpResLoc, mCurProgInterface, NULL, msg, errType );
        if ( FAILED( hr ) )
            return hr;

        hr = errBPRes->QueryInterface( __uuidof( IDebugErrorBreakpointResolution2 ), (void**) &errBPResInterface );
        _ASSERT( hr == S_OK );

        hr = MakeCComObject( errBP );
        if ( FAILED( hr ) )
            return hr;

        errBP->Init( pendBPInterface, errBPResInterface );
        errorBP = errBP;

        return hr;
    }
Example #30
0
TextureClient*
IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
{
  ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11ImageBridgeDevice();
  if (!device ||
      aClient->GetForwarder()->GetCompositorBackendType() != LayersBackend::LAYERS_D3D11) {

    IDirect3DDevice9* d3d9device = gfxWindowsPlatform::GetPlatform()->GetD3D9Device();
    if (d3d9device && aClient->GetForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D9) {
      return GetD3D9TextureClient(aClient);
    }
    return nullptr;
  }

  if (mTextureClient) {
    return mTextureClient;
  }

  RefPtr<ID3D11DeviceContext> ctx;
  device->GetImmediateContext(byRef(ctx));

  CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_A8_UNORM,
                                mData.mYSize.width, mData.mYSize.height, 1, 1);

  newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;

  RefPtr<ID3D11Texture2D> textureY;
  HRESULT hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureY));
  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);

  newDesc.Width = mData.mCbCrSize.width;
  newDesc.Height = mData.mCbCrSize.height;

  RefPtr<ID3D11Texture2D> textureCb;
  hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureCb));
  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);

  RefPtr<ID3D11Texture2D> textureCr;
  hr = device->CreateTexture2D(&newDesc, nullptr, byRef(textureCr));
  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);

  {
    AutoLockTexture lockY(textureY);
    AutoLockTexture lockCb(textureCb);
    AutoLockTexture lockCr(textureCr);

    ctx->UpdateSubresource(textureY, 0, nullptr, mData.mYChannel,
                           mData.mYStride, mData.mYStride * mData.mYSize.height);
    ctx->UpdateSubresource(textureCb, 0, nullptr, mData.mCbChannel,
                           mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
    ctx->UpdateSubresource(textureCr, 0, nullptr, mData.mCrChannel,
                           mData.mCbCrStride, mData.mCbCrStride * mData.mCbCrSize.height);
  }

  RefPtr<IDXGIResource> resource;

  HANDLE shareHandleY;
  textureY->QueryInterface((IDXGIResource**)byRef(resource));
  hr = resource->GetSharedHandle(&shareHandleY);

  HANDLE shareHandleCb;
  textureCb->QueryInterface((IDXGIResource**)byRef(resource));
  hr = resource->GetSharedHandle(&shareHandleCb);

  HANDLE shareHandleCr;
  textureCr->QueryInterface((IDXGIResource**)byRef(resource));
  hr = resource->GetSharedHandle(&shareHandleCr);

  mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(),
                                                  TextureFlags::DEFAULT,
                                                  textureY,
                                                  textureCb,
                                                  textureCr,
                                                  shareHandleY,
                                                  shareHandleCb,
                                                  shareHandleCr,
                                                  GetSize(),
                                                  mData.mYSize,
                                                  mData.mCbCrSize);

  return mTextureClient;
}