OLD | NEW |
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 "platform/graphics/StaticBitmapImage.h" | 5 #include "platform/graphics/StaticBitmapImage.h" |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
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 "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 { | 54 { |
55 return m_image && m_image->isTextureBacked(); | 55 return m_image && m_image->isTextureBacked(); |
56 } | 56 } |
57 | 57 |
58 bool StaticBitmapImage::currentFrameKnownToBeOpaque(MetadataMode) | 58 bool StaticBitmapImage::currentFrameKnownToBeOpaque(MetadataMode) |
59 { | 59 { |
60 return m_image->isOpaque(); | 60 return m_image->isOpaque(); |
61 } | 61 } |
62 | 62 |
63 void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float
Rect& dstRect, | 63 void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float
Rect& dstRect, |
64 const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode cla
mpMode) | 64 const FloatRect& srcRect, bool imageSmoothingEnabled, RespectImageOrientatio
nEnum, ImageClampingMode clampMode) |
65 { | 65 { |
66 FloatRect adjustedSrcRect = srcRect; | 66 FloatRect adjustedSrcRect = srcRect; |
67 adjustedSrcRect.intersect(SkRect::Make(m_image->bounds())); | 67 adjustedSrcRect.intersect(SkRect::Make(m_image->bounds())); |
68 | 68 |
69 if (dstRect.isEmpty() || adjustedSrcRect.isEmpty()) | 69 if (dstRect.isEmpty() || adjustedSrcRect.isEmpty()) |
70 return; // Nothing to draw. | 70 return; // Nothing to draw. |
71 | 71 |
72 canvas->drawImageRect(m_image.get(), adjustedSrcRect, dstRect, &paint, | 72 SkPaint adjustedPaint = paint; |
| 73 if (!imageSmoothingEnabled && Image::isDrawScalingDown(adjustedSrcRect, dstR
ect)) |
| 74 adjustedPaint.setFilterQuality(kLow_SkFilterQuality); |
| 75 |
| 76 canvas->drawImageRect(m_image.get(), adjustedSrcRect, dstRect, &adjustedPain
t, |
73 WebCoreClampingModeToSkiaRectConstraint(clampMode)); | 77 WebCoreClampingModeToSkiaRectConstraint(clampMode)); |
74 | 78 |
75 if (ImageObserver* observer = getImageObserver()) | 79 if (ImageObserver* observer = getImageObserver()) |
76 observer->didDraw(this); | 80 observer->didDraw(this); |
77 } | 81 } |
78 | 82 |
79 GLuint StaticBitmapImage::switchStorageToSkImage(WebGraphicsContext3DProvider* p
rovider) | 83 GLuint StaticBitmapImage::switchStorageToSkImage(WebGraphicsContext3DProvider* p
rovider) |
80 { | 84 { |
81 if (!provider) | 85 if (!provider) |
82 return 0; | 86 return 0; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // Has mailbox, consume mailbox, prepare a new mailbox if contextProvider is
not null (3D). | 179 // Has mailbox, consume mailbox, prepare a new mailbox if contextProvider is
not null (3D). |
176 DCHECK(isMainThread()); | 180 DCHECK(isMainThread()); |
177 // TODO(xidachen): make this work on a worker thread. | 181 // TODO(xidachen): make this work on a worker thread. |
178 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = wrapUnique(Pl
atform::current()->createSharedOffscreenGraphicsContext3DProvider()); | 182 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = wrapUnique(Pl
atform::current()->createSharedOffscreenGraphicsContext3DProvider()); |
179 if (!switchStorageToSkImage(sharedProvider.get())) | 183 if (!switchStorageToSkImage(sharedProvider.get())) |
180 return nullptr; | 184 return nullptr; |
181 return m_image; | 185 return m_image; |
182 } | 186 } |
183 | 187 |
184 } // namespace blink | 188 } // namespace blink |
OLD | NEW |