Esempio n. 1
0
static void test_blur_drawing(skiatest::Reporter* reporter) {

    SkPaint paint;
    paint.setColor(SK_ColorGRAY);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(SkIntToScalar(strokeWidth));

    SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5));
    for (int style = 0; style <= kLastEnum_SkBlurStyle; ++style) {
        SkBlurStyle blurStyle = static_cast<SkBlurStyle>(style);

        const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
        for (uint32_t flags = 0; flags < flagPermutations; ++flags) {
            SkMaskFilter* filter;
            filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags);

            paint.setMaskFilter(filter);
            filter->unref();

            for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) {
                SkPath path;
                tests[test].addPath(&path);
                SkPath strokedPath;
                paint.getFillPath(path, &strokedPath);
                SkRect refBound = strokedPath.getBounds();
                SkIRect iref;
                refBound.roundOut(&iref);
                iref.inset(-outset, -outset);
                SkBitmap refBitmap;
                create(&refBitmap, iref);

                SkCanvas refCanvas(refBitmap);
                refCanvas.translate(SkIntToScalar(-iref.fLeft),
                                    SkIntToScalar(-iref.fTop));
                drawBG(&refCanvas);
                refCanvas.drawPath(path, paint);

                for (int view = 0; view < tests[test].viewLen; ++view) {
                    SkIRect itest = tests[test].views[view];
                    SkBitmap testBitmap;
                    create(&testBitmap, itest);

                    SkCanvas testCanvas(testBitmap);
                    testCanvas.translate(SkIntToScalar(-itest.fLeft),
                                         SkIntToScalar(-itest.fTop));
                    drawBG(&testCanvas);
                    testCanvas.drawPath(path, paint);

                    REPORTER_ASSERT(reporter,
                        compare(refBitmap, iref, testBitmap, itest));
                }
            }
        }
    }
}
Esempio n. 2
0
void Simulation::Render()
{
    SDL_Renderer *renderer = Game::getGlobalGame()->getRenderer();

    Game::getGlobalGame()->setBackgroundColor(0, 0, 0);

    // Render do Fundo
//    SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD);
    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);

    drawBG(background[0], bgOffsetX, bgOffsetY, -0.1, renderer);
    drawBG(background[1], bgOffsetX, bgOffsetY, -0.13, renderer);
    drawBG(background[2], bgOffsetX, bgOffsetY, -0.2, renderer);
    drawBG(background[3], bgOffsetX, bgOffsetY, -0.28, renderer);
//    background[0]->DrawImage(bgOffsetX*0.10, bgOffsetY*0.10, renderer);
//    background[1]->DrawImage(bgOffsetX*0.13, bgOffsetY*0.13, renderer);
//    background[2]->DrawImage(bgOffsetX*0.20, bgOffsetY*0.20, renderer);
//    background[3]->DrawImage(bgOffsetX*0.28, bgOffsetY*0.28, renderer);

