gfx/thebes/gfxD2DSurface.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "gfxD2DSurface.h"
michael@0 7 #include "cairo.h"
michael@0 8 #include "cairo-win32.h"
michael@0 9 #include "gfxWindowsPlatform.h"
michael@0 10
michael@0 11 gfxD2DSurface::gfxD2DSurface(HWND aWnd, gfxContentType aContent)
michael@0 12 {
michael@0 13 Init(cairo_d2d_surface_create_for_hwnd(
michael@0 14 gfxWindowsPlatform::GetPlatform()->GetD2DDevice(),
michael@0 15 aWnd,
michael@0 16 (cairo_content_t)(int)aContent));
michael@0 17 }
michael@0 18
michael@0 19 gfxD2DSurface::gfxD2DSurface(HANDLE handle, gfxContentType aContent)
michael@0 20 {
michael@0 21 Init(cairo_d2d_surface_create_for_handle(
michael@0 22 gfxWindowsPlatform::GetPlatform()->GetD2DDevice(),
michael@0 23 handle,
michael@0 24 (cairo_content_t)(int)aContent));
michael@0 25 }
michael@0 26
michael@0 27 gfxD2DSurface::gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent)
michael@0 28 {
michael@0 29 Init(cairo_d2d_surface_create_for_texture(
michael@0 30 gfxWindowsPlatform::GetPlatform()->GetD2DDevice(),
michael@0 31 texture,
michael@0 32 (cairo_content_t)(int)aContent));
michael@0 33 }
michael@0 34
michael@0 35 gfxD2DSurface::gfxD2DSurface(cairo_surface_t *csurf)
michael@0 36 {
michael@0 37 Init(csurf, true);
michael@0 38 }
michael@0 39
michael@0 40 gfxD2DSurface::gfxD2DSurface(const gfxIntSize& size,
michael@0 41 gfxImageFormat imageFormat)
michael@0 42 {
michael@0 43 Init(cairo_d2d_surface_create(
michael@0 44 gfxWindowsPlatform::GetPlatform()->GetD2DDevice(),
michael@0 45 (cairo_format_t)(int)imageFormat,
michael@0 46 size.width, size.height));
michael@0 47 }
michael@0 48
michael@0 49 gfxD2DSurface::~gfxD2DSurface()
michael@0 50 {
michael@0 51 }
michael@0 52
michael@0 53 void
michael@0 54 gfxD2DSurface::Present()
michael@0 55 {
michael@0 56 cairo_d2d_present_backbuffer(CairoSurface());
michael@0 57 }
michael@0 58
michael@0 59 void
michael@0 60 gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip)
michael@0 61 {
michael@0 62 cairo_rectangle_t rect;
michael@0 63 rect.x = aClip.x;
michael@0 64 rect.y = aClip.y;
michael@0 65 rect.width = aClip.width;
michael@0 66 rect.height = aClip.height;
michael@0 67 cairo_d2d_scroll(CairoSurface(), aDelta.x, aDelta.y, &rect);
michael@0 68 }
michael@0 69
michael@0 70 ID3D10Texture2D*
michael@0 71 gfxD2DSurface::GetTexture()
michael@0 72 {
michael@0 73 return cairo_d2d_surface_get_texture(CairoSurface());
michael@0 74 }
michael@0 75
michael@0 76 HDC
michael@0 77 gfxD2DSurface::GetDC(bool aRetainContents)
michael@0 78 {
michael@0 79 return cairo_d2d_get_dc(CairoSurface(), aRetainContents);
michael@0 80 }
michael@0 81
michael@0 82 void
michael@0 83 gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect)
michael@0 84 {
michael@0 85 if (!aUpdatedRect) {
michael@0 86 return cairo_d2d_release_dc(CairoSurface(), nullptr);
michael@0 87 }
michael@0 88
michael@0 89 cairo_rectangle_int_t rect;
michael@0 90 rect.x = aUpdatedRect->x;
michael@0 91 rect.y = aUpdatedRect->y;
michael@0 92 rect.width = aUpdatedRect->width;
michael@0 93 rect.height = aUpdatedRect->height;
michael@0 94 cairo_d2d_release_dc(CairoSurface(), &rect);
michael@0 95 }
michael@0 96
michael@0 97 const gfxIntSize gfxD2DSurface::GetSize() const
michael@0 98 {
michael@0 99 return gfxIntSize(cairo_d2d_surface_get_width(mSurface),
michael@0 100 cairo_d2d_surface_get_height(mSurface));
michael@0 101 }

mercurial