DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (d1ed7de67f5a)

VCS Links

Line Code
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
#ifdef MOZ_WIDGET_ANDROID

#include "GLImages.h"
#include "GLContext.h"
#include "GLContextProvider.h"
#include "ScopedGLHelpers.h"
#include "GLImages.h"
#include "GLBlitHelper.h"
#include "GLReadTexImageHelper.h"
#include "AndroidSurfaceTexture.h"

using namespace mozilla;
using namespace mozilla::gl;

namespace mozilla {
namespace layers {

static nsRefPtr<GLContext> sSnapshotContext;

TemporaryRef<gfx::SourceSurface>
SurfaceTextureImage::GetAsSourceSurface()
{
  MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread");

  if (!sSnapshotContext) {
    SurfaceCaps caps = SurfaceCaps::ForRGBA();
    sSnapshotContext = GLContextProvider::CreateOffscreen(gfxIntSize(16, 16), caps);

    if (!sSnapshotContext) {
      return nullptr;
    }
  }

  sSnapshotContext->MakeCurrent();
  ScopedTexture scopedTex(sSnapshotContext);
  ScopedBindTexture boundTex(sSnapshotContext, scopedTex.Texture());
  sSnapshotContext->fTexImage2D(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA,
                                mData.mSize.width, mData.mSize.height, 0,
                                LOCAL_GL_RGBA,
                                LOCAL_GL_UNSIGNED_BYTE,
                                nullptr);

  ScopedFramebufferForTexture fb(sSnapshotContext, scopedTex.Texture());

  GLBlitHelper helper(sSnapshotContext);

  helper.BlitImageToFramebuffer(this, mData.mSize, fb.FB(), false);
  ScopedBindFramebuffer bind(sSnapshotContext, fb.FB());

  RefPtr<gfx::DataSourceSurface> source =
        gfx::Factory::CreateDataSourceSurface(mData.mSize, gfx::SurfaceFormat::B8G8R8A8);
  if (NS_WARN_IF(!source)) {
    return nullptr;
  }

  ReadPixelsIntoDataSurface(sSnapshotContext, source);
  return source.forget();
}

} // layers
} // mozilla

#endif