//    background->DrawImage(bgOffsetX, bgOffsetY, renderer);
//    background->DrawImage(bgOffsetX + Game::getGlobalGame()->getWidth(),
//                          bgOffsetY + Game::getGlobalGame()->getHeight(), renderer);
//
//    background->DrawImage(bgOffsetX + Game::getGlobalGame()->getWidth(), bgOffsetY, renderer);
//    background->DrawImage(bgOffsetX, bgOffsetY + Game::getGlobalGame()->getHeight(), renderer);

    //Just TESTING
    SDL_SetRenderTarget(renderer, renderCombat);
        // Limpar textura
        SDL_SetTextureBlendMode(renderCombat, SDL_BLENDMODE_BLEND);
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
        SDL_RenderClear(renderer);

        SDL_SetRenderDrawBlendMode(renderer, SDL_BlendMode::SDL_BLENDMODE_NONE);
        SDL_SetTextureBlendMode(renderCombat, SDL_BLENDMODE_BLEND);

        simulationWorld->render();
    SDL_SetRenderTarget(renderer, 0);

    // Renderizar imagem de combate na tela
    SDL_Rect rect;
    rect.x = -camera->getX();  rect.w = 2048;
    rect.y = -camera->getY();  rect.h = 2048;

    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
    SDL_SetRenderDrawBlendMode(renderer, SDL_BlendMode::SDL_BLENDMODE_NONE);
    SDL_RenderCopy( renderer, renderCombat, 0, &rect);

    if(selectedUnit)
    {
        filledCircleRGBA( renderer, selectedUnit->getAvgX(), selectedUnit->getAvgY(), 64, 0, 0, 255, 128 );
    }
}
Esempio n. 3
0
DEF_TEST(DrawText, reporter) {
    SkPaint paint;
    paint.setColor(SK_ColorGRAY);
    paint.setTextSize(SkIntToScalar(20));

    SkIRect drawTextRect = SkIRect::MakeWH(64, 64);
    SkBitmap drawTextBitmap;
    create(&drawTextBitmap, drawTextRect);
    SkCanvas drawTextCanvas(drawTextBitmap);

    SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64);
    SkBitmap drawPosTextBitmap;
    create(&drawPosTextBitmap, drawPosTextRect);
    SkCanvas drawPosTextCanvas(drawPosTextBitmap);

    // Two test cases "A" for the normal path through the code, and " " to check the
    // early return path.
    const char* cases[] = {"A", " "};
    for (auto c : cases) {
        for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
            for (float offsetX = 0.0f; offsetX < 1.0f; offsetX += (1.0f / 16.0f)) {
                SkPoint point = SkPoint::Make(25.0f + offsetX,
                                              25.0f + offsetY);

                for (int align = 0; align < SkPaint::kAlignCount; ++align) {
                    paint.setTextAlign(static_cast<SkPaint::Align>(align));

                    for (unsigned int flags = 0; flags < (1 << 3); ++flags) {
                        static const unsigned int antiAliasFlag = 1;
                        static const unsigned int subpixelFlag = 1 << 1;
                        static const unsigned int lcdFlag = 1 << 2;

                        paint.setAntiAlias(SkToBool(flags & antiAliasFlag));
                        paint.setSubpixelText(SkToBool(flags & subpixelFlag));
                        paint.setLCDRenderText(SkToBool(flags & lcdFlag));

                        // Test: drawText and drawPosText draw the same.
                        drawBG(&drawTextCanvas);
                        drawTextCanvas.drawText(c, 1, point.fX, point.fY, paint);

                        drawBG(&drawPosTextCanvas);
                        drawPosTextCanvas.drawPosText(c, 1, &point, paint);

                        REPORTER_ASSERT(reporter,
                                        compare(drawTextBitmap, drawTextRect,
                                                drawPosTextBitmap, drawPosTextRect));
                    }
                }
            }
        }
    }
}
Esempio n. 4
0
DEF_TEST(FontHostStream, reporter) {
    {
        SkPaint paint;
        paint.setColor(SK_ColorGRAY);
        paint.setTextSize(SkIntToScalar(30));

        SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
                                                           SkTypeface::kNormal);
        SkSafeUnref(paint.setTypeface(fTypeface));

        SkIRect origRect = SkIRect::MakeWH(64, 64);
        SkBitmap origBitmap;
        create(&origBitmap, origRect);
        SkCanvas origCanvas(origBitmap);

        SkIRect streamRect = SkIRect::MakeWH(64, 64);
        SkBitmap streamBitmap;
        create(&streamBitmap, streamRect);
        SkCanvas streamCanvas(streamBitmap);

        SkPoint point = SkPoint::Make(24, 32);

        // Test: origTypeface and streamTypeface from orig data draw the same
        drawBG(&origCanvas);
        origCanvas.drawText("A", 1, point.fX, point.fY, paint);

        SkTypeface* origTypeface = paint.getTypeface();
        SkAutoTUnref<SkTypeface> aur;
        if (NULL == origTypeface) {
            origTypeface = aur.reset(SkTypeface::RefDefault());
        }

        int ttcIndex;
        SkAutoTDelete<SkStreamAsset> fontData(origTypeface->openStream(&ttcIndex));
        SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData.detach());

        SkFontDescriptor desc;
        bool isLocalStream = false;
        streamTypeface->getFontDescriptor(&desc, &isLocalStream);
        REPORTER_ASSERT(reporter, isLocalStream);

        SkSafeUnref(paint.setTypeface(streamTypeface));
        drawBG(&streamCanvas);
        streamCanvas.drawPosText("A", 1, &point, paint);

        REPORTER_ASSERT(reporter,
                        compare(origBitmap, origRect, streamBitmap, streamRect));
    }
    //Make sure the typeface is deleted and removed.
    SkGraphics::PurgeFontCache();
}
Esempio n. 5
0
static void test_drawText(skiatest::Reporter* reporter) {

    SkPaint paint;
    paint.setColor(SK_ColorGRAY);
    paint.setTextSize(SkIntToScalar(20));

    SkIRect drawTextRect = SkIRect::MakeWH(64, 64);
    SkBitmap drawTextBitmap;
    create(&drawTextBitmap, drawTextRect, SkBitmap::kARGB_8888_Config);
    SkCanvas drawTextCanvas(drawTextBitmap);

    SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64);
    SkBitmap drawPosTextBitmap;
    create(&drawPosTextBitmap, drawPosTextRect, SkBitmap::kARGB_8888_Config);
    SkCanvas drawPosTextCanvas(drawPosTextBitmap);

    for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
        for (float offsetX = 0.0f; offsetX < 1.0f; offsetX += (1.0f / 16.0f)) {
            SkPoint point = SkPoint::Make(SkFloatToScalar(25.0f + offsetX),
                                          SkFloatToScalar(25.0f + offsetY));

            for (int align = 0; align < SkPaint::kAlignCount; ++align) {
                paint.setTextAlign(static_cast<SkPaint::Align>(align));

                for (unsigned int flags = 0; flags < (1 << 3); ++flags) {
                    static const unsigned int antiAliasFlag = 1;
                    static const unsigned int subpixelFlag = 1 << 1;
                    static const unsigned int lcdFlag = 1 << 2;

                    paint.setAntiAlias(SkToBool(flags & antiAliasFlag));
                    paint.setSubpixelText(SkToBool(flags & subpixelFlag));
                    paint.setLCDRenderText(SkToBool(flags & lcdFlag));

                    // Test: drawText and drawPosText draw the same.
                    drawBG(&drawTextCanvas);
                    drawTextCanvas.drawText("A", 1, point.fX, point.fY, paint);

                    drawBG(&drawPosTextCanvas);
                    drawPosTextCanvas.drawPosText("A", 1, &point, paint);

                    REPORTER_ASSERT(reporter,
                        compare(drawTextBitmap, drawTextRect,
                                drawPosTextBitmap, drawPosTextRect));
                }
            }
        }
    }
}
Esempio n. 6
0
    virtual void onDraw(SkCanvas* canvas) {
        drawBG(canvas);

        if (canvas->getViewport(NULL)) {
            test_glshader(canvas);
            return;
        }
        
        SkRect r;
        r.set(0, 0, 100, 100);
        
        canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
        
        SkPaint paint;
        paint.setAntiAlias(false);
        paint.setColor(SK_ColorRED);
        
        canvas->drawRect(r, paint);

        canvas->translate(r.width() + SkIntToScalar(20), 0);
        paint.setStyle(SkPaint::kStroke_Style);
        canvas->drawRect(r, paint);

        canvas->translate(r.width() + SkIntToScalar(20), 0);
        paint.setStrokeWidth(SkIntToScalar(5));
        canvas->drawRect(r, paint);
        
        canvas->translate(r.width() * 10/9, 0);
        show_ramp(canvas, r);
    }
