OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkOSWindow_SDL.h" | 8 #include "SkOSWindow_SDL.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 #include "SkGLCanvas.h" | 11 #include "SkGLCanvas.h" |
12 #include "SkOSMenu.h" | 12 #include "SkOSMenu.h" |
13 #include "SkTime.h" | 13 #include "SkTime.h" |
14 | 14 |
15 static void post_SkEvent_event() { | 15 static void post_SkEvent_event() { |
16 SDL_Event evt; | 16 SDL_Event evt; |
17 evt.type = SDL_USEREVENT; | 17 evt.type = SDL_USEREVENT; |
18 evt.user.type = SDL_USEREVENT; | 18 evt.user.type = SDL_USEREVENT; |
19 evt.user.code = 0; | 19 evt.user.code = 0; |
20 evt.user.data1 = NULL; | 20 evt.user.data1 = NULL; |
21 evt.user.data2 = NULL; | 21 evt.user.data2 = NULL; |
22 SDL_PushEvent(&evt); | 22 SDL_PushEvent(&evt); |
23 } | 23 } |
24 | 24 |
25 static bool skia_setBitmapFromSurface(SkBitmap* dst, SDL_Surface* src) { | 25 static bool skia_setBitmapFromSurface(SkBitmap* dst, SDL_Surface* src) { |
26 SkBitmap::Config config; | 26 SkColorType ct; |
| 27 SkAlphaType at; |
27 | 28 |
28 switch (src->format->BytesPerPixel) { | 29 switch (src->format->BytesPerPixel) { |
29 case 2: | 30 case 2: |
30 config = SkBitmap::kRGB_565_Config; | 31 ct = kRGB_565_SkColorType; |
| 32 at = kOpaque_SkAlphaType; |
31 break; | 33 break; |
32 case 4: | 34 case 4: |
33 config = SkBitmap::kARGB_8888_Config; | 35 ct = kN32_SkColorType; |
| 36 at = kPremul_SkAlphaType; |
34 break; | 37 break; |
35 default: | 38 default: |
36 return false; | 39 return false; |
37 } | 40 } |
38 | 41 |
39 dst->setConfig(config, src->w, src->h, src->pitch); | 42 return dst->installPixels(SkImageInfo::Make(src->w, src->h, ct, at), src->pi
xels, src->pitch); |
40 dst->setPixels(src->pixels); | |
41 return true; | |
42 } | 43 } |
43 | 44 |
44 SkOSWindow::SkOSWindow(void* screen) { | 45 SkOSWindow::SkOSWindow(void* screen) { |
45 fScreen = reinterpret_cast<SDL_Surface*>(screen); | 46 fScreen = reinterpret_cast<SDL_Surface*>(screen); |
46 this->resize(fScreen->w, fScreen->h); | 47 this->resize(fScreen->w, fScreen->h); |
47 | 48 |
48 uint32_t rmask = SK_R32_MASK << SK_R32_SHIFT; | 49 uint32_t rmask = SK_R32_MASK << SK_R32_SHIFT; |
49 uint32_t gmask = SK_G32_MASK << SK_G32_SHIFT; | 50 uint32_t gmask = SK_G32_MASK << SK_G32_SHIFT; |
50 uint32_t bmask = SK_B32_MASK << SK_B32_SHIFT; | 51 uint32_t bmask = SK_B32_MASK << SK_B32_SHIFT; |
51 uint32_t amask = SK_A32_MASK << SK_A32_SHIFT; | 52 uint32_t amask = SK_A32_MASK << SK_A32_SHIFT; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 return 0; | 218 return 0; |
218 } | 219 } |
219 | 220 |
220 void SkEvent::SignalQueueTimer(SkMSec delay) | 221 void SkEvent::SignalQueueTimer(SkMSec delay) |
221 { | 222 { |
222 SDL_SetTimer(0, NULL); | 223 SDL_SetTimer(0, NULL); |
223 if (delay) { | 224 if (delay) { |
224 SDL_SetTimer(delay, timer_callback); | 225 SDL_SetTimer(delay, timer_callback); |
225 } | 226 } |
226 } | 227 } |
OLD | NEW |