|
1 /******************************************************************************* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - initial implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 package org.eclipse.swt.internal.extension; |
|
13 |
|
14 import org.eclipse.swt.graphics.Internal_GfxPackageSupport; |
|
15 import org.eclipse.swt.widgets.Internal_PackageSupport; |
|
16 import org.eclipse.swt.widgets.Control; |
|
17 import org.eclipse.swt.graphics.Rectangle; |
|
18 import org.eclipse.swt.graphics.GC; |
|
19 import org.eclipse.swt.internal.qt.graphics.WindowSurface; |
|
20 |
|
21 public final class GraphicsUtil { |
|
22 |
|
23 /** |
|
24 * Ends window surface session started with startExternalRendering() -call. |
|
25 * Must be called after the rendering of external renderer has finished. |
|
26 * |
|
27 * @param gc The gc instance where the rendering is targeted |
|
28 */ |
|
29 public static void endExternalRendering(GC gc) { |
|
30 Internal_GfxPackageSupport.endExternalRendering(gc); |
|
31 } |
|
32 |
|
33 /** |
|
34 * Returns the WindowSurface instance that is the ultimate target of the |
|
35 * rendering for the given gc instance. |
|
36 * |
|
37 * @param gc The gc instance asossiated with the WindowSurface |
|
38 * @return The WindowSurface instance that is the target of given gc instance |
|
39 */ |
|
40 public static WindowSurface getWindowSurface(GC gc) { |
|
41 return Internal_GfxPackageSupport.getWindowSurface(gc); |
|
42 } |
|
43 |
|
44 /** |
|
45 * Start a window surface rendering session on the surface that is the |
|
46 * target of the given gc instance. This method must be called before |
|
47 * rendering to the window surface from external rendering APIs like m3g and m2g. |
|
48 * The caller must not render outside the area defined by the returned rectangle, |
|
49 * as it may result in rendering on top of other controls. |
|
50 * |
|
51 * @param gc The gc instance where the rendering is targeted |
|
52 * @return The current clip of the gc in window surface coordinates or |
|
53 * null if the target of given gc is not a Control |
|
54 */ |
|
55 public static Rectangle startExternalRendering(GC gc) { |
|
56 return Internal_GfxPackageSupport.startExternalRendering(gc); |
|
57 } |
|
58 |
|
59 /** |
|
60 * Converts the given rectangle to window surface coordinates. |
|
61 * |
|
62 * @param c The Control instance on which coordinates the conversion is done |
|
63 * @param rect The rectangle to be converted |
|
64 * @return Rectangcular area in window surface coordinates |
|
65 */ |
|
66 public static Rectangle toWindowSurface(Control c, Rectangle rect) { |
|
67 return Internal_PackageSupport.toWindowSurface(c, rect); |
|
68 } |
|
69 } |