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

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

Issue 7210023: Merge 88386 - 2011-06-08 John Bauman <jbauman@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 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
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return; 339 return;
340 340
341 GraphicsContext3D* context = layerRendererContext(); 341 GraphicsContext3D* context = layerRendererContext();
342 const LayerTilerChromium::Program* program = layerRenderer()->tilerProgram() ; 342 const LayerTilerChromium::Program* program = layerRenderer()->tilerProgram() ;
343 GLC(context, context->useProgram(program->program())); 343 GLC(context, context->useProgram(program->program()));
344 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); 344 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
345 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); 345 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
346 346
347 int left, top, right, bottom; 347 int left, top, right, bottom;
348 contentRectToTileIndices(contentRect, left, top, right, bottom); 348 contentRectToTileIndices(contentRect, left, top, right, bottom);
349 IntRect layerRect = contentRectToLayerRect(contentRect);
349 for (int j = top; j <= bottom; ++j) { 350 for (int j = top; j <= bottom; ++j) {
350 for (int i = left; i <= right; ++i) { 351 for (int i = left; i <= right; ++i) {
351 Tile* tile = tileAt(i, j); 352 Tile* tile = tileAt(i, j);
352 if (!tile) 353 if (!tile)
353 continue; 354 continue;
354 355
355 tile->texture()->bindTexture(); 356 tile->texture()->bindTexture();
356 357
357 TransformationMatrix tileMatrix(globalTransform); 358 TransformationMatrix tileMatrix(globalTransform);
358 359
359 // Don't use tileContentRect here, as that contains the full 360 // Don't use tileContentRect here, as that contains the full
360 // rect with border texels which shouldn't be drawn. 361 // rect with border texels which shouldn't be drawn.
361 IntRect tileRect = m_tilingData.tileBounds(m_tilingData.tileIndex(ti le->i(), tile->j())); 362 IntRect tileRect = m_tilingData.tileBounds(m_tilingData.tileIndex(ti le->i(), tile->j()));
363 IntRect displayRect = tileRect;
364 tileRect.intersect(layerRect);
365 // Keep track of how the top left has moved, so the texture can be
366 // offset the same amount.
367 IntSize offset = tileRect.minXMinYCorner() - displayRect.minXMinYCor ner();
362 tileRect.move(m_layerPosition.x(), m_layerPosition.y()); 368 tileRect.move(m_layerPosition.x(), m_layerPosition.y());
363 tileMatrix.translate3d(tileRect.x() + tileRect.width() / 2.0, tileRe ct.y() + tileRect.height() / 2.0, 0); 369 tileMatrix.translate3d(tileRect.x() + tileRect.width() / 2.0, tileRe ct.y() + tileRect.height() / 2.0, 0);
364 370
365 IntPoint texOffset = m_tilingData.textureOffset(tile->i(), tile->j() ); 371 IntPoint texOffset = m_tilingData.textureOffset(tile->i(), tile->j() ) + offset;
366 float tileWidth = static_cast<float>(m_tileSize.width()); 372 float tileWidth = static_cast<float>(m_tileSize.width());
367 float tileHeight = static_cast<float>(m_tileSize.height()); 373 float tileHeight = static_cast<float>(m_tileSize.height());
368 float texTranslateX = texOffset.x() / tileWidth; 374 float texTranslateX = texOffset.x() / tileWidth;
369 float texTranslateY = texOffset.y() / tileHeight; 375 float texTranslateY = texOffset.y() / tileHeight;
370 float texScaleX = tileRect.width() / tileWidth; 376 float texScaleX = tileRect.width() / tileWidth;
371 float texScaleY = tileRect.height() / tileHeight; 377 float texScaleY = tileRect.height() / tileHeight;
372 // OpenGL coordinate system is bottom-up. 378 // OpenGL coordinate system is bottom-up.
373 // If tile texture is top-down, we need to flip the texture coordina tes. 379 // If tile texture is top-down, we need to flip the texture coordina tes.
374 if (m_textureUpdater->orientation() == LayerTextureUpdater::TopDownO rientation) { 380 if (m_textureUpdater->orientation() == LayerTextureUpdater::TopDownO rientation) {
375 texTranslateY += 1.0; 381 texTranslateY += 1.0;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 419
414 GLC(context, context->uniform4f(program->vertexShader().texTransformLocation (), 420 GLC(context, context->uniform4f(program->vertexShader().texTransformLocation (),
415 texTranslateX, texTranslateY, texScaleX, texScaleY)); 421 texTranslateX, texTranslateY, texScaleX, texScaleY));
416 422
417 GLC(context, context->drawElements(GraphicsContext3D::TRIANGLES, 6, Graphics Context3D::UNSIGNED_SHORT, 0)); 423 GLC(context, context->drawElements(GraphicsContext3D::TRIANGLES, 6, Graphics Context3D::UNSIGNED_SHORT, 0));
418 } 424 }
419 425
420 } // namespace WebCore 426 } // namespace WebCore
421 427
422 #endif // USE(ACCELERATED_COMPOSITING) 428 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « Source/WebCore/ChangeLog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698