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/. */
5 
6 #ifndef NSRENDERINGCONTEXT__H__
7 #define NSRENDERINGCONTEXT__H__
8 
9 #include "gfxContext.h"
10 #include "mozilla/Attributes.h"
11 #include "nsCOMPtr.h"
12 #include "mozilla/RefPtr.h"
13 
14 namespace mozilla {
15 namespace gfx {
16 class DrawTarget;
17 } // namespace gfx
18 } // namespace mozilla
19 
20 class MOZ_STACK_CLASS nsRenderingContext final
21 {
22     typedef mozilla::gfx::DrawTarget DrawTarget;
23 
24 public:
nsRenderingContext(gfxContext * aThebesContext)25     explicit nsRenderingContext(gfxContext* aThebesContext)
26       : mThebes(aThebesContext)
27     {}
28 
nsRenderingContext(already_AddRefed<gfxContext> && aThebesContext)29     explicit nsRenderingContext(already_AddRefed<gfxContext>&& aThebesContext)
30       : mThebes(aThebesContext)
31     {}
32 
33     // These accessors will never return null.
ThebesContext()34     gfxContext *ThebesContext() { return mThebes; }
GetDrawTarget()35     DrawTarget *GetDrawTarget() { return mThebes->GetDrawTarget(); }
36 
37 private:
38     RefPtr<gfxContext> mThebes;
39 };
40 
41 #endif  // NSRENDERINGCONTEXT__H__
42