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 #include "SampleApp.h" | 7 #include "SampleApp.h" |
8 | 8 |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 win->present(); | 299 win->present(); |
300 } | 300 } |
301 | 301 |
302 virtual void windowSizeChanged(SampleWindow* win) { | 302 virtual void windowSizeChanged(SampleWindow* win) { |
303 #if SK_SUPPORT_GPU | 303 #if SK_SUPPORT_GPU |
304 if (fCurContext) { | 304 if (fCurContext) { |
305 AttachmentInfo attachmentInfo; | 305 AttachmentInfo attachmentInfo; |
306 win->attach(fBackend, fMSAASampleCount, &attachmentInfo); | 306 win->attach(fBackend, fMSAASampleCount, &attachmentInfo); |
307 | 307 |
308 GrBackendRenderTargetDesc desc; | 308 GrBackendRenderTargetDesc desc; |
309 desc.fWidth = SkScalarRound(win->width()); | 309 desc.fWidth = SkScalarRoundToInt(win->width()); |
310 desc.fHeight = SkScalarRound(win->height()); | 310 desc.fHeight = SkScalarRoundToInt(win->height()); |
311 desc.fConfig = kSkia8888_GrPixelConfig; | 311 desc.fConfig = kSkia8888_GrPixelConfig; |
312 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 312 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
313 desc.fSampleCnt = attachmentInfo.fSampleCount; | 313 desc.fSampleCnt = attachmentInfo.fSampleCount; |
314 desc.fStencilBits = attachmentInfo.fStencilBits; | 314 desc.fStencilBits = attachmentInfo.fStencilBits; |
315 GrGLint buffer; | 315 GrGLint buffer; |
316 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 316 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
317 desc.fRenderTargetHandle = buffer; | 317 desc.fRenderTargetHandle = buffer; |
318 | 318 |
319 SkSafeUnref(fCurRenderTarget); | 319 SkSafeUnref(fCurRenderTarget); |
320 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); | 320 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 | 1307 |
1308 this->INHERITED::draw(canvas); | 1308 this->INHERITED::draw(canvas); |
1309 | 1309 |
1310 canvas->restoreToCount(count); | 1310 canvas->restoreToCount(count); |
1311 } | 1311 } |
1312 | 1312 |
1313 void SampleWindow::showZoomer(SkCanvas* canvas) { | 1313 void SampleWindow::showZoomer(SkCanvas* canvas) { |
1314 int count = canvas->save(); | 1314 int count = canvas->save(); |
1315 canvas->resetMatrix(); | 1315 canvas->resetMatrix(); |
1316 // Ensure the mouse position is on screen. | 1316 // Ensure the mouse position is on screen. |
1317 int width = SkScalarRound(this->width()); | 1317 int width = SkScalarRoundToInt(this->width()); |
1318 int height = SkScalarRound(this->height()); | 1318 int height = SkScalarRoundToInt(this->height()); |
1319 if (fMouseX >= width) fMouseX = width - 1; | 1319 if (fMouseX >= width) fMouseX = width - 1; |
1320 else if (fMouseX < 0) fMouseX = 0; | 1320 else if (fMouseX < 0) fMouseX = 0; |
1321 if (fMouseY >= height) fMouseY = height - 1; | 1321 if (fMouseY >= height) fMouseY = height - 1; |
1322 else if (fMouseY < 0) fMouseY = 0; | 1322 else if (fMouseY < 0) fMouseY = 0; |
1323 | 1323 |
1324 SkBitmap bitmap = capture_bitmap(canvas); | 1324 SkBitmap bitmap = capture_bitmap(canvas); |
1325 bitmap.lockPixels(); | 1325 bitmap.lockPixels(); |
1326 | 1326 |
1327 // Find the size of the zoomed in view, forced to be odd, so the examine
d pixel is in the middle. | 1327 // Find the size of the zoomed in view, forced to be odd, so the examine
d pixel is in the middle. |
1328 int zoomedWidth = (width >> 1) | 1; | 1328 int zoomedWidth = (width >> 1) | 1; |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 | 2032 |
2033 /////////////////////////////////////////////////////////////////////////////// | 2033 /////////////////////////////////////////////////////////////////////////////// |
2034 | 2034 |
2035 static const char gGestureClickType[] = "GestureClickType"; | 2035 static const char gGestureClickType[] = "GestureClickType"; |
2036 | 2036 |
2037 bool SampleWindow::onDispatchClick(int x, int y, Click::State state, | 2037 bool SampleWindow::onDispatchClick(int x, int y, Click::State state, |
2038 void* owner, unsigned modi) { | 2038 void* owner, unsigned modi) { |
2039 if (Click::kMoved_State == state) { | 2039 if (Click::kMoved_State == state) { |
2040 updatePointer(x, y); | 2040 updatePointer(x, y); |
2041 } | 2041 } |
2042 int w = SkScalarRound(this->width()); | 2042 int w = SkScalarRoundToInt(this->width()); |
2043 int h = SkScalarRound(this->height()); | 2043 int h = SkScalarRoundToInt(this->height()); |
2044 | 2044 |
2045 // check for the resize-box | 2045 // check for the resize-box |
2046 if (w - x < 16 && h - y < 16) { | 2046 if (w - x < 16 && h - y < 16) { |
2047 return false; // let the OS handle the click | 2047 return false; // let the OS handle the click |
2048 } | 2048 } |
2049 else if (fMagnify) { | 2049 else if (fMagnify) { |
2050 //it's only necessary to update the drawing if there's a click | 2050 //it's only necessary to update the drawing if there's a click |
2051 this->inval(NULL); | 2051 this->inval(NULL); |
2052 return false; //prevent dragging while magnify is enabled | 2052 return false; //prevent dragging while magnify is enabled |
2053 } else { | 2053 } else { |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 SkGraphics::Init(); | 2616 SkGraphics::Init(); |
2617 SkEvent::Init(); | 2617 SkEvent::Init(); |
2618 } | 2618 } |
2619 | 2619 |
2620 // FIXME: this should be in a header | 2620 // FIXME: this should be in a header |
2621 void application_term(); | 2621 void application_term(); |
2622 void application_term() { | 2622 void application_term() { |
2623 SkEvent::Term(); | 2623 SkEvent::Term(); |
2624 SkGraphics::Term(); | 2624 SkGraphics::Term(); |
2625 } | 2625 } |
OLD | NEW |