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

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

Issue 323013004: Clean up transform methods in GraphicsContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2nd Attempt Mac build fix Created 6 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 | « no previous file | Source/core/html/canvas/CanvasRenderingContext2D.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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect)); 573 IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLev elRect));
574 574
575 ASSERT(document()->isActive()); 575 ASSERT(document()->isActive());
576 float deviceScaleFactor = m_host->deviceScaleFactor(); 576 float deviceScaleFactor = m_host->deviceScaleFactor();
577 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 577 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
578 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 578 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
579 579
580 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size()); 580 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size());
581 if (!buffer) 581 if (!buffer)
582 return nullptr; 582 return nullptr;
583 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); 583 buffer->context()->scale(deviceScaleFactor, deviceScaleFactor);
584 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 584 buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
585 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 585 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY()));
586 586
587 m_view->paintContents(buffer->context(), paintingRect); 587 m_view->paintContents(buffer->context(), paintingRect);
588 588
589 RefPtr<Image> image = buffer->copyImage(); 589 RefPtr<Image> image = buffer->copyImage();
590 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n(), deviceScaleFactor); 590 return DragImage::create(image.get(), renderer->shouldRespectImageOrientatio n(), deviceScaleFactor);
591 } 591 }
592 592
593 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection() 593 PassOwnPtr<DragImage> LocalFrame::dragImageForSelection()
594 { 594 {
595 if (!selection().isRange()) 595 if (!selection().isRange())
596 return nullptr; 596 return nullptr;
597 597
598 const ScopedFramePaintingState state(this, 0); 598 const ScopedFramePaintingState state(this, 0);
599 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers); 599 m_view->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorFlattenCo mpositingLayers);
600 document()->updateLayout(); 600 document()->updateLayout();
601 601
602 IntRect paintingRect = enclosingIntRect(selection().bounds()); 602 IntRect paintingRect = enclosingIntRect(selection().bounds());
603 603
604 ASSERT(document()->isActive()); 604 ASSERT(document()->isActive());
605 float deviceScaleFactor = m_host->deviceScaleFactor(); 605 float deviceScaleFactor = m_host->deviceScaleFactor();
606 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor); 606 paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
607 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor); 607 paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
608 608
609 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size()); 609 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(paintingRect.size());
610 if (!buffer) 610 if (!buffer)
611 return nullptr; 611 return nullptr;
612 buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); 612 buffer->context()->scale(deviceScaleFactor, deviceScaleFactor);
613 buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); 613 buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
614 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY())); 614 buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.ma xY()));
615 615
616 m_view->paintContents(buffer->context(), paintingRect); 616 m_view->paintContents(buffer->context(), paintingRect);
617 617
618 RefPtr<Image> image = buffer->copyImage(); 618 RefPtr<Image> image = buffer->copyImage();
619 return DragImage::create(image.get(), DoNotRespectImageOrientation, deviceSc aleFactor); 619 return DragImage::create(image.get(), DoNotRespectImageOrientation, deviceSc aleFactor);
620 } 620 }
621 621
622 double LocalFrame::devicePixelRatio() const 622 double LocalFrame::devicePixelRatio() const
(...skipping 18 matching lines...) Expand all
641 LocalFrame* LocalFrame::localFrameRoot() 641 LocalFrame* LocalFrame::localFrameRoot()
642 { 642 {
643 LocalFrame* curFrame = this; 643 LocalFrame* curFrame = this;
644 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame()) 644 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame())
645 curFrame = curFrame->tree().parent(); 645 curFrame = curFrame->tree().parent();
646 646
647 return curFrame; 647 return curFrame;
648 } 648 }
649 649
650 } // namespace WebCore 650 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698