void FramesWeightFrame::mouseMoveEvent(QMouseEvent* mouseEvent) { if(mouseDown) { weightedFrame = mouseEvent->x()/FrameBarWidth; if(weightedFrame<0 || weightedFrame>=frameCount()) return; adjustWeight(mouseEvent->y()); repaint(); } }
TEST_F(BitmapImageTest, destroyDecodedDataExceptCurrentFrame) { loadImage("/LayoutTests/fast/images/resources/animated-10color.gif"); size_t totalSize = decodedSize(); size_t frame = frameCount() / 2; setCurrentFrame(frame); size_t size = frameDecodedSize(frame); destroyDecodedData(false); EXPECT_LT(m_imageObserver->m_lastDecodedSizeChangedDelta, 0); EXPECT_GE(m_imageObserver->m_lastDecodedSizeChangedDelta, -static_cast<int>(totalSize - size)); }
RGBA32Buffer* GIFImageDecoder::frameBufferAtIndex(size_t index) { if (index >= (unsigned)frameCount()) return 0; RGBA32Buffer& frame = m_frameBufferCache[index]; if (frame.status() != RGBA32Buffer::FrameComplete && m_reader) // Decode this frame. decode(GIFFullQuery, index+1); return &frame; }
void Image::startAnimation() { if (m_frameTimer || !shouldAnimate() || frameCount() <= 1) return; // Don't advance the animation until the current frame has completely loaded. if (!m_source.frameIsCompleteAtIndex(m_currentFrame)) return; m_frameTimer = new Timer<Image>(this, &Image::advanceAnimation); m_frameTimer->startOneShot(frameDurationAtIndex(m_currentFrame)); }
int main( ){ long * ret = getFP( ); printf( "A: %i\n", a( ) ); printf( "B: %i\n", b( ) ); printf( "C: %i\n", c( ) ); printf( "Main: %i\n", frameCount() ); return *ret; }
CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size) { size_t count = frameCount(); for (size_t i = 0; i < count; ++i) { CGImageRef cgImage = frameAtIndex(i); if (cgImage && IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size) return cgImage; } // Fallback to the default CGImageRef if we can't find the right size return getCGImageRef(); }
bool BitmapImage::ensureFrameIsCached(size_t index, ImageFrameCaching frameCaching) { if (index >= frameCount()) return false; if (index >= m_frames.size() || (frameCaching == CacheMetadataAndFrame && !m_frames[index].m_image) || (frameCaching == CacheMetadataOnly && !m_frames[index].m_haveMetadata)) cacheFrame(index, 0, frameCaching); return true; }
void BitmapImage::resetAnimation() { stopAnimation(); m_currentFrame = 0; m_repetitionsComplete = 0; m_animationFinished = false; int frameSize = m_size.width() * m_size.height() * 4; // For extremely large animations, when the animation is reset, we just throw everything away. if (frameCount() * frameSize > cLargeAnimationCutoff) destroyDecodedData(); }
bool BitmapImage::mayFillWithSolidColor() { if (!m_checkedForSolidColor && frameCount() > 0) { checkForSolidColor(); // WINCE PORT: checkForSolidColor() doesn't set m_checkedForSolidColor until // it gets enough information to make final decision. #if !OS(WINCE) ASSERT(m_checkedForSolidColor); #endif } return m_isSolidColor && !m_currentFrame; }
void Image::advanceAnimation(Timer<Image>* timer) { // Stop the animation. stopAnimation(); // See if anyone is still paying attention to this animation. If not, we don't // advance and will remain suspended at the current frame until the animation is resumed. if (imageObserver()->shouldPauseAnimation(this)) return; m_currentFrame++; if (m_currentFrame >= frameCount()) { m_repetitionsComplete += 1; if (m_repetitionCount && m_repetitionsComplete >= m_repetitionCount) { m_animationFinished = true; m_currentFrame--; return; } m_currentFrame = 0; } // Notify our observer that the animation has advanced. imageObserver()->animationAdvanced(this); // For large animated images, go ahead and throw away frames as we go to save // footprint. int frameSize = m_size.width() * m_size.height() * 4; if (frameCount() * frameSize > cLargeAnimationCutoff) { // Destroy all of our frames and just redecode every time. destroyDecodedData(); // Go ahead and decode the next frame. frameAtIndex(m_currentFrame); } // We do not advance the animation explicitly. We rely on a subsequent draw of the image // to force a request for the next frame via startAnimation(). This allows images that move offscreen while // scrolling to stop animating (thus saving memory from additional decoded frames and // CPU time spent doing the decoding). }
ImageFrame* GIFImageDecoder::frameBufferAtIndex(size_t index) { if (index >= frameCount()) return 0; ImageFrame& frame = m_frameBufferCache[index]; if (frame.status() != ImageFrame::FrameComplete) { PlatformInstrumentation::willDecodeImage("GIF"); decode(index); PlatformInstrumentation::didDecodeImage(); } return &frame; }
ImageFrame* GIFImageDecoder::frameBufferAtIndex(size_t index) { if (index >= frameCount()) return 0; ImageFrame& frame = m_frameBufferCache[index]; if (frame.status() != ImageFrame::FrameComplete) { decode(index); } frame.notifyBitmapIfPixelsChanged(); return &frame; }
void SpriteObject::age() { if( mLifeSpan > 0 ) { mLifeSpan--; } mCycle++; moveBy(vx, vy); if( mCycle > mSeq->delay( frame() ) ) { setFrame((frame()+1)%frameCount()); mCycle = 0; } }
RetainPtr<CFArrayRef> BitmapImage::getCGImageArray() { size_t count = frameCount(); if (!count) return 0; CFMutableArrayRef array = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks); for (size_t i = 0; i < count; ++i) { if (CGImageRef currFrame = frameAtIndex(i)) CFArrayAppendValue(array, currFrame); } return adoptCF(array); }
PassNativeImagePtr BitmapImage::copyUnscaledFrameAtIndex(size_t index) { if (index >= frameCount()) return nullptr; if (index >= m_frames.size() || !m_frames[index].m_frame) cacheFrame(index, 0); if (!m_frames[index].m_subsamplingLevel) return CGImageRetain(m_frames[index].m_frame); return m_source.createFrameAtIndex(index); }
//============================================================== // Функция вызывается при перемещении мыши //============================================================== void FormAnimationCoreFrames::mouseMoveEvent(QMouseEvent *event) { // Изменение выбранной фигуры int figureIndex = event->y() / frameHeight_; if (figureIndex < 0) figureIndex = 0; else if (figureIndex >= figures_.count()) figureIndex = figures_.count() - 1; const int id = figures_[figureIndex]->id(); emit selectingFigure(id); // Изменение текущего кадра int frameIndex = event->x() / frameWidth_; if (frameIndex != currentFrameIndex_) { if (frameIndex < 0) frameIndex = 0; else if (frameIndex >= frameCount()) frameIndex = frameCount() - 1; emit changingCurrentFrame(frameIndex); } }
TEST_F(BitmapImageTest, animationRepetitions) { loadImage("/LayoutTests/fast/images/resources/full2loop.gif"); int expectedRepetitionCount = 2; EXPECT_EQ(expectedRepetitionCount, repetitionCount()); // We actually loop once more than stored repetition count. for (int repeat = 0; repeat < expectedRepetitionCount + 1; ++repeat) { for (size_t i = 0; i < frameCount(); ++i) { EXPECT_FALSE(animationFinished()); advanceAnimation(); } } EXPECT_TRUE(animationFinished()); }
WinComPtr<IWICBitmap> WindowsImageData::bitmapAtFrame(int frame) { if (frame >= 0 && frame < frameCount()) { WinComPtr<IWICBitmap>& bitmap = m_bitmaps[frame]; if (bitmap) { return bitmap; } else { WinComPtr<IWICBitmapFrameDecode> frameDecode; HRESULT hr = m_bitmapDecoder->GetFrame(0, frameDecode.resetAndGetPointerAddress()); if (FAILED(hr)) { return nullptr; } WinComPtr<IWICFormatConverter> formatConverter = 0; hr = twApp()->imagingFactory()->getWICImagingFacotry()->CreateFormatConverter(formatConverter.resetAndGetPointerAddress()); if (FAILED(hr)) { return nullptr; } hr = formatConverter->Initialize( frameDecode, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.f, WICBitmapPaletteTypeMedianCut ); if (FAILED(hr)) { return nullptr; } hr = twApp()->imagingFactory()->getWICImagingFacotry()->CreateBitmapFromSource(formatConverter, WICBitmapCacheOnLoad, bitmap.resetAndGetPointerAddress()); if (FAILED(hr)) { return nullptr; } return bitmap; } } return nullptr; }
TwSize<int> WindowsImageData::size() { if (frameCount() > 0) { UINT width = 0; UINT height = 0; bitmapAtFrame(0)->GetSize(&width, &height); return TwSize<int>(width, height); } else { return TwSize<int>(); } }
void BitmapImage::notifyObserverAndTrimDecodedData() { // Notify our observer that the animation has advanced. imageObserver()->animationAdvanced(this); // For large animated images, go ahead and throw away frames as we go to // save footprint. int frameSize = m_size.width() * m_size.height() * 4; if (frameCount() * frameSize > cLargeAnimationCutoff) { // Destroy all of our frames and just redecode every time. We save the // current frame since we'll need it in draw() anyway. destroyDecodedData(false, true); } }
void BitmapImage::checkForSolidColor() { m_isSolidColor = false; m_checkedForSolidColor = true; if (frameCount() > 1) return; cairo_surface_t* frameSurface = frameAtIndex(0); if (!frameSurface) return; //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) // Check if this is a compressed surface. const void* pCompressedSurfaceUserData = cairo_surface_get_user_data (frameSurface, (cairo_user_data_key_t*) ImageCompressionGetUserDataKey()); #endif //-EAWebKitChange ASSERT(cairo_surface_get_type(frameSurface) == CAIRO_SURFACE_TYPE_IMAGE); int width = cairo_image_surface_get_width(frameSurface); int height = cairo_image_surface_get_height(frameSurface); if (width != 1 || height != 1) { //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) if (pCompressedSurfaceUserData) cairo_surface_destroy(frameSurface); #endif //-EAWebKitChange return; } unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(frameSurface)); m_solidColor = colorFromPremultipliedARGB(*pixelColor); m_isSolidColor = true; //+EAWebKitChange //5/30/2012 #if ENABLE(IMAGE_COMPRESSION) if (pCompressedSurfaceUserData) cairo_surface_destroy(frameSurface); #endif //-EAWebKitChange }
ImageFrame* GIFImageDecoder::frameBufferAtIndex(size_t index) { if (index >= frameCount()) return 0; #if ENABLE(IMPROVE_ANIMATED_GIF_PERFORMANCE) bool highEndGfx = TilesManager::instance()->highEndGfx(); if (!highEndGfx && m_needAutoReduceFrame == GIFLargeSize && m_reduceRate != 0) index = index - (index % m_reduceRate); #endif ImageFrame& frame = m_frameBufferCache[index]; if (frame.status() != ImageFrame::FrameComplete) decode(index + 1, GIFFullQuery); #if ENABLE(IMPROVE_ANIMATED_GIF_PERFORMANCE) if (!highEndGfx && index == 0 && m_needAutoReduceFrame == GIFKnown) { m_needAutoReduceFrame = GIFSmallSize; unsigned int imageSize = (frame.width() * frame.height() * 4 * frameCount()) >> 20; if (imageSize > MAX_GIF_OBJECT_SUPPORT_MEMORY && frameCount() >= MAX_GIF_OBJECT_SUPPORT_FRAME_COUNT) { m_needAutoReduceFrame = GIFLargeSize; m_reduceRate = 2; } }
ImageFrame* ImageDecoder::frameBufferAtIndex(size_t index) { if (index >= frameCount()) return 0; ImageFrame* frame = &m_frameBufferCache[index]; if (frame->status() != ImageFrame::FrameComplete) { PlatformInstrumentation::willDecodeImage(filenameExtension()); decode(index); PlatformInstrumentation::didDecodeImage(); } frame->notifyBitmapIfPixelsChanged(); return frame; }
void BitmapImage::checkForSolidColor() { m_isSolidColor = false; m_checkedForSolidColor = true; if (frameCount() > 1) return; QPixmap* framePixmap = frameAtIndex(0); if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1) return; m_isSolidColor = true; m_solidColor = QColor::fromRgba(framePixmap->toImage().pixel(0, 0)); }
void BitmapImage::checkForSolidColor() { if (m_checkedForSolidColor) return; m_checkedForSolidColor = true; m_isSolidColor = false; if (frameCount() != 1 ) return; const int width = currentFrameSize().width(); const int height = currentFrameSize().height(); if (width > 10 || height > 10) return; #if !USE(WXGC) // wxBitmap check: use PixelData class from wx/rawbmp.h wxBitmap* bitmap = frameAtIndex(0); typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> PixelData; PixelData data(*bitmap); if (!data) return; PixelData::Iterator p(data); wxColour lastColor(p.Red(), p.Green(), p.Blue(), p.Alpha()); for (int y = 0; y < height; ++y) { PixelData::Iterator rowStart = p; for (int x = 0; x < width; ++x, ++p) { wxColour color(p.Red(), p.Green(), p.Blue(), p.Alpha()); if (color != lastColor) return; else lastColor = color; } p = rowStart; p.OffsetY(data, 1); } // every pixel was the same color m_isSolidColor = true; m_solidColor = lastColor; #endif }
void BitmapImage::notifyObserverAndTrimDecodedData() { // Notify our observer that the animation has advanced. imageObserver()->animationAdvanced(this); // For large animated images, go ahead and throw away frames as we go to save // footprint. int frameSize = m_size.width() * m_size.height() * 4; if (frameCount() * frameSize > cLargeAnimationCutoff) { // Destroy all of our frames and just redecode every time. destroyDecodedData(); // Go ahead and decode the next frame. frameAtIndex(m_currentFrame); } }
int QgsLayoutTable::rowsVisible( int frameIndex, int firstRow, bool includeEmptyRows ) const { //get frame extent if ( frameIndex >= frameCount() ) { return 0; } QRectF frameExtent = frame( frameIndex )->extent(); bool includeHeader = false; if ( ( mHeaderMode == QgsLayoutTable::FirstFrame && frameIndex < 1 ) || ( mHeaderMode == QgsLayoutTable::AllFrames ) ) { includeHeader = true; } return rowsVisible( frameExtent.height(), firstRow, includeHeader, includeEmptyRows ); }
int recur(int x){ count++; get_rbp_2; get_rsp_2; printf("%rbp is %ld, using register local var it's %ld\n",get_rbp(),rbp); printf("%rsp is %ld, using register local var it's %ld\n",get_rsp(),rsp); printf("rbp difference is %ld\n",rbp_init-rbp); printf("rsp difference is %ld\n",rsp_init-rsp); printf("recursion depth is %ld\n",((rsp_init-rsp)/48)); printf("frame number (using rsp) %ld\n",frameCount()); printf("frame number (using rbp) %ld\n",(rbp_init-getFP().rbp)/48); if(x<0){ return -1; } else { return recur(recur(x+x)); } }
int QgsComposerTableV2::rowsVisible( const int frameIndex ) const { //get frame extent if ( frameIndex >= frameCount() ) { return 0; } QRectF frameExtent = frame( frameIndex )->extent(); bool includeHeader = false; if (( mHeaderMode == QgsComposerTableV2::FirstFrame && frameIndex < 1 ) || ( mHeaderMode == QgsComposerTableV2::AllFrames ) ) { includeHeader = true; } return rowsVisible( frameExtent.height(), includeHeader ); }
ImageFrame* WEBPImageDecoder::frameBufferAtIndex(size_t index) { if (index >= frameCount()) return 0; ImageFrame& frame = m_frameBufferCache[index]; if (frame.status() == ImageFrame::FrameComplete) return &frame; Vector<size_t> framesToDecode; size_t frameToDecode = index; do { framesToDecode.append(frameToDecode); frameToDecode = m_frameBufferCache[frameToDecode].requiredPreviousFrameIndex(); } while (frameToDecode != kNotFound && m_frameBufferCache[frameToDecode].status() != ImageFrame::FrameComplete); ASSERT(m_demux); for (size_t i = framesToDecode.size(); i > 0; --i) { size_t frameIndex = framesToDecode[i - 1]; if ((m_formatFlags & ANIMATION_FLAG) && !initFrameBuffer(frameIndex)) return 0; WebPIterator webpFrame; if (!WebPDemuxGetFrame(m_demux, frameIndex + 1, &webpFrame)) return 0; PlatformInstrumentation::willDecodeImage("WEBP"); decode(webpFrame.fragment.bytes, webpFrame.fragment.size, false, frameIndex); PlatformInstrumentation::didDecodeImage(); WebPDemuxReleaseIterator(&webpFrame); if (failed()) return 0; // We need more data to continue decoding. if (m_frameBufferCache[frameIndex].status() != ImageFrame::FrameComplete) break; } // It is also a fatal error if all data is received and we have decoded all // frames available but the file is truncated. if (index >= m_frameBufferCache.size() - 1 && isAllDataReceived() && m_demux && m_demuxState != WEBP_DEMUX_DONE) setFailed(); frame.notifyBitmapIfPixelsChanged(); return &frame; }