Esempio n. 7
0
    virtual void onDrawContent(SkCanvas* canvas) {
        drawBG(canvas);

        SkBlurStyle NONE = SkBlurStyle(-999);
        static const struct {
            SkBlurStyle fStyle;
            int         fCx, fCy;
        } gRecs[] = {
            { NONE,                                 0,  0 },
            { kInner_SkBlurStyle,  -1,  0 },
            { kNormal_SkBlurStyle,  0,  1 },
            { kSolid_SkBlurStyle,   0, -1 },
            { kOuter_SkBlurStyle,   1,  0 },
        };

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setTextSize(25);
        canvas->translate(-40, 0);

        SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
        for (int j = 0; j < 2; j++) {
            canvas->save();
            paint.setColor(SK_ColorBLUE);
            for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
                if (gRecs[i].fStyle != NONE) {
                    SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle,
                                      SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)),
                                      flags);
                    paint.setMaskFilter(mf)->unref();
                } else {
                    paint.setMaskFilter(nullptr);
                }
                canvas->drawCircle(200 + gRecs[i].fCx*100.f,
                                   200 + gRecs[i].fCy*100.f, 50, paint);
            }
            // draw text
            {
                SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
                                      SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)),
                                      flags);
                paint.setMaskFilter(mf)->unref();
                SkScalar x = SkIntToScalar(70);
                SkScalar y = SkIntToScalar(400);
                paint.setColor(SK_ColorBLACK);
                canvas->drawText("Hamburgefons Style", 18, x, y, paint);
                canvas->drawText("Hamburgefons Style", 18, x, y + SkIntToScalar(50), paint);
                paint.setMaskFilter(nullptr);
                paint.setColor(SK_ColorWHITE);
                x -= SkIntToScalar(2);
                y -= SkIntToScalar(2);
                canvas->drawText("Hamburgefons Style", 18, x, y, paint);
            }
            canvas->restore();
            flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
            canvas->translate(350, 0);
        }
    }
 virtual void onDraw(SkCanvas* canvas) {
     drawBG(canvas);
     
     SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMode,
                                                SkShader::kMirror_TileMode);
     SkPaint paint;
     paint.setShader(s)->unref();
     canvas->drawPaint(paint);
 }
