зеркало из https://github.com/mozilla/pjs.git
bug 706383 - Save screenshot in bundle, clean up old unused code r=dougt
This commit is contained in:
Родитель
ca6f6c06ff
Коммит
6342477bcb
|
@ -75,7 +75,6 @@ public class GeckoEvent {
|
|||
public static final int SURFACE_DESTROYED = 14;
|
||||
public static final int GECKO_EVENT_SYNC = 15;
|
||||
public static final int ACTIVITY_START = 17;
|
||||
public static final int SAVE_STATE = 18;
|
||||
public static final int BROADCAST = 19;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
|
|
|
@ -491,11 +491,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
|||
break;
|
||||
}
|
||||
|
||||
case SAVE_STATE: {
|
||||
ReadCharactersField(jenv);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -531,7 +531,6 @@ public:
|
|||
GECKO_EVENT_SYNC = 15,
|
||||
FORCED_RESIZE = 16,
|
||||
ACTIVITY_START = 17,
|
||||
SAVE_STATE = 18,
|
||||
BROADCAST = 19,
|
||||
dummy_java_enum_list_end
|
||||
};
|
||||
|
|
|
@ -796,82 +796,6 @@ nsWindow::GetThebesSurface()
|
|||
return new gfxImageSurface(gfxIntSize(5,5), gfxImageSurface::ImageFormatRGB24);
|
||||
}
|
||||
|
||||
|
||||
class DrawToFileRunnable : public nsRunnable {
|
||||
public:
|
||||
DrawToFileRunnable(nsWindow* win, const nsAString &path) {
|
||||
mPath = path;
|
||||
mWindow = win;
|
||||
}
|
||||
NS_IMETHOD Run() {
|
||||
mWindow->DrawToFile(mPath);
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
nsString mPath;
|
||||
nsRefPtr<nsWindow> mWindow;
|
||||
};
|
||||
|
||||
bool
|
||||
nsWindow::DrawToFile(const nsAString &path)
|
||||
{
|
||||
if (!IsTopLevel() || !mIsVisible) {
|
||||
ALOG("### DrawToFile works only for a visible toplevel window!");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (GetLayerManager(nsnull)->GetBackendType() != LayerManager::LAYERS_BASIC) {
|
||||
ALOG("### DrawToFile works only for a basic layers!");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxImageSurface> imgSurface =
|
||||
new gfxImageSurface(gfxIntSize(mBounds.width, mBounds.height),
|
||||
gfxImageSurface::ImageFormatARGB32);
|
||||
|
||||
if (imgSurface->CairoStatus()) {
|
||||
ALOG("### Failed to create a valid surface");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsIntRect boundsRect(0, 0, mBounds.width, mBounds.height);
|
||||
bool result = DrawTo(imgSurface, boundsRect);
|
||||
NS_ENSURE_TRUE(result, PR_FALSE);
|
||||
|
||||
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance("@mozilla.org/image/encoder;2?type=image/png");
|
||||
NS_ENSURE_TRUE(encoder, PR_FALSE);
|
||||
|
||||
encoder->InitFromData(imgSurface->Data(),
|
||||
imgSurface->Stride() * mBounds.height,
|
||||
mBounds.width,
|
||||
mBounds.height,
|
||||
imgSurface->Stride(),
|
||||
imgIEncoder::INPUT_FORMAT_HOSTARGB,
|
||||
EmptyString());
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(path, true, getter_AddRefs(file));
|
||||
NS_ENSURE_TRUE(file, PR_FALSE);
|
||||
|
||||
PRUint32 length;
|
||||
encoder->Available(&length);
|
||||
|
||||
nsCOMPtr<nsIOutputStream> outputStream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), file);
|
||||
NS_ENSURE_TRUE(outputStream, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
|
||||
NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream),
|
||||
outputStream, length);
|
||||
NS_ENSURE_TRUE(bufferedOutputStream, PR_FALSE);
|
||||
|
||||
PRUint32 numWritten;
|
||||
bufferedOutputStream->WriteFrom(encoder, length, &numWritten);
|
||||
NS_ENSURE_SUCCESS(length == numWritten, PR_FALSE);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
||||
{
|
||||
|
@ -1024,14 +948,6 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
|||
AndroidBridge::Bridge()->AcknowledgeEventSync();
|
||||
break;
|
||||
|
||||
case AndroidGeckoEvent::SAVE_STATE:
|
||||
{
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsRefPtr<DrawToFileRunnable> runnable = new DrawToFileRunnable(win, ae->Characters());
|
||||
NS_NewThread(getter_AddRefs(thread), runnable);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -177,8 +177,6 @@ public:
|
|||
static bool sAccessibilityEnabled;
|
||||
#endif
|
||||
|
||||
bool DrawToFile(const nsAString &path);
|
||||
|
||||
protected:
|
||||
void BringToFront();
|
||||
nsWindow *FindTopLevel();
|
||||
|
|
Загрузка…
Ссылка в новой задаче