OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "SkWindow.h" | 8 #include "SkWindow.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | |
11 #include "SkOSMenu.h" | 10 #include "SkOSMenu.h" |
| 11 #include "SkSurface.h" |
12 #include "SkSystemEventTypes.h" | 12 #include "SkSystemEventTypes.h" |
13 #include "SkTime.h" | 13 #include "SkTime.h" |
14 | 14 |
15 #define SK_EventDelayInval "\xd" "n" "\xa" "l" | 15 #define SK_EventDelayInval "\xd" "n" "\xa" "l" |
16 | 16 |
17 SkWindow::SkWindow() : fFocusView(NULL) { | 17 SkWindow::SkWindow() : fFocusView(NULL) { |
18 fClicks.reset(); | 18 fClicks.reset(); |
19 fWaitingOnInval = false; | 19 fWaitingOnInval = false; |
20 | 20 |
21 #ifdef SK_BUILD_FOR_WINCE | 21 #ifdef SK_BUILD_FOR_WINCE |
22 fColorType = kRGB_565_SkColorType; | 22 fColorType = kRGB_565_SkColorType; |
23 #else | 23 #else |
24 fColorType = kN32_SkColorType; | 24 fColorType = kN32_SkColorType; |
25 #endif | 25 #endif |
26 | 26 |
27 fMatrix.reset(); | 27 fMatrix.reset(); |
28 } | 28 } |
29 | 29 |
30 SkWindow::~SkWindow() { | 30 SkWindow::~SkWindow() { |
31 fClicks.deleteAll(); | 31 fClicks.deleteAll(); |
32 fMenus.deleteAll(); | 32 fMenus.deleteAll(); |
33 } | 33 } |
34 | 34 |
35 SkCanvas* SkWindow::createCanvas() { | 35 SkSurface* SkWindow::createSurface() { |
36 return new SkCanvas(this->getBitmap()); | 36 const SkBitmap& bm = this->getBitmap(); |
| 37 return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes()); |
37 } | 38 } |
38 | 39 |
39 void SkWindow::setMatrix(const SkMatrix& matrix) { | 40 void SkWindow::setMatrix(const SkMatrix& matrix) { |
40 if (fMatrix != matrix) { | 41 if (fMatrix != matrix) { |
41 fMatrix = matrix; | 42 fMatrix = matrix; |
42 this->inval(NULL); | 43 this->inval(NULL); |
43 } | 44 } |
44 } | 45 } |
45 | 46 |
46 void SkWindow::preConcat(const SkMatrix& matrix) { | 47 void SkWindow::preConcat(const SkMatrix& matrix) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 char* buffer = (char*)GXBeginDraw(); | 120 char* buffer = (char*)GXBeginDraw(); |
120 SkASSERT(buffer); | 121 SkASSERT(buffer); |
121 | 122 |
122 RECT rect; | 123 RECT rect; |
123 GetWindowRect((HWND)((SkOSWindow*)this)->getHWND(), &rect); | 124 GetWindowRect((HWND)((SkOSWindow*)this)->getHWND(), &rect); |
124 buffer += rect.top * gDisplayProps.cbyPitch + rect.left * gDisplayProps.
cbxPitch; | 125 buffer += rect.top * gDisplayProps.cbyPitch + rect.left * gDisplayProps.
cbxPitch; |
125 | 126 |
126 bm.setPixels(buffer); | 127 bm.setPixels(buffer); |
127 #endif | 128 #endif |
128 | 129 |
129 SkAutoTUnref<SkCanvas> canvas(this->createCanvas()); | 130 SkAutoTUnref<SkSurface> surface(this->createSurface()); |
| 131 SkCanvas* canvas = surface->getCanvas(); |
130 | 132 |
131 canvas->clipRegion(fDirtyRgn); | 133 canvas->clipRegion(fDirtyRgn); |
132 if (updateArea) | 134 if (updateArea) |
133 *updateArea = fDirtyRgn.getBounds(); | 135 *updateArea = fDirtyRgn.getBounds(); |
134 | 136 |
135 SkAutoCanvasRestore acr(canvas, true); | 137 SkAutoCanvasRestore acr(canvas, true); |
136 canvas->concat(fMatrix); | 138 canvas->concat(fMatrix); |
137 | 139 |
138 // empty this now, so we can correctly record any inval calls that | 140 // empty this now, so we can correctly record any inval calls that |
139 // might be made during the draw call. | 141 // might be made during the draw call. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 fClicks.remove(index); | 331 fClicks.remove(index); |
330 handled = true; | 332 handled = true; |
331 } | 333 } |
332 break; | 334 break; |
333 default: | 335 default: |
334 // Do nothing | 336 // Do nothing |
335 break; | 337 break; |
336 } | 338 } |
337 return handled; | 339 return handled; |
338 } | 340 } |
OLD | NEW |