Kaydet (Commit) bebe347c authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor "workben" classes to use RenderContext

Change-Id: I9363d4d90df7c74cf7462494ceda2e2f47607dc9
üst 3d9edac6
...@@ -820,7 +820,7 @@ void grindFunc( OutputDevice& rTarget, ...@@ -820,7 +820,7 @@ void grindFunc( OutputDevice& rTarget,
/** Call OutputDevice render methods repeatedly, and output elapsed /** Call OutputDevice render methods repeatedly, and output elapsed
time to stdout time to stdout
*/ */
void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 ) void outDevGrind(vcl::RenderContext& rTarget, sal_Int32 nTurns = 100)
{ {
// TODO(F1): also profile pure complex clip setup times! // TODO(F1): also profile pure complex clip setup times!
...@@ -879,10 +879,10 @@ void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 ) ...@@ -879,10 +879,10 @@ void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 )
} }
} }
void TestWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle&) void TestWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
outDevGrind( *this ); outDevGrind(rRenderContext);
fflush( stdout ); fflush(stdout);
} }
sal_uInt16 GrindApp::Exception( sal_uInt16 nError ) sal_uInt16 GrindApp::Exception( sal_uInt16 nError )
......
...@@ -220,122 +220,123 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) ...@@ -220,122 +220,123 @@ static Color approachColor( const Color& rFrom, const Color& rTo )
} }
#define DELTA 5.0 #define DELTA 5.0
void MyWin::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) void MyWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{ {
WorkWindow::Paint(rRenderContext, rRect); WorkWindow::Paint(rRenderContext, rRect);
Push( PushFlags::ALL ); rRenderContext.Push(PushFlags::ALL);
MapMode aMapMode( MAP_100TH_MM ); MapMode aMapMode(MAP_100TH_MM);
SetMapMode( aMapMode ); rRenderContext.SetMapMode(aMapMode);
Size aPaperSize = GetOutputSize(); Size aPaperSize = rRenderContext.GetOutputSize();
Point aCenter( aPaperSize.Width()/2-300, Point aCenter(aPaperSize.Width() / 2 - 300,
(aPaperSize.Height() - 8400)/2 + 8400 ); (aPaperSize.Height() - 8400) / 2 + 8400);
Point aP1( aPaperSize.Width()/48, 0), aP2( aPaperSize.Width()/40, 0 ), aPoint; Point aP1(aPaperSize.Width() / 48, 0), aP2(aPaperSize.Width() / 40, 0);
Point aPoint;
DrawRect( Rectangle( Point( 0,0 ), aPaperSize ) );
DrawRect( Rectangle( Point( 100,100 ), rRenderContext.DrawRect(Rectangle(Point(0, 0), aPaperSize));
Size( aPaperSize.Width()-200, rRenderContext.DrawRect(Rectangle(Point(100, 100),
aPaperSize.Height()-200 ) ) ); Size(aPaperSize.Width() - 200,
DrawRect( Rectangle( Point( 200,200 ), aPaperSize.Height() - 200)));
Size( aPaperSize.Width()-400, rRenderContext.DrawRect(Rectangle(Point(200, 200),
aPaperSize.Height()-400 ) ) ); Size(aPaperSize.Width() - 400,
DrawRect( Rectangle( Point( 300,300 ), aPaperSize.Height() - 400)));
Size( aPaperSize.Width()-600, rRenderContext.DrawRect(Rectangle(Point(300, 300),
aPaperSize.Height()-600 ) ) ); Size(aPaperSize.Width() - 600,
aPaperSize.Height() - 600)));
const int nFontCount = GetDevFontCount();
const int nFontSamples = (nFontCount<15) ? nFontCount : 15; const int nFontCount = rRenderContext.GetDevFontCount();
for( int i = 0; i < nFontSamples; ++i ) const int nFontSamples = (nFontCount < 15) ? nFontCount : 15;
for (int i = 0; i < nFontSamples; ++i)
{ {
vcl::FontInfo aFont = GetDevFont( (i*nFontCount) / nFontSamples ); vcl::FontInfo aFont = rRenderContext.GetDevFont((i * nFontCount) / nFontSamples);
aFont.SetHeight( 400 + (i%7) * 100 ); aFont.SetHeight(400 + (i % 7) * 100);
aFont.SetOrientation( i * (3600 / nFontSamples) ); aFont.SetOrientation(i * (3600 / nFontSamples));
SetFont( aFont ); rRenderContext.SetFont(aFont);
sal_uInt8 nRed = (i << 6) & 0xC0; sal_uInt8 nRed = (i << 6) & 0xC0;
sal_uInt8 nGreen = (i << 4) & 0xC0; sal_uInt8 nGreen = (i << 4) & 0xC0;
sal_uInt8 nBlue = (i << 2) & 0xC0; sal_uInt8 nBlue = (i << 2) & 0xC0;
SetTextColor( Color( nRed, nGreen, nBlue ) ); rRenderContext.SetTextColor(Color(nRed, nGreen, nBlue));
OUStringBuffer aPrintText(1024); OUStringBuffer aPrintText(1024);
long nMaxWidth = 0; long nMaxWidth = 0;
aPrintText.appendAscii( "SVP test program" ); aPrintText.appendAscii( "SVP test program" );
DrawText( Rectangle( Point( (aPaperSize.Width() - 4000) / 2, 2000 ), rRenderContext.DrawText(Rectangle(Point((aPaperSize.Width() - 4000) / 2, 2000),
Size( aPaperSize.Width() - 2100 - nMaxWidth, Size(aPaperSize.Width() - 2100 - nMaxWidth, aPaperSize.Height() - 4000)),
aPaperSize.Height() - 4000 ) ), aPrintText.makeStringAndClear(),
aPrintText.makeStringAndClear(), TEXT_DRAW_MULTILINE);
TEXT_DRAW_MULTILINE );
} }
SetFillColor(); rRenderContext.SetFillColor();
DrawRect( Rectangle( Point( aPaperSize.Width() - 4000, 1000 ), DrawRect(Rectangle(Point(aPaperSize.Width() - 4000, 1000),
Size( 3000,3000 ) ) ); Size(3000, 3000)));
DrawBitmap( Point( aPaperSize.Width() - 4000, 1000 ), rRenderContext.DrawBitmap(Point(aPaperSize.Width() - 4000, 1000),
Size( 3000,3000 ), Size( 3000,3000 ),
m_aBitmap ); m_aBitmap);
Color aWhite( 0xff, 0xff, 0xff ); Color aWhite(0xff, 0xff, 0xff);
Color aBlack( 0, 0, 0 ); Color aBlack(0, 0, 0);
Color aLightRed( 0xff, 0, 0 ); Color aLightRed(0xff, 0, 0);
Color aDarkRed( 0x40, 0, 0 ); Color aDarkRed(0x40, 0, 0);
Color aLightBlue( 0, 0, 0xff ); Color aLightBlue(0, 0, 0xff);
Color aDarkBlue( 0,0,0x40 ); Color aDarkBlue(0,0,0x40);
Color aLightGreen( 0, 0xff, 0 ); Color aLightGreen(0, 0xff, 0);
Color aDarkGreen( 0, 0x40, 0 ); Color aDarkGreen(0, 0x40, 0);
Gradient aGradient( GradientStyle_LINEAR, aBlack, aWhite ); Gradient aGradient(GradientStyle_LINEAR, aBlack, aWhite);
aGradient.SetAngle( 900 ); aGradient.SetAngle(900);
DrawGradient( Rectangle( Point( 1000, 4500 ), rRenderContext.DrawGradient(Rectangle(Point(1000, 4500),
Size( aPaperSize.Width() - 2000, Size(aPaperSize.Width() - 2000, 500)),
500 ) ), aGradient ); aGradient);
aGradient.SetStartColor( aDarkRed ); aGradient.SetStartColor(aDarkRed);
aGradient.SetEndColor( aLightBlue ); aGradient.SetEndColor(aLightBlue);
DrawGradient( Rectangle( Point( 1000, 5300 ), rRenderContext.DrawGradient(Rectangle(Point(1000, 5300),
Size( aPaperSize.Width() - 2000, Size(aPaperSize.Width() - 2000, 500)),
500 ) ), aGradient ); aGradient);
aGradient.SetStartColor( aDarkBlue ); aGradient.SetStartColor(aDarkBlue);
aGradient.SetEndColor( aLightGreen ); aGradient.SetEndColor(aLightGreen);
DrawGradient( Rectangle( Point( 1000, 6100 ), rRenderContext.DrawGradient(Rectangle(Point(1000, 6100),
Size( aPaperSize.Width() - 2000, Size(aPaperSize.Width() - 2000, 500)),
500 ) ), aGradient ); aGradient);
aGradient.SetStartColor( aDarkGreen ); aGradient.SetStartColor(aDarkGreen);
aGradient.SetEndColor( aLightRed ); aGradient.SetEndColor(aLightRed);
DrawGradient( Rectangle( Point( 1000, 6900 ), rRenderContext.DrawGradient(Rectangle(Point(1000, 6900),
Size( aPaperSize.Width() - 2000, Size(aPaperSize.Width() - 2000, 500)),
500 ) ), aGradient ); aGradient);
LineInfo aLineInfo( LINE_SOLID, 200 ); LineInfo aLineInfo(LINE_SOLID, 200);
double sind = sin( DELTA*M_PI/180.0 ); double sind = sin(DELTA * M_PI / 180.0);
double cosd = cos( DELTA*M_PI/180.0 ); double cosd = cos(DELTA * M_PI / 180.0);
double factor = 1 + (DELTA/1000.0); double factor = 1 + (DELTA / 1000.0);
int n=0; int n = 0;
Color aLineColor( 0, 0, 0 ); Color aLineColor(0, 0, 0);
Color aApproachColor( 0, 0, 200 ); Color aApproachColor(0, 0, 200);
while ( aP2.X() < aCenter.X() && n++ < 680 )
while (aP2.X() < aCenter.X() && n++ < 680)
{ {
aLineInfo.SetWidth( n/3 ); aLineInfo.SetWidth(n / 3);
aLineColor = approachColor( aLineColor, aApproachColor ); aLineColor = approachColor(aLineColor, aApproachColor);
SetLineColor( aLineColor ); rRenderContext.SetLineColor(aLineColor);
// switch aproach color // switch aproach color
if( aApproachColor.IsRGBEqual( aLineColor ) ) if (aApproachColor.IsRGBEqual(aLineColor))
{ {
if( aApproachColor.GetRed() ) if (aApproachColor.GetRed())
aApproachColor = Color( 0, 0, 200 ); aApproachColor = Color(0, 0, 200);
else if( aApproachColor.GetGreen() ) else if (aApproachColor.GetGreen())
aApproachColor = Color( 200, 0, 0 ); aApproachColor = Color(200, 0, 0);
else else
aApproachColor = Color( 0, 200, 0 ); aApproachColor = Color(0, 200, 0);
} }
DrawLine( project( aP1 ) + aCenter, rRenderContext.DrawLine(project(aP1) + aCenter,
project( aP2 ) + aCenter, project(aP2) + aCenter,
aLineInfo ); aLineInfo);
aPoint.X() = (int)((((double)aP1.X())*cosd - ((double)aP1.Y())*sind)*factor); aPoint.X() = (int)((((double)aP1.X())*cosd - ((double)aP1.Y())*sind)*factor);
aPoint.Y() = (int)((((double)aP1.Y())*cosd + ((double)aP1.X())*sind)*factor); aPoint.Y() = (int)((((double)aP1.Y())*cosd + ((double)aP1.X())*sind)*factor);
aP1 = aPoint; aP1 = aPoint;
...@@ -343,7 +344,7 @@ void MyWin::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) ...@@ -343,7 +344,7 @@ void MyWin::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect )
aPoint.Y() = (int)((((double)aP2.Y())*cosd + ((double)aP2.X())*sind)*factor); aPoint.Y() = (int)((((double)aP2.Y())*cosd + ((double)aP2.X())*sind)*factor);
aP2 = aPoint; aP2 = aPoint;
} }
Pop(); rRenderContext.Pop();
} }
void MyWin::Resize() void MyWin::Resize()
......
...@@ -1074,7 +1074,7 @@ public: ...@@ -1074,7 +1074,7 @@ public:
} }
}; };
void drawToDevice(OutputDevice &rDev, Size aSize, bool bVDev) void drawToDevice(vcl::RenderContext& rDev, Size aSize, bool bVDev)
{ {
RenderContext aCtx; RenderContext aCtx;
double mnStartTime; double mnStartTime;
...@@ -1417,28 +1417,33 @@ public: ...@@ -1417,28 +1417,33 @@ public:
mrRenderer.SetSizePixel(GetSizePixel()); mrRenderer.SetSizePixel(GetSizePixel());
mrRenderer.KeyInput(rKEvt); mrRenderer.KeyInput(rKEvt);
} }
virtual void Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE
{ {
mrRenderer.SetSizePixel(GetSizePixel()); mrRenderer.SetSizePixel(GetSizePixel());
fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight()); fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
if (mrRenderer.getIterCount() == 0) if (mrRenderer.getIterCount() == 0)
mrRenderer.drawToDevice(*this, GetSizePixel(), false); mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
else else
TestAndQuit(); TestAndQuit(rRenderContext);
} }
void TestAndQuit() void TestAndQuit(vcl::RenderContext& rRenderContext)
{ {
if (underTesting) return; if (underTesting)
underTesting=true; return;
underTesting = true;
for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++) for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++)
{
while (mrRenderer.selectNextRenderer() > -1) while (mrRenderer.selectNextRenderer() > -1)
mrRenderer.drawToDevice(*this, GetSizePixel(), false); {
mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
}
}
double expandedGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_EXPANDED); double expandedGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_EXPANDED);
for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++) for (sal_Int32 i = 0; i < mrRenderer.getIterCount(); i++)
mrRenderer.drawToDevice(*this, GetSizePixel(), false); mrRenderer.drawToDevice(rRenderContext, GetSizePixel(), false);
double thumbGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_THUMB); double thumbGEOMEAN = mrRenderer.getAndResetBenchmark(RENDER_THUMB);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment