/usr/include/thunderbird/ImageLayerOGL.h is in thunderbird-dev 1:24.4.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
#ifndef GFX_IMAGELAYEROGL_H
#define GFX_IMAGELAYEROGL_H
#include "mozilla/layers/PLayerTransaction.h"
#include "LayerManagerOGL.h"
#include "ImageLayers.h"
#include "ImageContainer.h"
#include "yuv_convert.h"
#include "mozilla/Mutex.h"
namespace mozilla {
namespace layers {
class CairoImage;
class PlanarYCbCrImage;
class BlobYCbCrSurface;
/**
* This class wraps a GL texture. It includes a GLContext reference
* so we can use to free the texture when destroyed. The implementation
* makes sure to always free the texture on the main thread, even if the
* destructor runs on another thread.
*
* We ensure that the GLContext reference is only addrefed and released
* on the main thread, although it uses threadsafe recounting so we don't
* really have to.
*
* Initially the texture is not allocated --- it's in a "null" state.
*/
class GLTexture
{
typedef mozilla::gl::GLContext GLContext;
public:
GLTexture() : mTexture(0) {}
~GLTexture() { Release(); }
/**
* Allocate the texture. This can only be called on the main thread.
*/
void Allocate(GLContext *aContext);
/**
* Move the state of aOther to this GLTexture. If this GLTexture currently
* has a texture, it is released. This can be called on any thread.
*/
void TakeFrom(GLTexture *aOther);
bool IsAllocated() { return mTexture != 0; }
GLuint GetTextureID() { return mTexture; }
GLContext *GetGLContext() { return mContext; }
void Release();
private:
nsRefPtr<GLContext> mContext;
GLuint mTexture;
};
/**
* A RecycleBin is owned by an ImageLayer. We store textures in it that we
* want to recycle from one image to the next. It's a separate object from
* ImageContainer because images need to store a strong ref to their RecycleBin
* and we must avoid creating a reference loop between an ImageContainer and
* its active image.
*/
class TextureRecycleBin {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureRecycleBin)
typedef mozilla::gl::GLContext GLContext;
public:
TextureRecycleBin();
enum TextureType {
TEXTURE_Y,
TEXTURE_C
};
void RecycleTexture(GLTexture *aTexture, TextureType aType,
const gfxIntSize& aSize);
void GetTexture(TextureType aType, const gfxIntSize& aSize,
GLContext *aContext, GLTexture *aOutTexture);
private:
typedef mozilla::Mutex Mutex;
// This protects mRecycledBuffers, mRecycledBufferSize, mRecycledTextures
// and mRecycledTextureSizes
Mutex mLock;
nsTArray<GLTexture> mRecycledTextures[2];
gfxIntSize mRecycledTextureSizes[2];
};
class ImageLayerOGL : public ImageLayer,
public LayerOGL
{
public:
ImageLayerOGL(LayerManagerOGL *aManager);
~ImageLayerOGL() { Destroy(); }
// LayerOGL Implementation
virtual void Destroy() { mDestroyed = true; }
virtual Layer* GetLayer();
virtual bool LoadAsTexture(GLuint aTextureUnit, gfxIntSize* aSize);
virtual void RenderLayer(int aPreviousFrameBuffer,
const nsIntPoint& aOffset);
virtual void CleanupResources() {}
void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage);
void AllocateTexturesCairo(CairoImage *aImage);
protected:
nsRefPtr<TextureRecycleBin> mTextureRecycleBin;
};
struct PlanarYCbCrOGLBackendData : public ImageBackendData
{
~PlanarYCbCrOGLBackendData()
{
if (HasTextures()) {
mTextureRecycleBin->RecycleTexture(&mTextures[0], TextureRecycleBin::TEXTURE_Y, mYSize);
mTextureRecycleBin->RecycleTexture(&mTextures[1], TextureRecycleBin::TEXTURE_C, mCbCrSize);
mTextureRecycleBin->RecycleTexture(&mTextures[2], TextureRecycleBin::TEXTURE_C, mCbCrSize);
}
}
bool HasTextures()
{
return mTextures[0].IsAllocated() && mTextures[1].IsAllocated() &&
mTextures[2].IsAllocated();
}
GLTexture mTextures[3];
gfxIntSize mYSize, mCbCrSize;
nsRefPtr<TextureRecycleBin> mTextureRecycleBin;
};
struct CairoOGLBackendData : public ImageBackendData
{
CairoOGLBackendData() : mLayerProgram(gl::RGBALayerProgramType) {}
GLTexture mTexture;
gl::ShaderProgramType mLayerProgram;
gfxIntSize mTextureSize;
};
} /* layers */
} /* mozilla */
#endif /* GFX_IMAGELAYEROGL_H */
|