OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkWindow.h" | 8 #include "SkWindow.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkOSMenu.h" | 10 #include "SkOSMenu.h" |
11 #include "SkSurface.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() | 17 SkWindow::SkWindow() |
18 : fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) | 18 : fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) |
19 , fFocusView(NULL) | 19 , fFocusView(NULL) |
20 { | 20 { |
21 fClicks.reset(); | 21 fClicks.reset(); |
22 fWaitingOnInval = false; | 22 fWaitingOnInval = false; |
23 | |
24 #ifdef SK_BUILD_FOR_WINCE | |
25 fColorType = kRGB_565_SkColorType; | |
26 #else | |
27 fColorType = kN32_SkColorType; | 23 fColorType = kN32_SkColorType; |
28 #endif | |
29 | |
30 fMatrix.reset(); | 24 fMatrix.reset(); |
31 } | 25 } |
32 | 26 |
33 SkWindow::~SkWindow() { | 27 SkWindow::~SkWindow() { |
34 fClicks.deleteAll(); | 28 fClicks.deleteAll(); |
35 fMenus.deleteAll(); | 29 fMenus.deleteAll(); |
36 } | 30 } |
37 | 31 |
38 SkSurface* SkWindow::createSurface() { | 32 SkSurface* SkWindow::createSurface() { |
39 const SkBitmap& bm = this->getBitmap(); | 33 const SkBitmap& bm = this->getBitmap(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 this->onHandleInval(ir); | 92 this->onHandleInval(ir); |
99 return true; | 93 return true; |
100 } | 94 } |
101 | 95 |
102 void SkWindow::forceInvalAll() { | 96 void SkWindow::forceInvalAll() { |
103 fDirtyRgn.setRect(0, 0, | 97 fDirtyRgn.setRect(0, 0, |
104 SkScalarCeilToInt(this->width()), | 98 SkScalarCeilToInt(this->width()), |
105 SkScalarCeilToInt(this->height())); | 99 SkScalarCeilToInt(this->height())); |
106 } | 100 } |
107 | 101 |
108 #if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN) | |
109 #include <windows.h> | |
110 #include <gx.h> | |
111 extern GXDisplayProperties gDisplayProps; | |
112 #endif | |
113 | |
114 #ifdef SK_SIMULATE_FAILED_MALLOC | 102 #ifdef SK_SIMULATE_FAILED_MALLOC |
115 extern bool gEnableControlledThrow; | 103 extern bool gEnableControlledThrow; |
116 #endif | 104 #endif |
117 | 105 |
118 bool SkWindow::update(SkIRect* updateArea) { | 106 bool SkWindow::update(SkIRect* updateArea) { |
119 if (!fDirtyRgn.isEmpty()) { | 107 if (!fDirtyRgn.isEmpty()) { |
120 #if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN) | |
121 SkBitmap bm = this->getBitmap(); | |
122 | |
123 char* buffer = (char*)GXBeginDraw(); | |
124 SkASSERT(buffer); | |
125 | |
126 RECT rect; | |
127 GetWindowRect((HWND)((SkOSWindow*)this)->getHWND(), &rect); | |
128 buffer += rect.top * gDisplayProps.cbyPitch + rect.left * gDisplayProps.
cbxPitch; | |
129 | |
130 bm.setPixels(buffer); | |
131 #endif | |
132 | |
133 SkAutoTUnref<SkSurface> surface(this->createSurface()); | 108 SkAutoTUnref<SkSurface> surface(this->createSurface()); |
134 SkCanvas* canvas = surface->getCanvas(); | 109 SkCanvas* canvas = surface->getCanvas(); |
135 | 110 |
136 canvas->clipRegion(fDirtyRgn); | 111 canvas->clipRegion(fDirtyRgn); |
137 if (updateArea) { | 112 if (updateArea) { |
138 *updateArea = fDirtyRgn.getBounds(); | 113 *updateArea = fDirtyRgn.getBounds(); |
139 } | 114 } |
140 | 115 |
141 SkAutoCanvasRestore acr(canvas, true); | 116 SkAutoCanvasRestore acr(canvas, true); |
142 canvas->concat(fMatrix); | 117 canvas->concat(fMatrix); |
(...skipping 11 matching lines...) Expand all Loading... |
154 //} | 129 //} |
155 //catch (...) { | 130 //catch (...) { |
156 //} | 131 //} |
157 #else | 132 #else |
158 this->draw(canvas); | 133 this->draw(canvas); |
159 #endif | 134 #endif |
160 #ifdef SK_SIMULATE_FAILED_MALLOC | 135 #ifdef SK_SIMULATE_FAILED_MALLOC |
161 gEnableControlledThrow = false; | 136 gEnableControlledThrow = false; |
162 #endif | 137 #endif |
163 | 138 |
164 #if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN) | |
165 GXEndDraw(); | |
166 #endif | |
167 | |
168 return true; | 139 return true; |
169 } | 140 } |
170 return false; | 141 return false; |
171 } | 142 } |
172 | 143 |
173 bool SkWindow::handleChar(SkUnichar uni) { | 144 bool SkWindow::handleChar(SkUnichar uni) { |
174 if (this->onHandleChar(uni)) | 145 if (this->onHandleChar(uni)) |
175 return true; | 146 return true; |
176 | 147 |
177 SkView* focus = this->getFocusView(); | 148 SkView* focus = this->getFocusView(); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 329 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
359 desc.fSampleCnt = attachmentInfo.fSampleCount; | 330 desc.fSampleCnt = attachmentInfo.fSampleCount; |
360 desc.fStencilBits = attachmentInfo.fStencilBits; | 331 desc.fStencilBits = attachmentInfo.fStencilBits; |
361 GrGLint buffer; | 332 GrGLint buffer; |
362 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 333 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
363 desc.fRenderTargetHandle = buffer; | 334 desc.fRenderTargetHandle = buffer; |
364 return grContext->textureProvider()->wrapBackendRenderTarget(desc); | 335 return grContext->textureProvider()->wrapBackendRenderTarget(desc); |
365 } | 336 } |
366 | 337 |
367 #endif | 338 #endif |
OLD | NEW |