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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 fDeviceType = kGPU_DeviceType; | 775 fDeviceType = kGPU_DeviceType; |
776 #endif | 776 #endif |
777 #if SK_ANGLE && DEFAULT_TO_ANGLE | 777 #if SK_ANGLE && DEFAULT_TO_ANGLE |
778 fDeviceType = kANGLE_DeviceType; | 778 fDeviceType = kANGLE_DeviceType; |
779 #endif | 779 #endif |
780 | 780 |
781 fUseClip = false; | 781 fUseClip = false; |
782 fNClip = false; | 782 fNClip = false; |
783 fAnimating = false; | 783 fAnimating = false; |
784 fRotate = false; | 784 fRotate = false; |
| 785 fRotateAnimTime = 0; |
785 fPerspAnim = false; | 786 fPerspAnim = false; |
786 fPerspAnimTime = 0; | 787 fPerspAnimTime = 0; |
787 fRequestGrabImage = false; | 788 fRequestGrabImage = false; |
788 fPipeState = SkOSMenu::kOffState; | 789 fPipeState = SkOSMenu::kOffState; |
789 fTilingState = SkOSMenu::kOffState; | 790 fTilingState = SkOSMenu::kOffState; |
790 fTileCount.set(1, 1); | 791 fTileCount.set(1, 1); |
791 fMeasureFPS = false; | 792 fMeasureFPS = false; |
792 fLCDState = SkOSMenu::kMixedState; | 793 fLCDState = SkOSMenu::kMixedState; |
793 fAAState = SkOSMenu::kMixedState; | 794 fAAState = SkOSMenu::kMixedState; |
794 fFilterState = SkOSMenu::kMixedState; | 795 fFilterState = SkOSMenu::kMixedState; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 SkRegion inval; | 1403 SkRegion inval; |
1403 | 1404 |
1404 r.set(50, 50, 50+100, 50+100); | 1405 r.set(50, 50, 50+100, 50+100); |
1405 bm.scrollRect(&r, dx, dy, &inval); | 1406 bm.scrollRect(&r, dx, dy, &inval); |
1406 paint_rgn(bm, r, inval); | 1407 paint_rgn(bm, r, inval); |
1407 } | 1408 } |
1408 } | 1409 } |
1409 | 1410 |
1410 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { | 1411 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { |
1411 if (fRotate) { | 1412 if (fRotate) { |
| 1413 fRotateAnimTime += SampleCode::GetAnimSecondsDelta(); |
| 1414 |
1412 SkScalar cx = this->width() / 2; | 1415 SkScalar cx = this->width() / 2; |
1413 SkScalar cy = this->height() / 2; | 1416 SkScalar cy = this->height() / 2; |
1414 canvas->translate(cx, cy); | 1417 canvas->translate(cx, cy); |
1415 canvas->rotate(SkIntToScalar(30)); | 1418 canvas->rotate(fRotateAnimTime * 10); |
1416 canvas->translate(-cx, -cy); | 1419 canvas->translate(-cx, -cy); |
1417 } | 1420 } |
| 1421 |
1418 if (fPerspAnim) { | 1422 if (fPerspAnim) { |
1419 fPerspAnimTime += SampleCode::GetAnimSecondsDelta(); | 1423 fPerspAnimTime += SampleCode::GetAnimSecondsDelta(); |
1420 | 1424 |
1421 static const SkScalar gAnimPeriod = 10 * SK_Scalar1; | 1425 static const SkScalar gAnimPeriod = 10 * SK_Scalar1; |
1422 static const SkScalar gAnimMag = SK_Scalar1 / 1000; | 1426 static const SkScalar gAnimMag = SK_Scalar1 / 1000; |
1423 SkScalar t = SkScalarMod(fPerspAnimTime, gAnimPeriod); | 1427 SkScalar t = SkScalarMod(fPerspAnimTime, gAnimPeriod); |
1424 if (SkScalarFloorToInt(SkScalarDiv(fPerspAnimTime, gAnimPeriod)) & 0x1)
{ | 1428 if (SkScalarFloorToInt(SkScalarDiv(fPerspAnimTime, gAnimPeriod)) & 0x1)
{ |
1425 t = gAnimPeriod - t; | 1429 t = gAnimPeriod - t; |
1426 } | 1430 } |
1427 t = 2 * t - gAnimPeriod; | 1431 t = 2 * t - gAnimPeriod; |
1428 t = SkScalarMul(SkScalarDiv(t, gAnimPeriod), gAnimMag); | 1432 t = SkScalarMul(SkScalarDiv(t, gAnimPeriod), gAnimMag); |
1429 SkMatrix m; | 1433 SkMatrix m; |
1430 m.reset(); | 1434 m.reset(); |
1431 m.setPerspY(t); | 1435 m.setPerspY(t); |
1432 canvas->concat(m); | 1436 canvas->concat(m); |
1433 } | 1437 } |
1434 | 1438 |
1435 this->installDrawFilter(canvas); | 1439 this->installDrawFilter(canvas); |
1436 | 1440 |
1437 if (fMeasureFPS) { | 1441 if (fMeasureFPS) { |
1438 if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) { | 1442 if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) { |
1439 fMeasureFPS_StartTime = SkTime::GetMSecs(); | 1443 fMeasureFPS_StartTime = SkTime::GetMSecs(); |
1440 } | 1444 } |
1441 } else { | 1445 } else { |
1442 (void)SampleView::SetRepeatDraw(child, 1); | 1446 (void)SampleView::SetRepeatDraw(child, 1); |
1443 } | 1447 } |
1444 if (fPerspAnim) { | 1448 if (fPerspAnim || fRotate) { |
1445 this->inval(NULL); | 1449 this->inval(NULL); |
1446 } | 1450 } |
1447 } | 1451 } |
1448 | 1452 |
1449 void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) { | 1453 void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) { |
1450 canvas->setDrawFilter(NULL); | 1454 canvas->setDrawFilter(NULL); |
1451 } | 1455 } |
1452 | 1456 |
1453 static SkBitmap::Config gConfigCycle[] = { | 1457 static SkBitmap::Config gConfigCycle[] = { |
1454 SkBitmap::kNo_Config, // none -> none | 1458 SkBitmap::kNo_Config, // none -> none |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 this->inval(NULL); | 1761 this->inval(NULL); |
1758 break; | 1762 break; |
1759 case 'i': | 1763 case 'i': |
1760 this->zoomIn(); | 1764 this->zoomIn(); |
1761 break; | 1765 break; |
1762 case 'o': | 1766 case 'o': |
1763 this->zoomOut(); | 1767 this->zoomOut(); |
1764 break; | 1768 break; |
1765 case 'r': | 1769 case 'r': |
1766 fRotate = !fRotate; | 1770 fRotate = !fRotate; |
| 1771 fRotateAnimTime = 0; |
1767 this->inval(NULL); | 1772 this->inval(NULL); |
1768 this->updateTitle(); | 1773 this->updateTitle(); |
1769 return true; | 1774 return true; |
1770 case 'k': | 1775 case 'k': |
1771 fPerspAnim = !fPerspAnim; | 1776 fPerspAnim = !fPerspAnim; |
1772 this->inval(NULL); | 1777 this->inval(NULL); |
1773 this->updateTitle(); | 1778 this->updateTitle(); |
1774 return true; | 1779 return true; |
1775 #if SK_SUPPORT_GPU | 1780 #if SK_SUPPORT_GPU |
1776 case '\\': | 1781 case '\\': |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 SkGraphics::Init(); | 2473 SkGraphics::Init(); |
2469 SkEvent::Init(); | 2474 SkEvent::Init(); |
2470 } | 2475 } |
2471 | 2476 |
2472 // FIXME: this should be in a header | 2477 // FIXME: this should be in a header |
2473 void application_term(); | 2478 void application_term(); |
2474 void application_term() { | 2479 void application_term() { |
2475 SkEvent::Term(); | 2480 SkEvent::Term(); |
2476 SkGraphics::Term(); | 2481 SkGraphics::Term(); |
2477 } | 2482 } |
OLD | NEW |