The screen shot's framebuffer is received from qemu on Linux/Windows.
But on Mac, it is received from shared memory.
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
package org.tizen.emulator.skin;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.exception.ScreenShotException;
+import org.tizen.emulator.skin.image.ImageRegistry.IconName;
+import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.mode.SkinMode;
+import org.tizen.emulator.skin.screenshot.SdlScreenShotWindow;
+import org.tizen.emulator.skin.util.SkinUtil;
public class EmulatorSdlSkin extends EmulatorSkin {
+ private Logger logger = SkinLogger.getSkinLogger(
+ EmulatorSdlSkin.class).getLogger();
+
/**
* Constructor
*/
super(config, mode, isOnTop);
}
+ protected void openScreenShotWindow() {
+ if (screenShotDialog != null) {
+ return;
+ }
+
+ try {
+ screenShotDialog = new SdlScreenShotWindow(shell, communicator, this, config,
+ imageRegistry.getIcon(IconName.SCREENSHOT));
+ screenShotDialog.open();
+
+ } catch (ScreenShotException ex) {
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ SkinUtil.openMessage(shell, null,
+ "Fail to create a screen shot.", SWT.ICON_ERROR, config);
+
+ } catch (Exception ex) {
+ // defense exception handling.
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ String errorMessage = "Internal Error.\n[" + ex.getMessage() + "]";
+ SkinUtil.openMessage(shell, null, errorMessage, SWT.ICON_ERROR, config);
+
+ } finally {
+ screenShotDialog = null;
+ }
+ }
+
}
package org.tizen.emulator.skin;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.exception.ScreenShotException;
+import org.tizen.emulator.skin.image.ImageRegistry.IconName;
+import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.mode.SkinMode;
+import org.tizen.emulator.skin.screenshot.ShmScreenShotWindow;
+import org.tizen.emulator.skin.util.SkinUtil;
public class EmulatorShmSkin extends EmulatorSkin {
+ private Logger logger = SkinLogger.getSkinLogger(
+ EmulatorShmSkin.class).getLogger();
+
public static final int RED_MASK = 0x00FF0000;
public static final int GREEN_MASK = 0x0000FF00;
public static final int BLUE_MASK = 0x000000FF;
return ret;
}
+
+ protected void openScreenShotWindow() {
+ if (screenShotDialog != null) {
+ return;
+ }
+
+ try {
+ screenShotDialog = new ShmScreenShotWindow(shell, communicator, this, config,
+ imageRegistry.getIcon(IconName.SCREENSHOT));
+ screenShotDialog.open();
+
+ } catch (ScreenShotException ex) {
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ SkinUtil.openMessage(shell, null,
+ "Fail to create a screen shot.", SWT.ICON_ERROR, config);
+
+ } catch (Exception ex) {
+ // defense exception handling.
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ String errorMessage = "Internal Error.\n[" + ex.getMessage() + "]";
+ SkinUtil.openMessage(shell, null, errorMessage, SWT.ICON_ERROR, config);
+
+ } finally {
+ screenShotDialog = null;
+ }
+ }
}
private Logger logger = SkinLogger.getSkinLogger( EmulatorSkin.class ).getLogger();
protected EmulatorConfig config;
- private Shell shell;
- private ImageRegistry imageRegistry;
+ protected Shell shell;
+ protected ImageRegistry imageRegistry;
protected Canvas lcdCanvas;
private SkinMode skinMode;
private Image currentImage;
private boolean isShutdownRequested;
private boolean isAboutToReopen;
private boolean isOnTop;
- private boolean isScreenShotOpened;
private boolean isOnUsbKbd;
- private ScreenShotDialog screenShotDialog;
+ protected ScreenShotDialog screenShotDialog;
private Menu contextMenu;
- private SocketCommunicator communicator;
+ protected SocketCommunicator communicator;
private long windowHandleId;
private Listener shellCloseListener;
this.shell.open();
// logic only for reopen case ///////
- if ( isScreenShotOpened && ( null != screenShotDialog ) ) {
- try {
- screenShotDialog.setReserveImage( false );
- screenShotDialog.open();
- } finally {
- isScreenShotOpened = false;
- }
- }
+// if ( isScreenShotOpened && ( null != screenShotDialog ) ) {
+// try {
+// screenShotDialog.setReserveImage( false );
+// screenShotDialog.open();
+// } finally {
+// isScreenShotOpened = false;
+// }
+// }
// ///////////////////////////////////
while ( !shell.isDisposed() ) {
if ( !isAboutToReopen ) {
- if ( isScreenShotOpened && ( null != screenShotDialog ) ) {
+ if (null != screenShotDialog) {
Shell scShell = screenShotDialog.getShell();
if ( !scShell.isDisposed() ) {
scShell.close();
}
+ screenShotDialog = null;
}
// save config only for emulator close
return true;
}
+ protected void openScreenShotWindow() {
+ //TODO:
+ }
+
private void addMenuItems( final Shell shell, final Menu menu ) {
/* Emulator detail info menu */
@Override
public void widgetSelected( SelectionEvent e ) {
-
- if ( isScreenShotOpened ) {
- return;
- }
-
- try {
-
- isScreenShotOpened = true;
-
- screenShotDialog = new ScreenShotDialog( shell, communicator, EmulatorSkin.this, config,
- imageRegistry.getIcon(IconName.SCREENSHOT) );
- screenShotDialog.open();
-
- } catch ( ScreenShotException ex ) {
-
- logger.log( Level.SEVERE, ex.getMessage(), ex );
- SkinUtil.openMessage( shell, null, "Fail to create a screen shot.", SWT.ICON_ERROR, config );
-
- } catch ( Exception ex ) {
-
- // defense exception handling.
- logger.log( Level.SEVERE, ex.getMessage(), ex );
- String errorMessage = "Internal Error.\n[" + ex.getMessage() + "]";
- SkinUtil.openMessage( shell, null, errorMessage, SWT.ICON_ERROR, config );
-
- } finally {
- isScreenShotOpened = false;
- }
-
+ openScreenShotWindow();
}
} );
private Logger logger = SkinLogger.getSkinLogger( ScreenShotDialog.class ).getLogger();
- private PaletteData paletteData;
- private Image image;
- private Canvas imageCanvas;
+ protected PaletteData paletteData;
+ protected Image image;
+ protected Canvas imageCanvas;
private Shell shell;
private ScrolledComposite scrollComposite;
private Label label;
- private SocketCommunicator communicator;
+ protected SocketCommunicator communicator;
private EmulatorSkin emulatorSkin;
- private EmulatorConfig config;
+ protected EmulatorConfig config;
private RotationInfo currentRotation;
private boolean reserveImage;
arrageImageLayout();
}
- private void capture() throws ScreenShotException {
-
- DataTranfer dataTranfer = communicator.sendToQEMU( SendCommand.SCREEN_SHOT, null, true );
- byte[] receivedData = communicator.getReceivedData( dataTranfer );
-
- if ( null != receivedData ) {
-
- if ( null != this.image ) {
- this.image.dispose();
- }
-
- int width = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
- int height = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
- ImageData imageData = new ImageData( width , height, COLOR_DEPTH, paletteData, 1, receivedData );
-
- RotationInfo rotation = getCurrentRotation();
- imageData = rotateImageData( imageData, rotation );
-
- this.image = new Image( Display.getDefault(), imageData );
-
- imageCanvas.redraw();
-
- } else {
- throw new ScreenShotException( "Fail to get image data." );
- }
-
+ protected void capture() throws ScreenShotException {
}
private double getScaleLevel() {
}
- private ImageData rotateImageData( ImageData srcData, RotationInfo rotation ) {
+ protected ImageData rotateImageData( ImageData srcData, RotationInfo rotation ) {
int direction = SWT.NONE;
}
- private RotationInfo getCurrentRotation() {
+ protected RotationInfo getCurrentRotation() {
short currentRotationId = emulatorSkin.getCurrentRotationId();
RotationInfo rotationInfo = RotationInfo.getValue( currentRotationId );
return rotationInfo;
--- /dev/null
+/**
+ * Capture a screenshot of the Emulator framebuffer
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.screenshot;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.EmulatorSdlSkin;
+import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
+import org.tizen.emulator.skin.exception.ScreenShotException;
+import org.tizen.emulator.skin.log.SkinLogger;
+
+public class SdlScreenShotWindow extends ScreenShotDialog {
+ private Logger logger = SkinLogger.getSkinLogger(
+ SdlScreenShotWindow.class).getLogger();
+
+ /**
+ * @brief constructor
+ * @param Image icon : screenshot window icon resource
+ */
+ public SdlScreenShotWindow(Shell parent,
+ SocketCommunicator communicator, EmulatorSdlSkin emulatorSkin,
+ EmulatorConfig config, Image icon) throws ScreenShotException {
+ super(parent, communicator, emulatorSkin, config, icon);
+ }
+
+ protected void capture() throws ScreenShotException {
+ DataTranfer dataTranfer = communicator.sendToQEMU( SendCommand.SCREEN_SHOT, null, true );
+ byte[] receivedData = communicator.getReceivedData( dataTranfer );
+
+ if ( null != receivedData ) {
+
+ if ( null != this.image ) {
+ this.image.dispose();
+ }
+
+ int width = config.getArgInt( ArgsConstants.RESOLUTION_WIDTH );
+ int height = config.getArgInt( ArgsConstants.RESOLUTION_HEIGHT );
+ ImageData imageData = new ImageData( width , height, COLOR_DEPTH, paletteData, 1, receivedData );
+
+ RotationInfo rotation = getCurrentRotation();
+ imageData = rotateImageData( imageData, rotation );
+
+ this.image = new Image( Display.getDefault(), imageData );
+
+ imageCanvas.redraw();
+
+ } else {
+ throw new ScreenShotException( "Fail to get image data." );
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Capture a screenshot of the Emulator framebuffer
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.screenshot;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.EmulatorShmSkin;
+import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
+import org.tizen.emulator.skin.exception.ScreenShotException;
+import org.tizen.emulator.skin.log.SkinLogger;
+
+public class ShmScreenShotWindow extends ScreenShotDialog {
+ private Logger logger = SkinLogger.getSkinLogger(
+ ShmScreenShotWindow.class).getLogger();
+
+ private EmulatorShmSkin emulatorSkin;
+
+ /**
+ * @brief constructor
+ * @param Image icon : screenshot window icon resource
+ */
+ public ShmScreenShotWindow(Shell parent,
+ SocketCommunicator communicator, EmulatorShmSkin emulatorSkin,
+ EmulatorConfig config, Image icon) throws ScreenShotException {
+ super(parent, communicator, emulatorSkin, config, icon);
+
+ this.emulatorSkin = emulatorSkin;
+ }
+
+ protected void capture() throws ScreenShotException {
+ int width = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH);
+ int height = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT);
+
+ int[] array = new int[width * height];
+ //TODO:
+ //int result = emulatorSkin.getPixels(array); //from shared memory
+ //logger.info("getPixels navtive function returned " + result);
+
+ ImageData imageData = new ImageData(width, height, COLOR_DEPTH, paletteData);
+ for (int i = 0; i < height; i++) {
+ imageData.setPixels(0, i, width, array, i * width);
+ }
+
+ RotationInfo rotation = getCurrentRotation();
+ imageData = rotateImageData(imageData, rotation);
+
+ if (image != null) {
+ image.dispose();
+ }
+ image = new Image(Display.getDefault(), imageData);
+ imageCanvas.redraw();
+ }
+}
\ No newline at end of file