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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Clean up comments, fix mac build Created 3 years, 11 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 16 matching lines...) Expand all
27 #include "platform/graphics/BitmapImage.h" 27 #include "platform/graphics/BitmapImage.h"
28 28
29 #include "platform/PlatformInstrumentation.h" 29 #include "platform/PlatformInstrumentation.h"
30 #include "platform/RuntimeEnabledFeatures.h" 30 #include "platform/RuntimeEnabledFeatures.h"
31 #include "platform/Timer.h" 31 #include "platform/Timer.h"
32 #include "platform/geometry/FloatRect.h" 32 #include "platform/geometry/FloatRect.h"
33 #include "platform/graphics/BitmapImageMetrics.h" 33 #include "platform/graphics/BitmapImageMetrics.h"
34 #include "platform/graphics/DeferredImageDecoder.h" 34 #include "platform/graphics/DeferredImageDecoder.h"
35 #include "platform/graphics/ImageObserver.h" 35 #include "platform/graphics/ImageObserver.h"
36 #include "platform/graphics/StaticBitmapImage.h" 36 #include "platform/graphics/StaticBitmapImage.h"
37 #include "platform/graphics/paint/PaintCanvas.h"
38 #include "platform/graphics/paint/PaintFlags.h"
37 #include "platform/graphics/skia/SkiaUtils.h" 39 #include "platform/graphics/skia/SkiaUtils.h"
38 #include "platform/instrumentation/tracing/TraceEvent.h" 40 #include "platform/instrumentation/tracing/TraceEvent.h"
39 #include "third_party/skia/include/core/SkCanvas.h"
40 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
41 #include "wtf/PtrUtil.h" 42 #include "wtf/PtrUtil.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 namespace { 47 namespace {
47 48
48 ColorBehavior defaultColorBehavior() { 49 ColorBehavior defaultColorBehavior() {
49 // TODO(ccameron): ColorBehavior should be specified by the caller requesting 50 // TODO(ccameron): ColorBehavior should be specified by the caller requesting
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 254
254 bool BitmapImage::hasColorProfile() const { 255 bool BitmapImage::hasColorProfile() const {
255 return m_source.hasColorProfile(); 256 return m_source.hasColorProfile();
256 } 257 }
257 258
258 String BitmapImage::filenameExtension() const { 259 String BitmapImage::filenameExtension() const {
259 return m_source.filenameExtension(); 260 return m_source.filenameExtension();
260 } 261 }
261 262
262 void BitmapImage::draw( 263 void BitmapImage::draw(
263 SkCanvas* canvas, 264 PaintCanvas* canvas,
264 const SkPaint& paint, 265 const PaintFlags& paint,
265 const FloatRect& dstRect, 266 const FloatRect& dstRect,
266 const FloatRect& srcRect, 267 const FloatRect& srcRect,
267 RespectImageOrientationEnum shouldRespectImageOrientation, 268 RespectImageOrientationEnum shouldRespectImageOrientation,
268 ImageClampingMode clampMode, 269 ImageClampingMode clampMode,
269 const ColorBehavior& colorBehavior) { 270 const ColorBehavior& colorBehavior) {
270 TRACE_EVENT0("skia", "BitmapImage::draw"); 271 TRACE_EVENT0("skia", "BitmapImage::draw");
271 272
272 sk_sp<SkImage> image = imageForCurrentFrame(colorBehavior); 273 sk_sp<SkImage> image = imageForCurrentFrame(colorBehavior);
273 if (!image) 274 if (!image)
274 return; // It's too early and we don't have an image yet. 275 return; // It's too early and we don't have an image yet.
275 276
276 FloatRect adjustedSrcRect = srcRect; 277 FloatRect adjustedSrcRect = srcRect;
277 adjustedSrcRect.intersect(SkRect::Make(image->bounds())); 278 adjustedSrcRect.intersect(SkRect::Make(image->bounds()));
278 279
279 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) 280 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty())
280 return; // Nothing to draw. 281 return; // Nothing to draw.
281 282
282 ImageOrientation orientation = DefaultImageOrientation; 283 ImageOrientation orientation = DefaultImageOrientation;
283 if (shouldRespectImageOrientation == RespectImageOrientation) 284 if (shouldRespectImageOrientation == RespectImageOrientation)
284 orientation = frameOrientationAtIndex(m_currentFrame); 285 orientation = frameOrientationAtIndex(m_currentFrame);
285 286
286 SkAutoCanvasRestore autoRestore(canvas, false); 287 PaintCanvasAutoRestore autoRestore(canvas, false);
287 FloatRect adjustedDstRect = dstRect; 288 FloatRect adjustedDstRect = dstRect;
288 if (orientation != DefaultImageOrientation) { 289 if (orientation != DefaultImageOrientation) {
289 canvas->save(); 290 canvas->save();
290 291
291 // ImageOrientation expects the origin to be at (0, 0) 292 // ImageOrientation expects the origin to be at (0, 0)
292 canvas->translate(adjustedDstRect.x(), adjustedDstRect.y()); 293 canvas->translate(adjustedDstRect.x(), adjustedDstRect.y());
293 adjustedDstRect.setLocation(FloatPoint()); 294 adjustedDstRect.setLocation(FloatPoint());
294 295
295 canvas->concat(affineTransformToSkMatrix( 296 canvas->concat(affineTransformToSkMatrix(
296 orientation.transformFromDefault(adjustedDstRect.size()))); 297 orientation.transformFromDefault(adjustedDstRect.size())));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 getImageObserver()->animationAdvanced(this); 653 getImageObserver()->animationAdvanced(this);
653 654
654 return true; 655 return true;
655 } 656 }
656 657
657 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) { 658 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) {
658 getImageObserver()->animationAdvanced(this); 659 getImageObserver()->animationAdvanced(this);
659 } 660 }
660 661
661 } // namespace blink 662 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698