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

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

Issue 2918443003: Remove redundant reading and writing of data about SharedBuffer.
Patch Set: benchmark Created 3 years, 6 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 118
119 void BitmapImage::DestroyDecodedData() { 119 void BitmapImage::DestroyDecodedData() {
120 cached_frame_.reset(); 120 cached_frame_.reset();
121 for (size_t i = 0; i < frames_.size(); ++i) 121 for (size_t i = 0; i < frames_.size(); ++i)
122 frames_[i].Clear(true); 122 frames_[i].Clear(true);
123 source_.ClearCacheExceptFrame(kNotFound); 123 source_.ClearCacheExceptFrame(kNotFound);
124 NotifyMemoryChanged(); 124 NotifyMemoryChanged();
125 } 125 }
126 126
127 PassRefPtr<SharedBuffer> BitmapImage::Data() {
128 return source_.Data();
129 }
130
131 void BitmapImage::NotifyMemoryChanged() { 127 void BitmapImage::NotifyMemoryChanged() {
132 if (GetImageObserver()) 128 if (GetImageObserver())
133 GetImageObserver()->DecodedSizeChangedTo(this, TotalFrameBytes()); 129 GetImageObserver()->DecodedSizeChangedTo(this, TotalFrameBytes());
134 } 130 }
135 131
136 size_t BitmapImage::TotalFrameBytes() { 132 size_t BitmapImage::TotalFrameBytes() {
137 const size_t num_frames = FrameCount(); 133 const size_t num_frames = FrameCount();
138 size_t total_bytes = 0; 134 size_t total_bytes = 0;
139 for (size_t i = 0; i < num_frames; ++i) 135 for (size_t i = 0; i < num_frames; ++i)
140 total_bytes += source_.FrameBytesAtIndex(i); 136 total_bytes += source_.FrameBytesAtIndex(i);
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 639
644 return true; 640 return true;
645 } 641 }
646 642
647 void BitmapImage::NotifyObserversOfAnimationAdvance(TimerBase*) { 643 void BitmapImage::NotifyObserversOfAnimationAdvance(TimerBase*) {
648 if (GetImageObserver()) 644 if (GetImageObserver())
649 GetImageObserver()->AnimationAdvanced(this); 645 GetImageObserver()->AnimationAdvanced(this);
650 } 646 }
651 647
652 } // namespace blink 648 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698