Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / gfxQuartzNativeDrawing.h
blobd4b90732ceb0f88395477e1f8ed88ba22e165e70
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef _GFXQUARTZNATIVEDRAWING_H_
7 #define _GFXQUARTZNATIVEDRAWING_H_
9 #include "mozilla/Attributes.h"
11 #include "gfxContext.h"
12 #include "gfxQuartzSurface.h"
13 #include "mozilla/gfx/BorrowedContext.h"
14 #include "nsAutoPtr.h"
16 class gfxQuartzNativeDrawing {
17 public:
19 /* Create native Quartz drawing for a rectangle bounded by
20 * nativeRect.
22 * Typical usage looks like:
24 * gfxQuartzNativeDrawing nativeDraw(ctx, nativeRect);
25 * CGContextRef cgContext = nativeDraw.BeginNativeDrawing();
26 * if (!cgContext)
27 * return NS_ERROR_FAILURE;
29 * ... call Quartz operations on CGContextRef to draw to nativeRect ...
31 * nativeDraw.EndNativeDrawing();
33 * aNativeRect is the size of the surface (in Quartz/Cocoa points) that
34 * will be created _if_ the gfxQuartzNativeDrawing decides to create a new
35 * surface and CGContext for its drawing operations, which it then
36 * composites into the target gfxContext.
38 * (Note that aNativeRect will be ignored if the gfxQuartzNativeDrawing
39 * uses the target gfxContext directly.)
41 * The optional aBackingScale parameter is a scaling factor that will be
42 * applied when creating and rendering into such a temporary surface.
44 gfxQuartzNativeDrawing(gfxContext *ctx,
45 const gfxRect& aNativeRect);
47 /* Returns a CGContextRef which may be used for native drawing. This
48 * CGContextRef is valid until EndNativeDrawing is called; if it is used
49 * for drawing after that time, the result is undefined. */
50 CGContextRef BeginNativeDrawing();
52 /* Marks the end of native drawing */
53 void EndNativeDrawing();
55 private:
56 // don't allow copying via construction or assignment
57 gfxQuartzNativeDrawing(const gfxQuartzNativeDrawing&) MOZ_DELETE;
58 const gfxQuartzNativeDrawing& operator=(const gfxQuartzNativeDrawing&) MOZ_DELETE;
60 // Final destination context
61 nsRefPtr<gfxContext> mContext;
62 mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
63 mozilla::gfx::BorrowedCGContext mBorrowedContext;
64 mozilla::gfx::Rect mNativeRect;
66 // saved state
67 CGContextRef mCGContext;
70 #endif