Esempio n. 9
0
// Main menu
void gfx()
{
	pvr_wait_ready();
	pvr_scene_begin();

	pvr_list_begin(PVR_LIST_OP_POLY);
		if (stateM == stateMenu || stateM == statePrintDIR)
			drawBG();
	pvr_list_finish();


	pvr_list_begin(PVR_LIST_TR_POLY);

	switch(stateM)
	{
		case statePaused:
			printPVR((DISP_WIDTH / 2) - 36, (DISP_HEIGHT / 2) - 24, "Paused");
			break;

		case stateMenu:
			printPVR(0, 0, "eCastOS 0.3.7 | EXT2");
			printPVR(0, 48, "A     : Boot romdisk Binary");
			printPVR(0, 72, "B     : List Root Directory");
			if (mountState)
				printPVR(0, 96, "X     : Un Mount G1");
			if (!mountState)
			{
				printPVR(0, 96, "X     : Mount G1");
				printPVR(0, 240, "G1    : Not Mounted");
			}
			printPVR(0, 120, "Y     : Write Hard Drive File's");
			printPVR(0, 168, "UP    : Pause Rendering PowerVR");
			printPVR(0, 192, "DOWN  : Check Settings Over Serial");
			break;

		case statePrintDIR:
			printPVR(((DISP_WIDTH / 2) - 216), 0, "  Press B To Return");
			do {
				printDIR("/hd");
		  } while (stateM == statePrintDIR);
			break;

		case stateSettings:
			break;

		case stateBoot:
			printPVR(12, 24, "Initializing eCastOS...");
			sleep(1);
			stateM = stateMenu;
			break;
	}

	pvr_list_finish();

	pvr_scene_finish();
}
Esempio n. 10
0
/** Test that drawing glyphs with empty paths is different from drawing glyphs without paths. */
DEF_TEST(DrawText_dashout, reporter) {
    SkIRect size = SkIRect::MakeWH(64, 64);

    SkBitmap drawTextBitmap;
    create(&drawTextBitmap, size);
    SkCanvas drawTextCanvas(drawTextBitmap);

    SkBitmap drawDashedTextBitmap;
    create(&drawDashedTextBitmap, size);
    SkCanvas drawDashedTextCanvas(drawDashedTextBitmap);

    SkBitmap emptyBitmap;
    create(&emptyBitmap, size);
    SkCanvas emptyCanvas(emptyBitmap);

    SkPoint point = SkPoint::Make(25.0f, 25.0f);
    SkPaint paint;
    paint.setColor(SK_ColorGRAY);
    paint.setTextSize(SkIntToScalar(20));
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);
    paint.setLCDRenderText(true);
    paint.setStyle(SkPaint::kStroke_Style);

    // Draw a stroked "A" without a dash which will draw something.
    drawBG(&drawTextCanvas);
    drawTextCanvas.drawText("A", 1, point.fX, point.fY, paint);

    // Draw an "A" but with a dash which will never draw anything.
    paint.setStrokeWidth(2);
    constexpr SkScalar bigInterval = 10000;
    static constexpr SkScalar intervals[] = { 1, bigInterval };
    paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 2));

    drawBG(&drawDashedTextCanvas);
    drawDashedTextCanvas.drawText("A", 1, point.fX, point.fY, paint);

    // Draw nothing.
    drawBG(&emptyCanvas);

    REPORTER_ASSERT(reporter, !compare(drawTextBitmap, size, emptyBitmap, size));
    REPORTER_ASSERT(reporter, compare(drawDashedTextBitmap, size, emptyBitmap, size));
}
Esempio n. 11
0
int main() {
	setMode(MODE_4 | BG2_ENABLE);
	startGame();
	while(1) {
		if (KEY_DOWN_NOW(KEY_START) && state == 0) {			
			state = 1;
			numOfLives = 3;
			loadAvatar();
			fillPalette(GPalette_palette, 0, GPALETTE_PALETTE_SIZE);
			PALETTE[200] = BLACK;
			PALETTE[201] = WHITE;
			PALETTE[202] = RED;
			PALETTE[203] = GREEN;
			PALETTE[204] = BLUE;
			
			for (int i = 0; i < 5; i++) {
				homeFlags[i] = 0;
			}
		}
		if (state == 1) {
			drawBG();
			char liveStr[7];
		if (numOfLives >= 0) {
			sprintf(liveStr, "%d", numOfLives);
			drawString4(10, 147, "LIVES LEFT:  ", PALETTE[1]);
			drawString4(80, 147, liveStr, PALETTE[1]);
		}
			drawTrucks();
			drawCars();
			drawCrocodiles();
			drawWoods();
			drawFrog();
			collision();
			reset();
			delay(2);
			waitForVblank();
			flipPage();
		}
		if (state == 2) {
			while (1) {
				if (KEY_DOWN_NOW(KEY_START)) {
					state = 0;
					break;
				}
			}
		}
	}
	return 0;
}
Esempio n. 12
0
void display()
{
	glClearColor( 1, 1 , 1 , 0 );
	glClear( GL_COLOR_BUFFER_BIT );

	drawBG() ;
	if ( gameState == RUN ) {
	snake.Draw() ;
	food.Draw();
	} else if ( gameState == GAMEOVER ) {
		glColor3f(0,0,1) ;
		vprint2(-80, -180, 0.2, "GAME OVER" ) ;
	}
 
	glutSwapBuffers();
}
    virtual void onDraw(SkCanvas* canvas) {
        drawBG(canvas);

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kStroke_Style);

        SkMatrix matrix;
        matrix.setScale(3.55f, 80.f);
        canvas->setMatrix(matrix);
        
        paint.setStrokeWidth(0.0588f);
        canvas->drawLine(10, 5, 30, 4.8f, paint);
        
        paint.setStrokeWidth(0.06f);
        canvas->drawLine(20, 5, 40, 4.8f, paint);
    }
