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

Side by Side Diff: Source/platform/graphics/StaticBitmapImage.cpp

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/graphics/StaticBitmapImage.h" 6 #include "platform/graphics/StaticBitmapImage.h"
7 7
8 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/ImageObserver.h" 9 #include "platform/graphics/ImageObserver.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 18 matching lines...) Expand all
29 IntSize StaticBitmapImage::size() const 29 IntSize StaticBitmapImage::size() const
30 { 30 {
31 return IntSize(m_image->width(), m_image->height()); 31 return IntSize(m_image->width(), m_image->height());
32 } 32 }
33 33
34 bool StaticBitmapImage::currentFrameKnownToBeOpaque() 34 bool StaticBitmapImage::currentFrameKnownToBeOpaque()
35 { 35 {
36 return m_image->isOpaque(); 36 return m_image->isOpaque();
37 } 37 }
38 38
39 void StaticBitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, con st FloatRect& srcRect, SkXfermode::Mode compositeOp, RespectImageOrientationEnum ) 39 void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float Rect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum)
40 { 40 {
41 FloatRect normDstRect = adjustForNegativeSize(dstRect); 41 FloatRect normDstRect = adjustForNegativeSize(dstRect);
42 FloatRect normSrcRect = adjustForNegativeSize(srcRect); 42 FloatRect normSrcRect = adjustForNegativeSize(srcRect);
43 43
44 normSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height())); 44 normSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height()));
45 45
46 if (normSrcRect.isEmpty() || normDstRect.isEmpty()) 46 if (normSrcRect.isEmpty() || normDstRect.isEmpty())
47 return; // Nothing to draw. 47 return; // Nothing to draw.
48 48
49 ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.height() <= m_ image->height()); 49 ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.height() <= m_ image->height());
50 50
51 { 51 SkRect srcSkRect = WebCoreFloatRectToSKRect(normSrcRect);
52 SkCanvas* canvas = ctx->canvas(); 52 SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect);
53 53
54 SkPaint paint; 54 canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &paint);
55 int initialSaveCount = ctx->preparePaintForDrawRectToRect(&paint, srcRec t, dstRect, compositeOp, !currentFrameKnownToBeOpaque());
56
57 SkRect srcSkRect = WebCoreFloatRectToSKRect(normSrcRect);
58 SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect);
59
60 canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &paint);
61 canvas->restoreToCount(initialSaveCount);
62 }
63 55
64 if (ImageObserver* observer = imageObserver()) 56 if (ImageObserver* observer = imageObserver())
65 observer->didDraw(this); 57 observer->didDraw(this);
66 } 58 }
67 59
68 } // namespace blink 60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698