2011-12-24 07:13:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-06-29 10:42:59 +00:00
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp : */
|
2012-07-20 09:10:44 +00:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-12-24 07:13:33 +00:00
|
|
|
|
2014-07-04 02:36:22 +00:00
|
|
|
#include "Framebuffer.h"
|
|
|
|
|
|
|
|
#include "android/log.h"
|
2011-12-24 07:13:33 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2014-07-04 02:36:22 +00:00
|
|
|
#include "nsSize.h"
|
2011-12-24 07:13:33 +00:00
|
|
|
#include "mozilla/FileUtils.h"
|
|
|
|
|
2014-07-04 02:36:22 +00:00
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
|
2011-12-24 07:13:33 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace Framebuffer {
|
|
|
|
|
|
|
|
static size_t sMappedSize;
|
|
|
|
static struct fb_var_screeninfo sVi;
|
2012-07-30 14:20:58 +00:00
|
|
|
static gfxIntSize *sScreenSize = nullptr;
|
2011-12-24 07:13:33 +00:00
|
|
|
|
2012-04-05 16:15:19 +00:00
|
|
|
bool
|
|
|
|
GetSize(nsIntSize *aScreenSize) {
|
2012-06-26 14:38:50 +00:00
|
|
|
// If the framebuffer has been opened, we should always have the size.
|
2012-12-08 00:02:48 +00:00
|
|
|
if (sScreenSize) {
|
2012-06-26 14:38:50 +00:00
|
|
|
*aScreenSize = *sScreenSize;
|
2012-04-05 16:15:19 +00:00
|
|
|
return true;
|
2012-06-26 14:38:50 +00:00
|
|
|
}
|
2012-04-05 16:15:19 +00:00
|
|
|
|
|
|
|
ScopedClose fd(open("/dev/graphics/fb0", O_RDWR));
|
2012-04-12 10:21:24 +00:00
|
|
|
if (0 > fd.get()) {
|
2012-04-05 16:15:19 +00:00
|
|
|
LOG("Error opening framebuffer device");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-12 10:21:24 +00:00
|
|
|
if (0 > ioctl(fd.get(), FBIOGET_VSCREENINFO, &sVi)) {
|
2012-04-05 16:15:19 +00:00
|
|
|
LOG("Error getting variable screeninfo");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-26 14:38:50 +00:00
|
|
|
sScreenSize = new gfxIntSize(sVi.xres, sVi.yres);
|
|
|
|
*aScreenSize = *sScreenSize;
|
2012-04-05 16:15:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-12-24 07:13:33 +00:00
|
|
|
} // namespace Framebuffer
|
|
|
|
} // namespace mozilla
|