зеркало из https://github.com/mozilla/moz-skia.git
Added helper methods for changing samples, getting sample titles, and extracting pdf Data
http://codereview.appspot.com/4626073/ git-svn-id: http://skia.googlecode.com/svn/trunk@1704 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
2eff7e26c0
Коммит
501775e5ac
|
@ -410,7 +410,8 @@ SampleWindow::SampleWindow(void* hwnd) : INHERITED(hwnd) {
|
|||
if (this->height() && this->width()) {
|
||||
this->onSizeChange();
|
||||
}
|
||||
|
||||
|
||||
fPDFData = NULL;
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
testpdf();
|
||||
#endif
|
||||
|
@ -760,7 +761,7 @@ static void paint_rgn(const SkBitmap& bm, const SkIRect& r,
|
|||
canvas.clipRegion(inval);
|
||||
canvas.drawColor(0xFFFF8080);
|
||||
}
|
||||
|
||||
#include "SkData.h"
|
||||
void SampleWindow::afterChildren(SkCanvas* orig) {
|
||||
if (fSaveToPdf) {
|
||||
fSaveToPdf = false;
|
||||
|
@ -775,12 +776,19 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
|
|||
#ifdef ANDROID
|
||||
name.prepend("/sdcard/");
|
||||
#endif
|
||||
|
||||
#ifdef SK_BUILD_FOR_IOS
|
||||
SkDynamicMemoryWStream mstream;
|
||||
doc.emitPDF(&mstream);
|
||||
fPDFData = SkData::NewWithCopy(mstream.getStream(),mstream.getOffset());
|
||||
#endif
|
||||
SkFILEWStream stream(name.c_str());
|
||||
if (stream.isValid()) {
|
||||
doc.emitPDF(&stream);
|
||||
const char* desc = "File saved from Skia SampleApp";
|
||||
this->onPDFSaved(this->getTitle(), desc, name.c_str());
|
||||
}
|
||||
|
||||
delete fPdfCanvas;
|
||||
fPdfCanvas = NULL;
|
||||
|
||||
|
@ -939,6 +947,27 @@ bool SampleWindow::nextSample() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SampleWindow::goToSample(int i) {
|
||||
fCurrIndex = (i) % fSamples.count();
|
||||
this->loadView(fSamples[fCurrIndex]());
|
||||
return true;
|
||||
}
|
||||
|
||||
SkString SampleWindow::getSampleTitle(int i) {
|
||||
SkView* view = fSamples[i]();
|
||||
SkString title;
|
||||
SkEvent evt(gTitleEvtName);
|
||||
if (view->doQuery(&evt)) {
|
||||
title.set(evt.findString(gTitleEvtName));
|
||||
}
|
||||
view->unref();
|
||||
return title;
|
||||
}
|
||||
|
||||
int SampleWindow::sampleCount() {
|
||||
return fSamples.count();
|
||||
}
|
||||
|
||||
void SampleWindow::postAnimatingEvent() {
|
||||
if (fAnimating) {
|
||||
SkEvent* evt = new SkEvent(ANIMATING_EVENTTYPE);
|
||||
|
|
|
@ -33,6 +33,7 @@ class SkCanvas;
|
|||
class SkGpuCanvas;
|
||||
class SkPicture;
|
||||
class SkTypeface;
|
||||
class SkData;
|
||||
|
||||
enum SkTriState {
|
||||
kFalse_SkTriState,
|
||||
|
@ -58,9 +59,13 @@ public:
|
|||
void changeZoomLevel(float delta);
|
||||
bool nextSample();
|
||||
bool previousSample();
|
||||
bool goToSample(int i);
|
||||
SkString getSampleTitle(int i);
|
||||
int sampleCount();
|
||||
bool handleTouch(int ownerId, float x, float y,
|
||||
SkView::Click::State state);
|
||||
void saveToPdf();
|
||||
SkData* getPDFData() { return fPDFData; }
|
||||
void postInvalDelay();
|
||||
|
||||
protected:
|
||||
|
@ -102,6 +107,7 @@ private:
|
|||
|
||||
bool fSaveToPdf;
|
||||
SkCanvas* fPdfCanvas;
|
||||
SkData* fPDFData;
|
||||
|
||||
bool fUseClip;
|
||||
bool fNClip;
|
||||
|
|
Загрузка…
Ссылка в новой задаче