1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxD2DSurface.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "gfxD2DSurface.h" 1.10 +#include "cairo.h" 1.11 +#include "cairo-win32.h" 1.12 +#include "gfxWindowsPlatform.h" 1.13 + 1.14 +gfxD2DSurface::gfxD2DSurface(HWND aWnd, gfxContentType aContent) 1.15 +{ 1.16 + Init(cairo_d2d_surface_create_for_hwnd( 1.17 + gfxWindowsPlatform::GetPlatform()->GetD2DDevice(), 1.18 + aWnd, 1.19 + (cairo_content_t)(int)aContent)); 1.20 +} 1.21 + 1.22 +gfxD2DSurface::gfxD2DSurface(HANDLE handle, gfxContentType aContent) 1.23 +{ 1.24 + Init(cairo_d2d_surface_create_for_handle( 1.25 + gfxWindowsPlatform::GetPlatform()->GetD2DDevice(), 1.26 + handle, 1.27 + (cairo_content_t)(int)aContent)); 1.28 +} 1.29 + 1.30 +gfxD2DSurface::gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent) 1.31 +{ 1.32 + Init(cairo_d2d_surface_create_for_texture( 1.33 + gfxWindowsPlatform::GetPlatform()->GetD2DDevice(), 1.34 + texture, 1.35 + (cairo_content_t)(int)aContent)); 1.36 +} 1.37 + 1.38 +gfxD2DSurface::gfxD2DSurface(cairo_surface_t *csurf) 1.39 +{ 1.40 + Init(csurf, true); 1.41 +} 1.42 + 1.43 +gfxD2DSurface::gfxD2DSurface(const gfxIntSize& size, 1.44 + gfxImageFormat imageFormat) 1.45 +{ 1.46 + Init(cairo_d2d_surface_create( 1.47 + gfxWindowsPlatform::GetPlatform()->GetD2DDevice(), 1.48 + (cairo_format_t)(int)imageFormat, 1.49 + size.width, size.height)); 1.50 +} 1.51 + 1.52 +gfxD2DSurface::~gfxD2DSurface() 1.53 +{ 1.54 +} 1.55 + 1.56 +void 1.57 +gfxD2DSurface::Present() 1.58 +{ 1.59 + cairo_d2d_present_backbuffer(CairoSurface()); 1.60 +} 1.61 + 1.62 +void 1.63 +gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip) 1.64 +{ 1.65 + cairo_rectangle_t rect; 1.66 + rect.x = aClip.x; 1.67 + rect.y = aClip.y; 1.68 + rect.width = aClip.width; 1.69 + rect.height = aClip.height; 1.70 + cairo_d2d_scroll(CairoSurface(), aDelta.x, aDelta.y, &rect); 1.71 +} 1.72 + 1.73 +ID3D10Texture2D* 1.74 +gfxD2DSurface::GetTexture() 1.75 +{ 1.76 + return cairo_d2d_surface_get_texture(CairoSurface()); 1.77 +} 1.78 + 1.79 +HDC 1.80 +gfxD2DSurface::GetDC(bool aRetainContents) 1.81 +{ 1.82 + return cairo_d2d_get_dc(CairoSurface(), aRetainContents); 1.83 +} 1.84 + 1.85 +void 1.86 +gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect) 1.87 +{ 1.88 + if (!aUpdatedRect) { 1.89 + return cairo_d2d_release_dc(CairoSurface(), nullptr); 1.90 + } 1.91 + 1.92 + cairo_rectangle_int_t rect; 1.93 + rect.x = aUpdatedRect->x; 1.94 + rect.y = aUpdatedRect->y; 1.95 + rect.width = aUpdatedRect->width; 1.96 + rect.height = aUpdatedRect->height; 1.97 + cairo_d2d_release_dc(CairoSurface(), &rect); 1.98 +} 1.99 + 1.100 +const gfxIntSize gfxD2DSurface::GetSize() const 1.101 +{ 1.102 + return gfxIntSize(cairo_d2d_surface_get_width(mSurface), 1.103 + cairo_d2d_surface_get_height(mSurface)); 1.104 +} 1.105 \ No newline at end of file