예제 #1
0
HRESULT d2d_bitmap_brush_init(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target, ID2D1Bitmap *bitmap,
        const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc)
{
    D3D10_SAMPLER_DESC sampler_desc;
    HRESULT hr;

    FIXME("Ignoring brush properties.\n");

    d2d_brush_init(brush, &render_target->ID2D1RenderTarget_iface, D2D_BRUSH_TYPE_BITMAP,
            brush_desc, (ID2D1BrushVtbl *)&d2d_bitmap_brush_vtbl);
    brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap);

    sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
    sampler_desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
    sampler_desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
    sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
    sampler_desc.MipLODBias = 0.0f;
    sampler_desc.MaxAnisotropy = 0;
    sampler_desc.ComparisonFunc = D3D10_COMPARISON_NEVER;
    sampler_desc.BorderColor[0] = 0.0f;
    sampler_desc.BorderColor[1] = 0.0f;
    sampler_desc.BorderColor[2] = 0.0f;
    sampler_desc.BorderColor[3] = 0.0f;
    sampler_desc.MinLOD = 0.0f;
    sampler_desc.MaxLOD = 0.0f;

    if (FAILED(hr = ID3D10Device_CreateSamplerState(render_target->device,
            &sampler_desc, &brush->u.bitmap.sampler_state)))
    {
        ERR("Failed to create sampler state, hr %#x.\n", hr);
        return hr;
    }

    return S_OK;
}
예제 #2
0
static HRESULT STDMETHODCALLTYPE d2d_dc_render_target_BindDC(ID2D1DCRenderTarget *iface,
        const HDC hdc, const RECT *rect)
{
    struct d2d_dc_render_target *render_target = impl_from_ID2D1DCRenderTarget(iface);
    D2D1_BITMAP_PROPERTIES1 bitmap_desc;
    struct d2d_bitmap *bitmap_impl;
    IDXGISurface1 *dxgi_surface;
    ID2D1DeviceContext *context;
    ID3D10Resource *resource;
    D2D1_SIZE_U bitmap_size;
    ID2D1Bitmap *bitmap;
    HRESULT hr;

    TRACE("iface %p, hdc %p, rect %s.\n", iface, hdc, wine_dbgstr_rect(rect));

    if (!hdc)
        return E_INVALIDARG;

    /* Switch dxgi target to new surface. */
    ID2D1RenderTarget_QueryInterface(render_target->dxgi_target, &IID_ID2D1DeviceContext, (void **)&context);

    bitmap_size.width = rect->right - rect->left;
    bitmap_size.height = rect->bottom - rect->top;

    memset(&bitmap_desc, 0, sizeof(bitmap_desc));
    bitmap_desc.pixelFormat = render_target->pixel_format;
    bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW |
            D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE;
    if (FAILED(hr = ID2D1DeviceContext_CreateBitmap(context, bitmap_size, NULL, 0, &bitmap_desc,
            (ID2D1Bitmap1 **)&bitmap)))
    {
        WARN("Failed to create target bitmap, hr %#x.\n", hr);
        ID2D1DeviceContext_Release(context);
        return hr;
    }

    bitmap_impl = unsafe_impl_from_ID2D1Bitmap(bitmap);
    ID3D10ShaderResourceView_GetResource(bitmap_impl->view, &resource);
    ID3D10Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)&dxgi_surface);
    ID3D10Resource_Release(resource);

    ID2D1DeviceContext_SetTarget(context, (ID2D1Image *)bitmap);
    ID2D1Bitmap_Release(bitmap);
    ID2D1DeviceContext_Release(context);

    if (render_target->dxgi_surface)
        IDXGISurface1_Release(render_target->dxgi_surface);
    render_target->dxgi_surface = dxgi_surface;

    render_target->hdc = hdc;
    render_target->dst_rect = *rect;

    return hr;
}
예제 #3
0
파일: brush.c 프로젝트: YongHaoWu/wine-hub
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush *iface, ID2D1Bitmap *bitmap)
{
    struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface);

    TRACE("iface %p, bitmap %p.\n", iface, bitmap);

    if (bitmap)
        ID2D1Bitmap_AddRef(bitmap);
    if (brush->u.bitmap.bitmap)
        ID2D1Bitmap_Release(&brush->u.bitmap.bitmap->ID2D1Bitmap_iface);
    brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap);
}
예제 #4
0
파일: brush.c 프로젝트: YongHaoWu/wine-hub
void d2d_bitmap_brush_init(struct d2d_brush *brush, ID2D1Factory *factory, ID2D1Bitmap *bitmap,
        const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc)
{
    d2d_brush_init(brush, factory, D2D_BRUSH_TYPE_BITMAP,
            brush_desc, (ID2D1BrushVtbl *)&d2d_bitmap_brush_vtbl);
    if ((brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap)))
        ID2D1Bitmap_AddRef(&brush->u.bitmap.bitmap->ID2D1Bitmap_iface);
    if (bitmap_brush_desc)
    {
        brush->u.bitmap.extend_mode_x = bitmap_brush_desc->extendModeX;
        brush->u.bitmap.extend_mode_y = bitmap_brush_desc->extendModeY;
        brush->u.bitmap.interpolation_mode = bitmap_brush_desc->interpolationMode;
    }
    else
    {
        brush->u.bitmap.extend_mode_x = D2D1_EXTEND_MODE_CLAMP;
        brush->u.bitmap.extend_mode_y = D2D1_EXTEND_MODE_CLAMP;
        brush->u.bitmap.interpolation_mode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
    }
}
예제 #5
0
파일: bitmap.c 프로젝트: YongHaoWu/wine-hub
HRESULT d2d_bitmap_init_shared(struct d2d_bitmap *bitmap, struct d2d_d3d_render_target *render_target,
        REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES *desc)
{
    if (IsEqualGUID(iid, &IID_ID2D1Bitmap))
    {
        struct d2d_bitmap *src_impl = unsafe_impl_from_ID2D1Bitmap(data);
        D2D1_BITMAP_PROPERTIES d;
        ID3D10Device *device;

        if (src_impl->factory != render_target->factory)
            return D2DERR_WRONG_FACTORY;

        ID3D10ShaderResourceView_GetDevice(src_impl->view, &device);
        ID3D10Device_Release(device);
        if (device != render_target->device)
            return D2DERR_UNSUPPORTED_OPERATION;

        if (!desc)
        {
            d.pixelFormat = src_impl->format;
            d.dpiX = src_impl->dpi_x;
            d.dpiY = src_impl->dpi_y;
            desc = &d;
        }

        if (!format_supported(&desc->pixelFormat))
        {
            WARN("Tried to create bitmap with unsupported format {%#x / %#x}.\n",
                    desc->pixelFormat.format, desc->pixelFormat.alphaMode);
            return D2DERR_UNSUPPORTED_PIXEL_FORMAT;
        }

        d2d_bitmap_init(bitmap, render_target->factory, src_impl->view, src_impl->pixel_size, desc);

        return S_OK;
    }

    WARN("Unhandled interface %s.\n", debugstr_guid(iid));

    return E_INVALIDARG;
}