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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 "Down and Right", "Down", "Down and Left", | 951 "Down and Right", "Down", "Down and Left", |
952 "Left", "Up and Left", NULL); | 952 "Left", "Up and Left", NULL); |
953 fAppMenu->assignKeyEquivalentToItem(itemID, 'k'); | 953 fAppMenu->assignKeyEquivalentToItem(itemID, 'k'); |
954 itemID = fAppMenu->appendAction("Save to PDF", sinkID); | 954 itemID = fAppMenu->appendAction("Save to PDF", sinkID); |
955 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); | 955 fAppMenu->assignKeyEquivalentToItem(itemID, 'e'); |
956 | 956 |
957 this->addMenu(fAppMenu); | 957 this->addMenu(fAppMenu); |
958 fSlideMenu = new SkOSMenu; | 958 fSlideMenu = new SkOSMenu; |
959 this->addMenu(fSlideMenu); | 959 this->addMenu(fSlideMenu); |
960 | 960 |
961 this->setColorType(kPMColor_SkColorType); | 961 this->setColorType(kN32_SkColorType); |
962 this->setVisibleP(true); | 962 this->setVisibleP(true); |
963 this->setClipToBounds(false); | 963 this->setClipToBounds(false); |
964 | 964 |
965 skiagm::GM::SetResourcePath(resourcePath); | 965 skiagm::GM::SetResourcePath(resourcePath); |
966 | 966 |
967 this->loadView((*fSamples[fCurrIndex])()); | 967 this->loadView((*fSamples[fCurrIndex])()); |
968 | 968 |
969 fPDFData = NULL; | 969 fPDFData = NULL; |
970 | 970 |
971 if (NULL == devManager) { | 971 if (NULL == devManager) { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 // to redraw. | 1442 // to redraw. |
1443 this->inval(NULL); | 1443 this->inval(NULL); |
1444 return; | 1444 return; |
1445 } | 1445 } |
1446 | 1446 |
1447 if (fRequestGrabImage) { | 1447 if (fRequestGrabImage) { |
1448 fRequestGrabImage = false; | 1448 fRequestGrabImage = false; |
1449 | 1449 |
1450 SkBaseDevice* device = orig->getDevice(); | 1450 SkBaseDevice* device = orig->getDevice(); |
1451 SkBitmap bmp; | 1451 SkBitmap bmp; |
1452 if (device->accessBitmap(false).copyTo(&bmp, kPMColor_SkColorType)) { | 1452 if (device->accessBitmap(false).copyTo(&bmp, kN32_SkColorType)) { |
1453 static int gSampleGrabCounter; | 1453 static int gSampleGrabCounter; |
1454 SkString name; | 1454 SkString name; |
1455 name.printf("sample_grab_%d.png", gSampleGrabCounter++); | 1455 name.printf("sample_grab_%d.png", gSampleGrabCounter++); |
1456 SkImageEncoder::EncodeFile(name.c_str(), bmp, | 1456 SkImageEncoder::EncodeFile(name.c_str(), bmp, |
1457 SkImageEncoder::kPNG_Type, 100); | 1457 SkImageEncoder::kPNG_Type, 100); |
1458 } | 1458 } |
1459 } | 1459 } |
1460 | 1460 |
1461 if (kPicture_DeviceType == fDeviceType) { | 1461 if (kPicture_DeviceType == fDeviceType) { |
1462 if (true) { | 1462 if (true) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 } | 1545 } |
1546 | 1546 |
1547 void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) { | 1547 void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) { |
1548 canvas->setDrawFilter(NULL); | 1548 canvas->setDrawFilter(NULL); |
1549 } | 1549 } |
1550 | 1550 |
1551 static SkColorType gColorTypeCycle[] = { | 1551 static SkColorType gColorTypeCycle[] = { |
1552 kUnknown_SkColorType, // none -> none | 1552 kUnknown_SkColorType, // none -> none |
1553 kUnknown_SkColorType, // a8 -> none | 1553 kUnknown_SkColorType, // a8 -> none |
1554 kARGB_4444_SkColorType, // 565 -> 4444 | 1554 kARGB_4444_SkColorType, // 565 -> 4444 |
1555 kPMColor_SkColorType, // 4444 -> 8888 | 1555 kN32_SkColorType, // 4444 -> 8888 |
1556 kRGB_565_SkColorType, // 8888 -> 565 | 1556 kRGB_565_SkColorType, // 8888 -> 565 |
1557 kRGB_565_SkColorType, // 8888 -> 565 | 1557 kRGB_565_SkColorType, // 8888 -> 565 |
1558 kUnknown_SkColorType, // index8 -> none | 1558 kUnknown_SkColorType, // index8 -> none |
1559 }; | 1559 }; |
1560 | 1560 |
1561 static SkColorType cycle_colortypes(SkColorType c) { | 1561 static SkColorType cycle_colortypes(SkColorType c) { |
1562 return gColorTypeCycle[c]; | 1562 return gColorTypeCycle[c]; |
1563 } | 1563 } |
1564 | 1564 |
1565 void SampleWindow::changeZoomLevel(float delta) { | 1565 void SampleWindow::changeZoomLevel(float delta) { |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 SkGraphics::Init(); | 2562 SkGraphics::Init(); |
2563 SkEvent::Init(); | 2563 SkEvent::Init(); |
2564 } | 2564 } |
2565 | 2565 |
2566 // FIXME: this should be in a header | 2566 // FIXME: this should be in a header |
2567 void application_term(); | 2567 void application_term(); |
2568 void application_term() { | 2568 void application_term() { |
2569 SkEvent::Term(); | 2569 SkEvent::Term(); |
2570 SkGraphics::Term(); | 2570 SkGraphics::Term(); |
2571 } | 2571 } |
OLD | NEW |