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

Side by Side Diff: Source/core/frame/Frame.cpp

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase mayhem Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/frame/ImageBitmap.cpp » ('j') | 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 642
643 LayoutRect topLevelRect; 643 LayoutRect topLevelRect;
644 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect)); 644 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect));
645 645
646 float deviceScaleFactor = 1; 646 float deviceScaleFactor = 1;
647 if (m_page) 647 if (m_page)
648 deviceScaleFactor = m_page->deviceScaleFactor(); 648 deviceScaleFactor = m_page->deviceScaleFactor();
649 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 649 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
650 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 650 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
651 651
652 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); 652 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size());
653 if (!buffer) 653 if (!buffer)
654 return nullptr; 654 return nullptr;
655 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
655 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 656 buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
656 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 657 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY()));
657 658
658 m_view->paintContents(buffer->context(), paintingRect); 659 m_view->paintContents(buffer->context(), paintingRect);
659 660
660 RefPtr<Image> image = buffer->copyImage(); 661 RefPtr<Image> image = buffer->copyImage();
661 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n()); 662 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n());
662 } 663 }
663 664
664 PassOwnPtr<DragImage> Frame::dragImageForSelection() 665 PassOwnPtr<DragImage> Frame::dragImageForSelection()
665 { 666 {
666 if (!selection().isRange()) 667 if (!selection().isRange())
667 return nullptr; 668 return nullptr;
668 669
669 const ScopedFramePaintingState state(this, 0); 670 const ScopedFramePaintingState state(this, 0);
670 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers); 671 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers);
671 document()->updateLayout(); 672 document()->updateLayout();
672 673
673 IntRect paintingRect = enclosingIntRect(selection().bounds()); 674 IntRect paintingRect = enclosingIntRect(selection().bounds());
674 675
675 float deviceScaleFactor = 1; 676 float deviceScaleFactor = 1;
676 if (m_page) 677 if (m_page)
677 deviceScaleFactor = m_page->deviceScaleFactor(); 678 deviceScaleFactor = m_page->deviceScaleFactor();
678 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 679 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
679 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 680 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
680 681
681 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); 682 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size());
682 if (!buffer) 683 if (!buffer)
683 return nullptr; 684 return nullptr;
685 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
684 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 686 buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
685 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 687 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY()));
686 688
687 m_view->paintContents(buffer->context(), paintingRect); 689 m_view->paintContents(buffer->context(), paintingRect);
688 690
689 RefPtr<Image> image = buffer->copyImage(); 691 RefPtr<Image> image = buffer->copyImage();
690 return DragImage::create(image.get()); 692 return DragImage::create(image.get());
691 } 693 }
692 694
693 double Frame::devicePixelRatio() const 695 double Frame::devicePixelRatio() const
694 { 696 {
695 if (!m_page) 697 if (!m_page)
696 return 0; 698 return 0;
697 699
698 double ratio = m_page->deviceScaleFactor(); 700 double ratio = m_page->deviceScaleFactor();
699 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled()) 701 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled())
700 ratio *= pageZoomFactor(); 702 ratio *= pageZoomFactor();
701 return ratio; 703 return ratio;
702 } 704 }
703 705
704 } // namespace WebCore 706 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/ImageBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698