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

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: build fixes for win+mac 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "core/frame/animation/AnimationController.h" 58 #include "core/frame/animation/AnimationController.h"
59 #include "core/page/scrolling/ScrollingCoordinator.h" 59 #include "core/page/scrolling/ScrollingCoordinator.h"
60 #include "core/platform/DragImage.h" 60 #include "core/platform/DragImage.h"
61 #include "core/platform/graphics/GraphicsContext.h" 61 #include "core/platform/graphics/GraphicsContext.h"
62 #include "core/platform/graphics/ImageBuffer.h" 62 #include "core/platform/graphics/ImageBuffer.h"
63 #include "core/rendering/HitTestResult.h" 63 #include "core/rendering/HitTestResult.h"
64 #include "core/rendering/RenderLayerCompositor.h" 64 #include "core/rendering/RenderLayerCompositor.h"
65 #include "core/rendering/RenderPart.h" 65 #include "core/rendering/RenderPart.h"
66 #include "core/rendering/RenderView.h" 66 #include "core/rendering/RenderView.h"
67 #include "core/svg/SVGDocument.h" 67 #include "core/svg/SVGDocument.h"
68 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
68 #include "wtf/PassOwnPtr.h" 69 #include "wtf/PassOwnPtr.h"
69 #include "wtf/RefCountedLeakCounter.h" 70 #include "wtf/RefCountedLeakCounter.h"
70 #include "wtf/StdLibExtras.h" 71 #include "wtf/StdLibExtras.h"
71 72
72 using namespace std; 73 using namespace std;
73 74
74 namespace WebCore { 75 namespace WebCore {
75 76
76 using namespace HTMLNames; 77 using namespace HTMLNames;
77 78
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 643
643 LayoutRect topLevelRect; 644 LayoutRect topLevelRect;
644 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect)); 645 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect));
645 646
646 float deviceScaleFactor = 1; 647 float deviceScaleFactor = 1;
647 if (m_page) 648 if (m_page)
648 deviceScaleFactor = m_page->deviceScaleFactor(); 649 deviceScaleFactor = m_page->deviceScaleFactor();
649 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 650 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
650 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 651 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
651 652
652 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); 653 OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSu rface(paintingRect.size(), NonOpaque, deviceScaleFactor));
653 if (!buffer) 654 if (!surface->isValid())
654 return nullptr; 655 return nullptr;
655 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 656 ImageBuffer buffer(surface.release());
656 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 657 buffer.context()->translate(-paintingRect.x(), -paintingRect.y());
658 buffer.context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.max Y()));
657 659
658 m_view->paintContents(buffer->context(), paintingRect); 660 m_view->paintContents(buffer.context(), paintingRect);
659 661
660 RefPtr<Image> image = buffer->copyImage(); 662 RefPtr<Image> image = buffer.copyImage();
661 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n()); 663 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n());
662 } 664 }
663 665
664 PassOwnPtr<DragImage> Frame::dragImageForSelection() 666 PassOwnPtr<DragImage> Frame::dragImageForSelection()
665 { 667 {
666 if (!selection().isRange()) 668 if (!selection().isRange())
667 return nullptr; 669 return nullptr;
668 670
669 const ScopedFramePaintingState state(this, 0); 671 const ScopedFramePaintingState state(this, 0);
670 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers); 672 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers);
671 document()->updateLayout(); 673 document()->updateLayout();
672 674
673 IntRect paintingRect = enclosingIntRect(selection().bounds()); 675 IntRect paintingRect = enclosingIntRect(selection().bounds());
674 676
675 float deviceScaleFactor = 1; 677 float deviceScaleFactor = 1;
676 if (m_page) 678 if (m_page)
677 deviceScaleFactor = m_page->deviceScaleFactor(); 679 deviceScaleFactor = m_page->deviceScaleFactor();
678 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 680 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
679 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 681 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
680 682
681 OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceSc aleFactor)); 683 OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSu rface(paintingRect.size(), NonOpaque, deviceScaleFactor));
682 if (!buffer) 684 if (!surface->isValid())
683 return nullptr; 685 return nullptr;
684 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 686 ImageBuffer buffer(surface.release());
685 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 687 buffer.context()->translate(-paintingRect.x(), -paintingRect.y());
688 buffer.context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.max Y()));
686 689
687 m_view->paintContents(buffer->context(), paintingRect); 690 m_view->paintContents(buffer.context(), paintingRect);
688 691
689 RefPtr<Image> image = buffer->copyImage(); 692 RefPtr<Image> image = buffer.copyImage();
690 return DragImage::create(image.get()); 693 return DragImage::create(image.get());
691 } 694 }
692 695
693 double Frame::devicePixelRatio() const 696 double Frame::devicePixelRatio() const
694 { 697 {
695 if (!m_page) 698 if (!m_page)
696 return 0; 699 return 0;
697 700
698 double ratio = m_page->deviceScaleFactor(); 701 double ratio = m_page->deviceScaleFactor();
699 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled()) 702 if (RuntimeEnabledFeatures::devicePixelRatioIncludesZoomEnabled())
700 ratio *= pageZoomFactor(); 703 ratio *= pageZoomFactor();
701 return ratio; 704 return ratio;
702 } 705 }
703 706
704 } // namespace WebCore 707 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698