Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

Issue 7590009: Merge 92255 - Source/WebCore: [Chromium] Use edge-distance method for layer anti-aliasing. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Returns true if the matrix has no rotation, skew or perspective components to it. 99 // Returns true if the matrix has no rotation, skew or perspective components to it.
100 static bool isScaleOrTranslation(const TransformationMatrix& m) 100 static bool isScaleOrTranslation(const TransformationMatrix& m)
101 { 101 {
102 return !m.m12() && !m.m13() && !m.m14() 102 return !m.m12() && !m.m13() && !m.m14()
103 && !m.m21() && !m.m23() && !m.m24() 103 && !m.m21() && !m.m23() && !m.m24()
104 && !m.m31() && !m.m32() && !m.m43() 104 && !m.m31() && !m.m32() && !m.m43()
105 && m.m44(); 105 && m.m44();
106 106
107 } 107 }
108 108
109 static TransformationMatrix screenMatrix(int x, int y, int width, int height)
110 {
111 TransformationMatrix screen;
112
113 // Map to viewport.
114 screen.translate3d(x, y, 0);
115 screen.scale3d(width, height, 0);
116
117 // Map x, y and z to unit square.
118 screen.translate3d(0.5, 0.5, 0.5);
119 screen.scale3d(0.5, 0.5, 0.5);
120
121 return screen;
122 }
123
109 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHostC lient* client, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDra wing) 124 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(CCLayerTreeHostC lient* client, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDra wing)
110 { 125 {
111 RefPtr<GraphicsContext3D> context = client->createLayerTreeHostContext3D(); 126 RefPtr<GraphicsContext3D> context = client->createLayerTreeHostContext3D();
112 if (!context) 127 if (!context)
113 return 0; 128 return 0;
114 129
115 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromi um(client, context, contentPaint, accelerateDrawing))); 130 RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromi um(client, context, contentPaint, accelerateDrawing)));
116 layerRenderer->init(); 131 layerRenderer->init();
117 if (!layerRenderer->hardwareCompositing()) 132 if (!layerRenderer->hardwareCompositing())
118 return 0; 133 return 0;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 { 518 {
504 if (m_viewportVisibleRect.isEmpty() || !m_rootLayer) 519 if (m_viewportVisibleRect.isEmpty() || !m_rootLayer)
505 return; 520 return;
506 521
507 TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0); 522 TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0);
508 CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl(); 523 CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl();
509 makeContextCurrent(); 524 makeContextCurrent();
510 525
511 // The GL viewport covers the entire visible area, including the scrollbars. 526 // The GL viewport covers the entire visible area, including the scrollbars.
512 GLC(m_context.get(), m_context->viewport(0, 0, m_viewportVisibleRect.width() , m_viewportVisibleRect.height())); 527 GLC(m_context.get(), m_context->viewport(0, 0, m_viewportVisibleRect.width() , m_viewportVisibleRect.height()));
528 m_windowMatrix = screenMatrix(0, 0, m_viewportVisibleRect.width(), m_viewpor tVisibleRect.height());
513 529
514 // Bind the common vertex attributes used for drawing all the layers. 530 // Bind the common vertex attributes used for drawing all the layers.
515 m_sharedGeometry->prepareForDraw(); 531 m_sharedGeometry->prepareForDraw();
516 532
517 // FIXME: These calls can be made once, when the compositor context is initi alized. 533 // FIXME: These calls can be made once, when the compositor context is initi alized.
518 GLC(m_context.get(), m_context->disable(GraphicsContext3D::DEPTH_TEST)); 534 GLC(m_context.get(), m_context->disable(GraphicsContext3D::DEPTH_TEST));
519 GLC(m_context.get(), m_context->disable(GraphicsContext3D::CULL_FACE)); 535 GLC(m_context.get(), m_context->disable(GraphicsContext3D::CULL_FACE));
520 536
521 // Blending disabled by default. Root layer alpha channel on Windows is inco rrect when Skia uses ClearType. 537 // Blending disabled by default. Root layer alpha channel on Windows is inco rrect when Skia uses ClearType.
522 GLC(m_context.get(), m_context->disable(GraphicsContext3D::BLEND)); 538 GLC(m_context.get(), m_context->disable(GraphicsContext3D::BLEND));
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 // Sets the coordinate range of content that ends being drawn onto the target re nder surface. 1157 // Sets the coordinate range of content that ends being drawn onto the target re nder surface.
1142 // The target render surface is assumed to have an origin at 0, 0 and the width and height of 1158 // The target render surface is assumed to have an origin at 0, 0 and the width and height of
1143 // of the drawRect. 1159 // of the drawRect.
1144 void LayerRendererChromium::setDrawViewportRect(const IntRect& drawRect, bool fl ipY) 1160 void LayerRendererChromium::setDrawViewportRect(const IntRect& drawRect, bool fl ipY)
1145 { 1161 {
1146 if (flipY) 1162 if (flipY)
1147 m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.maxX(), drawRect .maxY(), drawRect.y()); 1163 m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.maxX(), drawRect .maxY(), drawRect.y());
1148 else 1164 else
1149 m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.maxX(), drawRect .y(), drawRect.maxY()); 1165 m_projectionMatrix = orthoMatrix(drawRect.x(), drawRect.maxX(), drawRect .y(), drawRect.maxY());
1150 GLC(m_context.get(), m_context->viewport(0, 0, drawRect.width(), drawRect.he ight())); 1166 GLC(m_context.get(), m_context->viewport(0, 0, drawRect.width(), drawRect.he ight()));
1167 m_windowMatrix = screenMatrix(0, 0, drawRect.width(), drawRect.height());
1151 } 1168 }
1152 1169
1153 1170
1154 1171
1155 void LayerRendererChromium::resizeOnscreenContent(const IntSize& size) 1172 void LayerRendererChromium::resizeOnscreenContent(const IntSize& size)
1156 { 1173 {
1157 if (m_context) 1174 if (m_context)
1158 m_context->reshape(size.width(), size.height()); 1175 m_context->reshape(size.width(), size.height());
1159 } 1176 }
1160 1177
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 { 1257 {
1241 if (!m_tilerProgramSwizzle) 1258 if (!m_tilerProgramSwizzle)
1242 m_tilerProgramSwizzle = adoptPtr(new LayerTilerChromium::ProgramSwizzle( m_context.get())); 1259 m_tilerProgramSwizzle = adoptPtr(new LayerTilerChromium::ProgramSwizzle( m_context.get()));
1243 if (!m_tilerProgramSwizzle->initialized()) { 1260 if (!m_tilerProgramSwizzle->initialized()) {
1244 TRACE_EVENT("LayerRendererChromium::tilerProgramSwizzle::initialize", th is, 0); 1261 TRACE_EVENT("LayerRendererChromium::tilerProgramSwizzle::initialize", th is, 0);
1245 m_tilerProgramSwizzle->initialize(); 1262 m_tilerProgramSwizzle->initialize();
1246 } 1263 }
1247 return m_tilerProgramSwizzle.get(); 1264 return m_tilerProgramSwizzle.get();
1248 } 1265 }
1249 1266
1267 const LayerTilerChromium::ProgramAA* LayerRendererChromium::tilerProgramAA()
1268 {
1269 if (!m_tilerProgramAA)
1270 m_tilerProgramAA = adoptPtr(new LayerTilerChromium::ProgramAA(m_context. get()));
1271 if (!m_tilerProgramAA->initialized()) {
1272 TRACE_EVENT("LayerRendererChromium::tilerProgramAA::initialize", this, 0 );
1273 m_tilerProgramAA->initialize();
1274 }
1275 return m_tilerProgramAA.get();
1276 }
1277
1278 const LayerTilerChromium::ProgramSwizzleAA* LayerRendererChromium::tilerProgramS wizzleAA()
1279 {
1280 if (!m_tilerProgramSwizzleAA)
1281 m_tilerProgramSwizzleAA = adoptPtr(new LayerTilerChromium::ProgramSwizzl eAA(m_context.get()));
1282 if (!m_tilerProgramSwizzleAA->initialized()) {
1283 TRACE_EVENT("LayerRendererChromium::tilerProgramSwizzleAA::initialize", this, 0);
1284 m_tilerProgramSwizzleAA->initialize();
1285 }
1286 return m_tilerProgramSwizzleAA.get();
1287 }
1288
1250 const CCCanvasLayerImpl::Program* LayerRendererChromium::canvasLayerProgram() 1289 const CCCanvasLayerImpl::Program* LayerRendererChromium::canvasLayerProgram()
1251 { 1290 {
1252 if (!m_canvasLayerProgram) 1291 if (!m_canvasLayerProgram)
1253 m_canvasLayerProgram = adoptPtr(new CCCanvasLayerImpl::Program(m_context .get())); 1292 m_canvasLayerProgram = adoptPtr(new CCCanvasLayerImpl::Program(m_context .get()));
1254 if (!m_canvasLayerProgram->initialized()) { 1293 if (!m_canvasLayerProgram->initialized()) {
1255 TRACE_EVENT("LayerRendererChromium::borderProgram::initialize", this, 0) ; 1294 TRACE_EVENT("LayerRendererChromium::borderProgram::initialize", this, 0) ;
1256 m_canvasLayerProgram->initialize(); 1295 m_canvasLayerProgram->initialize();
1257 } 1296 }
1258 return m_canvasLayerProgram.get(); 1297 return m_canvasLayerProgram.get();
1259 } 1298 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 PassOwnPtr<CCLayerTreeHostImplProxy> LayerRendererChromium::createLayerTreeHostI mplProxy() 1487 PassOwnPtr<CCLayerTreeHostImplProxy> LayerRendererChromium::createLayerTreeHostI mplProxy()
1449 { 1488 {
1450 OwnPtr<CCLayerTreeHostImplProxy> proxy = LayerRendererChromiumImplProxy::cre ate(this); 1489 OwnPtr<CCLayerTreeHostImplProxy> proxy = LayerRendererChromiumImplProxy::cre ate(this);
1451 proxy->start(); 1490 proxy->start();
1452 return proxy.release(); 1491 return proxy.release();
1453 } 1492 }
1454 1493
1455 } // namespace WebCore 1494 } // namespace WebCore
1456 1495
1457 #endif // USE(ACCELERATED_COMPOSITING) 1496 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698