Esempio n. 14
0
    virtual void onDraw(SkCanvas* canvas) {
        drawBG(canvas);

        SkBitmap sprite;
        sprite.setConfig(SkBitmap::kARGB_8888_Config, 4, 4, 4*sizeof(SkColor));
        const SkColor spriteData[16] = {
            SK_ColorBLACK,  SK_ColorCYAN,    SK_ColorMAGENTA, SK_ColorYELLOW,
            SK_ColorBLACK,  SK_ColorWHITE,   SK_ColorBLACK,   SK_ColorRED,
            SK_ColorGREEN,  SK_ColorBLACK,   SK_ColorWHITE,   SK_ColorBLUE,
            SK_ColorYELLOW, SK_ColorMAGENTA, SK_ColorCYAN,    SK_ColorBLACK
        };
        sprite.allocPixels();
        sprite.lockPixels();
        SkPMColor* addr = sprite.getAddr32(0, 0);
        for (size_t i = 0; i < SK_ARRAY_COUNT(spriteData); ++i) {
            addr[i] = SkPreMultiplyColor(spriteData[i]);
        }
        sprite.unlockPixels();

        // We draw a magnified subrect of the sprite
        // sample interpolation may cause color bleeding around edges
        // the subrect is a pure white area
        SkIRect srcRect;
        SkRect dstRect;
        SkPaint paint;
        paint.setFilterBitmap(true);
        //First row : full texture with and without filtering
        srcRect.setXYWH(0, 0, 4, 4);
        dstRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0)
                        , SkIntToScalar(100), SkIntToScalar(100));
        canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
        dstRect.setXYWH(SkIntToScalar(100), SkIntToScalar(0)
                        , SkIntToScalar(100), SkIntToScalar(100));
        canvas->drawBitmapRect(sprite, &srcRect, dstRect);
        //Second row : sub rect of texture with and without filtering
        srcRect.setXYWH(1, 1, 2, 2);
        dstRect.setXYWH(SkIntToScalar(25), SkIntToScalar(125)
                        , SkIntToScalar(50), SkIntToScalar(50));
        canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
        dstRect.setXYWH(SkIntToScalar(125), SkIntToScalar(125)
                        , SkIntToScalar(50), SkIntToScalar(50));
        canvas->drawBitmapRect(sprite, &srcRect, dstRect);
    }
