ec3ed6a5eb
I have manually examined all of these diffs and restored a few files that seem to require manual adjustment. The following files still need to be modified manually, in a separate CL: android_sample/SampleApp/AndroidManifest.xml android_sample/SampleApp/res/layout/layout.xml android_sample/SampleApp/res/menu/sample.xml android_sample/SampleApp/res/values/strings.xml android_sample/SampleApp/src/com/skia/sampleapp/SampleApp.java android_sample/SampleApp/src/com/skia/sampleapp/SampleView.java experimental/CiCarbonSampleMain.c experimental/CocoaDebugger/main.m experimental/FileReaderApp/main.m experimental/SimpleCocoaApp/main.m experimental/iOSSampleApp/Shared/SkAlertPrompt.h experimental/iOSSampleApp/Shared/SkAlertPrompt.m experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig gpu/src/android/GrGLDefaultInterface_android.cpp gyp/common.gypi gyp_skia include/ports/SkHarfBuzzFont.h include/views/SkOSWindow_wxwidgets.h make.bat make.py src/opts/memset.arm.S src/opts/memset16_neon.S src/opts/memset32_neon.S src/opts/opts_check_arm.cpp src/ports/SkDebug_brew.cpp src/ports/SkMemory_brew.cpp src/ports/SkOSFile_brew.cpp src/ports/SkXMLParser_empty.cpp src/utils/ios/SkImageDecoder_iOS.mm src/utils/ios/SkOSFile_iOS.mm src/utils/ios/SkStream_NSData.mm tests/FillPathTest.cpp Review URL: http://codereview.appspot.com/4816058 git-svn-id: http://skia.googlecode.com/svn/trunk@1982 2bbb7eff-a529-9590-31e7-b0007b416f81
129 lines
3.4 KiB
C++
129 lines
3.4 KiB
C++
|
|
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#include "gm.h"
|
|
#include "SkPicture.h"
|
|
#include "SkRectShape.h"
|
|
#include "SkGroupShape.h"
|
|
|
|
namespace skiagm {
|
|
|
|
static SkRect make_rect(int l, int t, int r, int b) {
|
|
SkRect rect;
|
|
rect.set(SkIntToScalar(l), SkIntToScalar(t),
|
|
SkIntToScalar(r), SkIntToScalar(b));
|
|
return rect;
|
|
}
|
|
|
|
static SkShape* make_shape0(bool red) {
|
|
SkRectShape* s = new SkRectShape;
|
|
s->setRect(make_rect(10, 10, 90, 90));
|
|
if (red) {
|
|
s->paint().setColor(SK_ColorRED);
|
|
}
|
|
return s;
|
|
}
|
|
|
|
static SkShape* make_shape1() {
|
|
SkRectShape* s = new SkRectShape;
|
|
s->setOval(make_rect(10, 10, 90, 90));
|
|
s->paint().setColor(SK_ColorBLUE);
|
|
return s;
|
|
}
|
|
|
|
static SkShape* make_shape2() {
|
|
SkRectShape* s = new SkRectShape;
|
|
s->setRRect(make_rect(10, 10, 90, 90),
|
|
SkIntToScalar(20), SkIntToScalar(20));
|
|
s->paint().setColor(SK_ColorGREEN);
|
|
return s;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
class ShapesGM : public GM {
|
|
SkGroupShape fGroup;
|
|
SkMatrixRef* fMatrixRefs[4];
|
|
public:
|
|
ShapesGM() {
|
|
SkMatrix m;
|
|
fGroup.appendShape(make_shape0(false))->unref();
|
|
m.setRotate(SkIntToScalar(30), SkIntToScalar(50), SkIntToScalar(50));
|
|
m.postTranslate(0, SkIntToScalar(120));
|
|
fGroup.appendShape(make_shape0(true), m)->unref();
|
|
|
|
m.setTranslate(SkIntToScalar(120), 0);
|
|
fGroup.appendShape(make_shape1(), m)->unref();
|
|
m.postTranslate(0, SkIntToScalar(120));
|
|
fGroup.appendShape(make_shape2(), m)->unref();
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrixRefs); i++) {
|
|
SkSafeRef(fMatrixRefs[i] = fGroup.getShapeMatrixRef(i));
|
|
}
|
|
SkScalar c = SkIntToScalar(50);
|
|
fMatrixRefs[3]->preRotate(SkIntToScalar(30), c, c);
|
|
}
|
|
|
|
virtual ~ShapesGM() {
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrixRefs); i++) {
|
|
SkSafeUnref(fMatrixRefs[i]);
|
|
}
|
|
}
|
|
|
|
protected:
|
|
virtual SkString onShortName() {
|
|
return SkString("shapes");
|
|
}
|
|
|
|
virtual SkISize onISize() {
|
|
return make_isize(380, 480);
|
|
}
|
|
|
|
void drawBG(SkCanvas* canvas) {
|
|
canvas->drawColor(0xFFDDDDDD);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
this->drawBG(canvas);
|
|
|
|
SkMatrix matrix;
|
|
|
|
SkGroupShape* gs = new SkGroupShape;
|
|
SkAutoUnref aur(gs);
|
|
gs->appendShape(&fGroup);
|
|
matrix.setScale(-SK_Scalar1, SK_Scalar1);
|
|
matrix.postTranslate(SkIntToScalar(220), SkIntToScalar(240));
|
|
gs->appendShape(&fGroup, matrix);
|
|
matrix.setTranslate(SkIntToScalar(240), 0);
|
|
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
|
|
gs->appendShape(&fGroup, matrix);
|
|
|
|
#if 1
|
|
SkPicture* pict = new SkPicture;
|
|
SkCanvas* cv = pict->beginRecording(1000, 1000);
|
|
cv->scale(SK_ScalarHalf, SK_ScalarHalf);
|
|
gs->draw(cv);
|
|
cv->translate(SkIntToScalar(680), SkIntToScalar(480));
|
|
cv->scale(-SK_Scalar1, SK_Scalar1);
|
|
gs->draw(cv);
|
|
pict->endRecording();
|
|
canvas->drawPicture(*pict);
|
|
pict->unref();
|
|
#endif
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return new ShapesGM; }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|