diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-05-31 07:14:21 +0900 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-05-31 07:14:21 +0900 |
| commit | 8a5ac0ac095d09564aecb340d4bf58bbecfe63c9 (patch) | |
| tree | d9656fef9e2806858dfa31f7b50e96c392267b87 /src/skia-image.cpp | |
| parent | 636f6a31c35d6d1825eabc92b91cedb6c12b4906 (diff) | |
| parent | 11ce9a1775b62ce2d199a4ab0f4f82b92603b483 (diff) | |
Merge pull request #67 from Samsung/Issue_65
Create window for image backend.
ref: https://github.com/Samsung/caskbench/issues/65
Diffstat (limited to 'src/skia-image.cpp')
| -rw-r--r-- | src/skia-image.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/skia-image.cpp b/src/skia-image.cpp index bb20612..67864bf 100644 --- a/src/skia-image.cpp +++ b/src/skia-image.cpp @@ -12,14 +12,38 @@ #include <SkBitmapDevice.h> #include "image.h" -#include "device_config.h" static image_state_t *state; +SkBitmap skia_bitmap; + +static bool convertBitmapToXImage(const SkBitmap& bitmap) { + sk_bzero(&state->image, sizeof(state->image)); + + int bitsPerPixel = bitmap.bytesPerPixel() * 8; + state->image.width = bitmap.width(); + state->image.height = bitmap.height(); + state->image.format = ZPixmap; + state->image.data = (char*) bitmap.getPixels(); + state->image.byte_order = LSBFirst; + state->image.bitmap_unit = 4 * 8; + state->image.bitmap_bit_order = LSBFirst; + state->image.bitmap_pad = 4 * 8; + state->image.depth = 32; + state->image.bytes_per_line = bitmap.width() * 4; + state->image.bits_per_pixel = 4 * 8; + return XInitImage(&state->image); +} + SkBaseDevice * create_skia_device_image (const device_config_t& config) { - SkBitmap skia_bitmap; + state = (image_state_t*) malloc (sizeof (image_state_t)); + if (!state) { + warnx ("Out of memory\n"); + return NULL; + } + if (!skia_bitmap.setConfig(SkBitmap::kARGB_8888_Config, config.width, config.height)) { warnx("Failed to configure bitmap\n"); @@ -32,18 +56,28 @@ create_skia_device_image (const device_config_t& config) warnx("Failed to allocate pixels\n"); return NULL; } + + if (!createImageWindow(state, config)) { + cleanup_state_image(state); + return NULL; + } + return new SkBitmapDevice (skia_bitmap); } void destroy_skia_image(void) { + destroyImageWindow(state); cleanup_state_image(state); } void update_skia_image(void) { + if (convertBitmapToXImage (skia_bitmap)) { + updateImageWindow(state); + } } /* |