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

Side by Side Diff: Source/core/platform/image-decoders/ImageFrame.cpp

Issue 23068027: Animated WebP: Optimize decoding in case of seeking (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add_noblend_image
Patch Set: Fix assert fail on debug Created 7 years, 3 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 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
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 21 matching lines...) Expand all
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 ImageFrame::ImageFrame() 35 ImageFrame::ImageFrame()
36 : m_bitmap(NativeImageSkia::create()) 36 : m_bitmap(NativeImageSkia::create())
37 , m_allocator(0) 37 , m_allocator(0)
38 , m_hasAlpha(false) 38 , m_hasAlpha(false)
39 , m_status(FrameEmpty) 39 , m_status(FrameEmpty)
40 , m_duration(0) 40 , m_duration(0)
41 , m_disposalMethod(DisposeNotSpecified) 41 , m_disposalMethod(DisposeNotSpecified)
42 , m_alphaBlendSource(BlendAtopPreviousFrame)
42 , m_premultiplyAlpha(true) 43 , m_premultiplyAlpha(true)
43 , m_requiredPreviousFrameIndex(notFound) 44 , m_requiredPreviousFrameIndex(notFound)
44 #if !ASSERT_DISABLED 45 #if !ASSERT_DISABLED
45 , m_requiredPreviousFrameIndexValid(false) 46 , m_requiredPreviousFrameIndexValid(false)
46 #endif 47 #endif
47 { 48 {
48 } 49 }
49 50
50 ImageFrame& ImageFrame::operator=(const ImageFrame& other) 51 ImageFrame& ImageFrame::operator=(const ImageFrame& other)
51 { 52 {
52 if (this == &other) 53 if (this == &other)
53 return *this; 54 return *this;
54 55
55 m_bitmap = other.m_bitmap->clone(); 56 m_bitmap = other.m_bitmap->clone();
56 // Keep the pixels locked since we will be writing directly into the 57 // Keep the pixels locked since we will be writing directly into the
57 // bitmap throughout this object's lifetime. 58 // bitmap throughout this object's lifetime.
58 m_bitmap->bitmap().lockPixels(); 59 m_bitmap->bitmap().lockPixels();
59 setMemoryAllocator(other.allocator()); 60 setMemoryAllocator(other.allocator());
60 setOriginalFrameRect(other.originalFrameRect()); 61 setOriginalFrameRect(other.originalFrameRect());
61 setStatus(other.status()); 62 setStatus(other.status());
62 setDuration(other.duration()); 63 setDuration(other.duration());
63 setDisposalMethod(other.disposalMethod()); 64 setDisposalMethod(other.disposalMethod());
65 setAlphaBlendSource(other.alphaBlendSource());
64 setPremultiplyAlpha(other.premultiplyAlpha()); 66 setPremultiplyAlpha(other.premultiplyAlpha());
65 // Be sure that this is called after we've called setStatus(), since we 67 // Be sure that this is called after we've called setStatus(), since we
66 // look at our status to know what to do with the alpha value. 68 // look at our status to know what to do with the alpha value.
67 setHasAlpha(other.hasAlpha()); 69 setHasAlpha(other.hasAlpha());
68 // Copy raw fields to avoid ASSERT failure in requiredPreviousFrameIndex(). 70 // Copy raw fields to avoid ASSERT failure in requiredPreviousFrameIndex().
69 m_requiredPreviousFrameIndex = other.m_requiredPreviousFrameIndex; 71 m_requiredPreviousFrameIndex = other.m_requiredPreviousFrameIndex;
70 #if !ASSERT_DISABLED 72 #if !ASSERT_DISABLED
71 m_requiredPreviousFrameIndexValid = other.m_requiredPreviousFrameIndexValid; 73 m_requiredPreviousFrameIndexValid = other.m_requiredPreviousFrameIndexValid;
72 #endif 74 #endif
73 return *this; 75 return *this;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 131
130 // If the frame is not fully loaded, there will be transparent pixels, 132 // If the frame is not fully loaded, there will be transparent pixels,
131 // so we can't tell skia we're opaque, even for image types that logically 133 // so we can't tell skia we're opaque, even for image types that logically
132 // always are (e.g. jpeg). 134 // always are (e.g. jpeg).
133 bool isOpaque = !m_hasAlpha; 135 bool isOpaque = !m_hasAlpha;
134 if (m_status != FrameComplete) 136 if (m_status != FrameComplete)
135 isOpaque = false; 137 isOpaque = false;
136 m_bitmap->bitmap().setIsOpaque(isOpaque); 138 m_bitmap->bitmap().setIsOpaque(isOpaque);
137 } 139 }
138 140
139 void ImageFrame::setStatus(FrameStatus status) 141 void ImageFrame::setStatus(Status status)
140 { 142 {
141 m_status = status; 143 m_status = status;
142 if (m_status == FrameComplete) { 144 if (m_status == FrameComplete) {
143 m_bitmap->bitmap().setIsOpaque(!m_hasAlpha); 145 m_bitmap->bitmap().setIsOpaque(!m_hasAlpha);
144 m_bitmap->setDataComplete(); // Tell the bitmap it's done. 146 m_bitmap->setDataComplete(); // Tell the bitmap it's done.
145 } 147 }
146 } 148 }
147 149
148 void ImageFrame::zeroFillFrameRect(const IntRect& rect) 150 void ImageFrame::zeroFillFrameRect(const IntRect& rect)
149 { 151 {
150 if (rect.isEmpty()) 152 if (rect.isEmpty())
151 return; 153 return;
152 154
153 m_bitmap->bitmap().eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); 155 m_bitmap->bitmap().eraseArea(rect, SkColorSetARGB(0, 0, 0, 0));
154 setHasAlpha(true); 156 setHasAlpha(true);
155 } 157 }
156 158
157 } // namespace WebCore 159 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/image-decoders/ImageDecoderTest.cpp ('k') | Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698