зеркало из https://github.com/mozilla/moz-skia.git
create offscreen surface so we can set its RGB ordering to match our internals
git-svn-id: http://skia.googlecode.com/svn/trunk@187 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
437f35e5ec
Коммит
c3a8c5fb38
|
@ -22,7 +22,8 @@
|
|||
|
||||
class SkOSWindow : public SkWindow {
|
||||
public:
|
||||
SkOSWindow(void* surface);
|
||||
SkOSWindow(void* screen);
|
||||
virtual ~SkOSWindow();
|
||||
|
||||
static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
|
||||
|
||||
|
@ -36,6 +37,7 @@ protected:
|
|||
virtual void onSetTitle(const char[]);
|
||||
|
||||
private:
|
||||
SDL_Surface* fScreen;
|
||||
SDL_Surface* fSurface;
|
||||
|
||||
void doDraw();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "SkOSWindow_SDL.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkOSMenu.h"
|
||||
#include "SkTime.h"
|
||||
|
||||
|
@ -32,9 +33,21 @@ static bool skia_setBitmapFromSurface(SkBitmap* dst, SDL_Surface* src) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SkOSWindow::SkOSWindow(void* surface) {
|
||||
fSurface = reinterpret_cast<SDL_Surface*>(surface);
|
||||
this->resize(fSurface->w, fSurface->h);
|
||||
SkOSWindow::SkOSWindow(void* screen) {
|
||||
fScreen = reinterpret_cast<SDL_Surface*>(screen);
|
||||
this->resize(fScreen->w, fScreen->h);
|
||||
|
||||
uint32_t rmask = SK_R32_MASK << SK_R32_SHIFT;
|
||||
uint32_t gmask = SK_G32_MASK << SK_G32_SHIFT;
|
||||
uint32_t bmask = SK_B32_MASK << SK_B32_SHIFT;
|
||||
uint32_t amask = SK_A32_MASK << SK_A32_SHIFT;
|
||||
|
||||
fSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, fScreen->w, fScreen->h, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
}
|
||||
|
||||
SkOSWindow::~SkOSWindow() {
|
||||
SDL_FreeSurface(fSurface);
|
||||
}
|
||||
|
||||
void SkOSWindow::doDraw() {
|
||||
|
@ -54,7 +67,12 @@ void SkOSWindow::doDraw() {
|
|||
if ( SDL_MUSTLOCK(fSurface) ) {
|
||||
SDL_UnlockSurface(fSurface);
|
||||
}
|
||||
SDL_UpdateRect(fSurface, 0, 0, fSurface->w, fSurface->h);
|
||||
|
||||
int result = SDL_BlitSurface(fSurface, NULL, fScreen, NULL);
|
||||
if (result) {
|
||||
SkDebugf("------- SDL_BlitSurface returned %d\n", result);
|
||||
}
|
||||
SDL_UpdateRect(fScreen, 0, 0, fScreen->w, fScreen->h);
|
||||
}
|
||||
|
||||
static SkKey find_skkey(SDLKey src) {
|
||||
|
|
|
@ -15,10 +15,13 @@
|
|||
#include "SkApplication.h"
|
||||
#include "SkWindow.h"
|
||||
|
||||
#define WINDOW_WIDTH 800
|
||||
#define WINDOW_HEIGHT 600
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
|
||||
SDL_Surface *screen;
|
||||
Uint8 video_bpp = 0;
|
||||
Uint8 video_bpp = 32;
|
||||
Uint32 videoflags = SDL_SWSURFACE;
|
||||
SDL_Event event;
|
||||
|
||||
|
@ -30,14 +33,13 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
/* Set 640x480 video mode */
|
||||
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
||||
if (screen == NULL) {
|
||||
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||
video_bpp, SDL_GetError());
|
||||
screen=SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, video_bpp, videoflags);
|
||||
if (screen == NULL) {
|
||||
fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
application_init();
|
||||
SkOSWindow* skwin = create_sk_window(screen);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче