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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 3 years, 12 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 18 matching lines...) Expand all
29 #include "platform/PlatformInstrumentation.h" 29 #include "platform/PlatformInstrumentation.h"
30 #include "platform/Timer.h" 30 #include "platform/Timer.h"
31 #include "platform/geometry/FloatRect.h" 31 #include "platform/geometry/FloatRect.h"
32 #include "platform/graphics/BitmapImageMetrics.h" 32 #include "platform/graphics/BitmapImageMetrics.h"
33 #include "platform/graphics/DeferredImageDecoder.h" 33 #include "platform/graphics/DeferredImageDecoder.h"
34 #include "platform/graphics/ImageObserver.h" 34 #include "platform/graphics/ImageObserver.h"
35 #include "platform/graphics/StaticBitmapImage.h" 35 #include "platform/graphics/StaticBitmapImage.h"
36 #include "platform/graphics/skia/SkiaUtils.h" 36 #include "platform/graphics/skia/SkiaUtils.h"
37 #include "platform/tracing/TraceEvent.h" 37 #include "platform/tracing/TraceEvent.h"
38 #include "third_party/skia/include/core/SkCanvas.h" 38 #include "third_party/skia/include/core/SkCanvas.h"
39 #include "skia/ext/cdl_canvas.h"
40 #include "skia/ext/cdl_paint.h"
39 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
40 #include "wtf/PtrUtil.h" 42 #include "wtf/PtrUtil.h"
41 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
42 44
43 namespace blink { 45 namespace blink {
44 46
45 PassRefPtr<BitmapImage> BitmapImage::createWithOrientationForTesting( 47 PassRefPtr<BitmapImage> BitmapImage::createWithOrientationForTesting(
46 const SkBitmap& bitmap, 48 const SkBitmap& bitmap,
47 ImageOrientation orientation) { 49 ImageOrientation orientation) {
48 if (bitmap.isNull()) { 50 if (bitmap.isNull()) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 235
234 bool BitmapImage::hasColorProfile() const { 236 bool BitmapImage::hasColorProfile() const {
235 return m_source.hasColorProfile(); 237 return m_source.hasColorProfile();
236 } 238 }
237 239
238 String BitmapImage::filenameExtension() const { 240 String BitmapImage::filenameExtension() const {
239 return m_source.filenameExtension(); 241 return m_source.filenameExtension();
240 } 242 }
241 243
242 void BitmapImage::draw( 244 void BitmapImage::draw(
243 SkCanvas* canvas, 245 CdlCanvas* canvas,
244 const SkPaint& paint, 246 const CdlPaint& paint,
245 const FloatRect& dstRect, 247 const FloatRect& dstRect,
246 const FloatRect& srcRect, 248 const FloatRect& srcRect,
247 RespectImageOrientationEnum shouldRespectImageOrientation, 249 RespectImageOrientationEnum shouldRespectImageOrientation,
248 ImageClampingMode clampMode) { 250 ImageClampingMode clampMode) {
249 TRACE_EVENT0("skia", "BitmapImage::draw"); 251 TRACE_EVENT0("skia", "BitmapImage::draw");
250 252
251 sk_sp<SkImage> image = imageForCurrentFrame(); 253 sk_sp<SkImage> image = imageForCurrentFrame();
252 if (!image) 254 if (!image)
253 return; // It's too early and we don't have an image yet. 255 return; // It's too early and we don't have an image yet.
254 256
255 FloatRect adjustedSrcRect = srcRect; 257 FloatRect adjustedSrcRect = srcRect;
256 adjustedSrcRect.intersect(SkRect::Make(image->bounds())); 258 adjustedSrcRect.intersect(SkRect::Make(image->bounds()));
257 259
258 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) 260 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty())
259 return; // Nothing to draw. 261 return; // Nothing to draw.
260 262
261 ImageOrientation orientation = DefaultImageOrientation; 263 ImageOrientation orientation = DefaultImageOrientation;
262 if (shouldRespectImageOrientation == RespectImageOrientation) 264 if (shouldRespectImageOrientation == RespectImageOrientation)
263 orientation = frameOrientationAtIndex(m_currentFrame); 265 orientation = frameOrientationAtIndex(m_currentFrame);
264 266
265 SkAutoCanvasRestore autoRestore(canvas, false); 267 CdlAutoCanvasRestore autoRestore(canvas, false);
266 FloatRect adjustedDstRect = dstRect; 268 FloatRect adjustedDstRect = dstRect;
267 if (orientation != DefaultImageOrientation) { 269 if (orientation != DefaultImageOrientation) {
268 canvas->save(); 270 canvas->save();
269 271
270 // ImageOrientation expects the origin to be at (0, 0) 272 // ImageOrientation expects the origin to be at (0, 0)
271 canvas->translate(adjustedDstRect.x(), adjustedDstRect.y()); 273 canvas->translate(adjustedDstRect.x(), adjustedDstRect.y());
272 adjustedDstRect.setLocation(FloatPoint()); 274 adjustedDstRect.setLocation(FloatPoint());
273 275
274 canvas->concat(affineTransformToSkMatrix( 276 canvas->concat(affineTransformToSkMatrix(
275 orientation.transformFromDefault(adjustedDstRect.size()))); 277 orientation.transformFromDefault(adjustedDstRect.size())));
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 getImageObserver()->animationAdvanced(this); 623 getImageObserver()->animationAdvanced(this);
622 624
623 return true; 625 return true;
624 } 626 }
625 627
626 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) { 628 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) {
627 getImageObserver()->animationAdvanced(this); 629 getImageObserver()->animationAdvanced(this);
628 } 630 }
629 631
630 } // namespace blink 632 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/BitmapImage.h ('k') | third_party/WebKit/Source/platform/graphics/BoxReflection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698