Esempio n. 15
0
    virtual void onDraw(SkCanvas* canvas) {
        drawBG(canvas);
        
        canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
        
        SkPaint paint;
        const SkScalar scale = SkIntToScalar(5)/4;

        paint.setAntiAlias(false);

        showFour(canvas, SK_Scalar1, paint);
        canvas->translate(SkIntToScalar(450), 0);
        showFour(canvas, scale, paint);

        paint.setAntiAlias(true);

        canvas->translate(SkIntToScalar(-450), SkIntToScalar(450));
        showFour(canvas, SK_Scalar1, paint);
        canvas->translate(SkIntToScalar(450), 0);
        showFour(canvas, scale, paint);
    }
    virtual void onDraw(SkCanvas* canvas) {
        drawBG(canvas);
        //return;
        canvas->translate(SkIntToScalar(10), SkIntToScalar(10));

        SkPaint paint;
        paint.setAntiAlias(true);
        
        if (true) {
            canvas->drawColor(SK_ColorBLACK);

            paint.setTextSize(24);
            paint.setColor(SK_ColorWHITE);
            canvas->translate(10, 30);

            static const SkBlurMaskFilter::BlurStyle gStyle[] = {
                SkBlurMaskFilter::kNormal_BlurStyle,
                SkBlurMaskFilter::kInner_BlurStyle,
                SkBlurMaskFilter::kOuter_BlurStyle,
                SkBlurMaskFilter::kSolid_BlurStyle,
            };
            for (int x = 0; x < 5; x++) {
                SkMaskFilter* mf;
                SkScalar radius = 4;
                for (int y = 0; y < 10; y++) {
                    if (x) {
                        mf = SkBlurMaskFilter::Create(radius, gStyle[x - 1]);
                        paint.setMaskFilter(mf)->unref();
                    }
                    canvas->drawText("Title Bar", 9, x*100, y*30, paint);
                    radius *= 0.75f;
                }
                
            }
            return;
        }

        paint.setColor(SK_ColorBLUE);

#if 1
        SkPath p;
        float r = rand.nextUScalar1() + 0.5f;
        SkScalar x = 0, y = 0;
        p.moveTo(x, y);
#if 0
        p.cubicTo(x-75*r, y+75*r, x-40*r, y+125*r, x, y+85*r);
        p.cubicTo(x+40*r, y+125*r, x+75*r, y+75*r, x, y);
#else
        p.cubicTo(x+75*r, y+75*r, x+40*r, y+125*r, x, y+85*r);
        p.cubicTo(x-40*r, y+125*r, x-75*r, y+75*r, x, y);
#endif
        p.close();
        fPath = p;
        fPath.offset(100, 0);
#endif
        
        fPath.setFillType(SkPath::kWinding_FillType);
        drawSet(canvas, &paint);
        
        canvas->translate(0, fPath.getBounds().height() * 5 / 4);
        fPath.setFillType(SkPath::kEvenOdd_FillType);
        drawSet(canvas, &paint);
    }
