2010-04-20 14:52:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:set ts=2 sts=2 sw=2 et cin:
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-20 14:52:19 +00:00
|
|
|
|
|
|
|
#ifndef nsCoreAnimationSupport_h__
|
|
|
|
#define nsCoreAnimationSupport_h__
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
2012-02-01 02:18:30 +00:00
|
|
|
#import <OpenGL/OpenGL.h>
|
2010-04-20 14:52:19 +00:00
|
|
|
#import "ApplicationServices/ApplicationServices.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "gfxTypes.h"
|
2011-07-12 14:31:18 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2012-02-01 02:18:30 +00:00
|
|
|
#include "nsIOSurface.h"
|
2010-04-20 14:52:19 +00:00
|
|
|
|
|
|
|
// Get the system color space.
|
2010-05-20 21:48:15 +00:00
|
|
|
CGColorSpaceRef THEBES_API CreateSystemColorSpace();
|
2010-04-20 14:52:19 +00:00
|
|
|
|
|
|
|
// Manages a CARenderer
|
|
|
|
struct _CGLPBufferObject;
|
|
|
|
struct _CGLContextObject;
|
|
|
|
|
2011-10-20 20:32:38 +00:00
|
|
|
enum AllowOfflineRendererEnum { ALLOW_OFFLINE_RENDERER, DISALLOW_OFFLINE_RENDERER };
|
|
|
|
|
2010-04-20 14:52:19 +00:00
|
|
|
class THEBES_API nsCARenderer {
|
2011-07-12 14:31:18 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsCARenderer)
|
2010-04-20 14:52:19 +00:00
|
|
|
public:
|
2012-07-30 14:20:58 +00:00
|
|
|
nsCARenderer() : mCARenderer(nullptr), mFBOTexture(0), mOpenGLContext(nullptr),
|
|
|
|
mCGImage(nullptr), mCGData(nullptr), mIOSurface(nullptr), mFBO(0),
|
2012-07-20 11:16:17 +00:00
|
|
|
mIOTexture(0),
|
2011-10-20 20:32:38 +00:00
|
|
|
mUnsupportedWidth(UINT32_MAX), mUnsupportedHeight(UINT32_MAX),
|
|
|
|
mAllowOfflineRenderer(DISALLOW_OFFLINE_RENDERER) {}
|
2010-04-20 14:52:19 +00:00
|
|
|
~nsCARenderer();
|
2011-10-20 20:32:38 +00:00
|
|
|
nsresult SetupRenderer(void* aCALayer, int aWidth, int aHeight,
|
|
|
|
AllowOfflineRendererEnum aAllowOfflineRenderer);
|
2010-04-20 14:52:19 +00:00
|
|
|
nsresult Render(int aWidth, int aHeight, CGImageRef *aOutCAImage);
|
2012-07-30 14:20:58 +00:00
|
|
|
bool isInit() { return mCARenderer != nullptr; }
|
2010-04-20 14:52:19 +00:00
|
|
|
/*
|
|
|
|
* Render the CALayer to an IOSurface. If no IOSurface
|
|
|
|
* is attached then an internal pixel buffer will be
|
|
|
|
* used.
|
2011-10-13 14:36:59 +00:00
|
|
|
*/
|
2011-07-12 14:31:18 +00:00
|
|
|
void AttachIOSurface(nsRefPtr<nsIOSurface> aSurface);
|
|
|
|
IOSurfaceID GetIOSurfaceID();
|
2011-10-13 14:36:59 +00:00
|
|
|
static nsresult DrawSurfaceToCGContext(CGContextRef aContext,
|
|
|
|
nsIOSurface *surf,
|
|
|
|
CGColorSpaceRef aColorSpace,
|
2010-04-20 14:52:19 +00:00
|
|
|
int aX, int aY,
|
2011-06-24 14:49:42 +00:00
|
|
|
size_t aWidth, size_t aHeight);
|
2011-10-13 14:36:59 +00:00
|
|
|
|
2011-07-12 14:31:18 +00:00
|
|
|
// Remove & Add the layer without destroying
|
|
|
|
// the renderer for fast back buffer swapping.
|
|
|
|
void DettachCALayer();
|
|
|
|
void AttachCALayer(void *aCALayer);
|
2011-06-30 16:46:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static void SaveToDisk(nsIOSurface *surf);
|
|
|
|
#endif
|
2010-04-20 14:52:19 +00:00
|
|
|
private:
|
2011-11-15 22:36:06 +00:00
|
|
|
void SetBounds(int aWidth, int aHeight);
|
|
|
|
void SetViewport(int aWidth, int aHeight);
|
2010-04-20 14:52:19 +00:00
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
void *mCARenderer;
|
2011-10-20 20:32:38 +00:00
|
|
|
GLuint mFBOTexture;
|
|
|
|
_CGLContextObject *mOpenGLContext;
|
|
|
|
CGImageRef mCGImage;
|
|
|
|
void *mCGData;
|
|
|
|
nsRefPtr<nsIOSurface> mIOSurface;
|
|
|
|
uint32_t mFBO;
|
|
|
|
uint32_t mIOTexture;
|
|
|
|
uint32_t mUnsupportedWidth;
|
|
|
|
uint32_t mUnsupportedHeight;
|
|
|
|
AllowOfflineRendererEnum mAllowOfflineRenderer;
|
2010-04-20 14:52:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // XP_MACOSX
|
|
|
|
#endif // nsCoreAnimationSupport_h__
|
|
|
|
|