Esempio n. 17
0
BOOL Render()
{
	int			i;

	sysInf.animeCnt ++;
	if(bgInf.shake_cnt) bgInf.shake_cnt ++;
	if(saveInf.bWave) saveInf.waveCnt ++;
	if(saveInf.demo && saveInf.demo_max){
		saveInf.demo_cnt ++;
		if(saveInf.demo_cnt>=saveInf.demo_max)saveInf.demo = 0;
	}
	DWORD	nowTime = timeGetTime() -sysInf.oldTime;
	if(nowTime<=0 || sysInf.bForceRender){
		fps = 1000 /FPS_CYCLE;
	}else{
#ifdef bFpsSet
		if(nowTime <DWORD(FPS_CYCLE*(sysInf.render_skip+1))){
			Sleep(FPS_CYCLE*(sysInf.render_skip+1)-nowTime);
			nowTime = timeGetTime() -sysInf.oldTime;
		}else if(sysInf.render_skip<5){
			sysInf.render_skip ++;
			return FALSE;
		}
#endif
		fps = 1000/(nowTime);
	}
	sysInf.bForceRender = off;
	sysInf.oldTime = timeGetTime();
	sysInf.render_skip = 0;

	switch(sysInf.execMode){
	  case opening_mode:
		titleWnd->Draw();
		break;
	  case backlog_mode:
		backLog.DrawBackLog();
		break;
	  case staffRoll_mode:
		lpStaffRoll->Draw();
		break;
	  case save_mode:
	  case load_mode:
		if(saveWnd)saveWnd->Blt();
		break;
	  case menu_mode:
		lpMenuWnd->Draw();
		break;
	  case kabegami_mode:
		lpKabeSetWnd->Draw();
		break;
	  case staffmode_mode:
		lpStaffmodeWnd->Draw();
		break;
	  default:
		drawBG();
		SetBmpDraw();
		drawChar();
		drawBack();
		msgWnd.BltMessage();
		selectWnd.selectBlt();
		break;
	}
#ifdef _DEBUG
	if(sysInf.bInfo){
		sprintf(debugBuf,"fps=%3d",fps);
		TextOut(g_DibInf.memDC,10,10,debugBuf,strlen(debugBuf));
	}
#endif
	return TRUE;
} // Render
Esempio n. 18
0
static void test_blur(skiatest::Reporter* reporter) {

    SkPaint paint;
    paint.setColor(SK_ColorGRAY);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(SkIntToScalar(strokeWidth));

    SkScalar radius = SkIntToScalar(5);
    for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) {
        SkBlurMaskFilter::BlurStyle blurStyle =
            static_cast<SkBlurMaskFilter::BlurStyle>(style);

        const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
        for (uint32_t flags = 0; flags < flagPermutations; ++flags) {
            SkMaskFilter* filter;
            filter = SkBlurMaskFilter::Create(radius, blurStyle, flags);

            SkMaskFilter::BlurInfo info;
            sk_bzero(&info, sizeof(info));
            SkMaskFilter::BlurType type = filter->asABlur(&info);

            REPORTER_ASSERT(reporter, type ==
                static_cast<SkMaskFilter::BlurType>(style + 1));
            REPORTER_ASSERT(reporter, info.fRadius == radius);
            REPORTER_ASSERT(reporter, info.fIgnoreTransform ==
                SkToBool(flags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag));
            REPORTER_ASSERT(reporter, info.fHighQuality ==
                SkToBool(flags & SkBlurMaskFilter::kHighQuality_BlurFlag));

            paint.setMaskFilter(filter);
            filter->unref();

            for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) {
                SkPath path;
                tests[test].addPath(&path);
                SkPath strokedPath;
                paint.getFillPath(path, &strokedPath);
                SkRect refBound = strokedPath.getBounds();
                SkIRect iref;
                refBound.roundOut(&iref);
                iref.inset(-outset, -outset);
                SkBitmap refBitmap;
                create(&refBitmap, iref, SkBitmap::kARGB_8888_Config);

                SkCanvas refCanvas(refBitmap);
                refCanvas.translate(SkIntToScalar(-iref.fLeft),
                                    SkIntToScalar(-iref.fTop));
                drawBG(&refCanvas);
                refCanvas.drawPath(path, paint);

                for (int view = 0; view < tests[test].viewLen; ++view) {
                    SkIRect itest = tests[test].views[view];
                    SkBitmap testBitmap;
                    create(&testBitmap, itest, SkBitmap::kARGB_8888_Config);

                    SkCanvas testCanvas(testBitmap);
                    testCanvas.translate(SkIntToScalar(-itest.fLeft),
                                         SkIntToScalar(-itest.fTop));
                    drawBG(&testCanvas);
                    testCanvas.drawPath(path, paint);

                    REPORTER_ASSERT(reporter,
                        compare(refBitmap, iref, testBitmap, itest));
                }
            }
        }
    }
}
Esempio n. 19
0
void draw()
{
	int x = 10, y = 10;

	sceDisplaySetMode(0, SCR_WIDTH, SCR_HEIGHT);
	sceGuStart(GU_DIRECT, list);
	sceGuClear(GU_COLOR_BUFFER_BIT);

	sceGuClutMode(GU_PSM_8888, 0, 0xFF, 0);
	sceGuClutLoad(1, clut);
	
	drawBG();

	// Reset things.
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x00);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0x000000);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x00);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBox(&x, &y);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFF0000);
	nextBox(&x, &y);

	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0x00FF00);
	nextBox(&x, &y);
	
	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0x0000FF);
	nextBox(&x, &y);
	
	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, GU_AMBIENT);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x00);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFF0000);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0x0000FF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x00);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x80);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x80);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, GU_AMBIENT);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFF0000);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0x0000FF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGBA_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, GU_AMBIENT);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFF0000);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0x0000FF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, GU_AMBIENT);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFF0000);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0x0000FF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x0);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTCOLOR, 0xFFFFFF);
	sceGuSendCommandi(GE_CMD_AMBIENTALPHA, 0x10);
	sceGuSendCommandi(GE_CMD_LIGHTINGENABLE, 1);
	nextBoxHasColor(&x, &y, HASCOLOR_RGB_TRANSPARENT);

	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0);
	nextBox(&x, &y);

	/*ScePspFVector3 pos = {x, y, 0};
	sceGuLight(0, GU_DIRECTIONAL, GU_AMBIENT_AND_DIFFUSE, &pos);
	nextBox(&x, &y);

	pos.x = x; pos.y = y;
	sceGuLight(0, GU_DIRECTIONAL, GU_AMBIENT_AND_DIFFUSE, &pos);
	sceGuLightMode(GU_SINGLE_COLOR);
	sceGuLightColor(0, GU_AMBIENT, 0x00FF00);
	sceGuLightAtt(0, 1.0, 1.0, 1.0);
	nextBox(&x, &y);*/

	sceGuFinish();
	sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE);
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
}
Esempio n. 20
0
 virtual void onDraw(SkCanvas* canvas) {
     drawBG(canvas);
     canvas->drawBitmap(fBM, 0, 0, NULL);
 }