Ejemplo n.º 1
0
void sweepNativeData() {
  for (auto node = s_sweep; node;) {
    auto obj = reinterpret_cast<ObjectData*>(node + 1);
    auto ndi = obj->getVMClass()->getNativeDataInfo();
    assert(ndi->sweep);
    ndi->sweep(obj);
    node = node->next;
    assert(invalidateNativeData(obj, ndi));
  }
  s_sweep = nullptr;
}
Ejemplo n.º 2
0
void sweepNativeData(std::vector<NativeNode*>& natives) {
  while (!natives.empty()) {
    assert(natives.back()->sweep_index == natives.size() - 1);
    auto node = natives.back();
    natives.pop_back();
    auto obj = Native::obj(node);
    auto ndi = obj->getVMClass()->getNativeDataInfo();
    assert(ndi->sweep);
    assert(node->obj_offset == ndsize(ndi));
    ndi->sweep(obj);
    assert(invalidateNativeData(obj, ndi));
  }
}
Ejemplo n.º 3
0
void Image::destroyDecodedData(bool incremental)
{
    // Destroy the cached images and release them.
    if (m_frames.size()) {
        int sizeChange = 0;
        int frameSize = m_size.width() * m_size.height() * 4;
        for (unsigned i = incremental ? m_frames.size() - 1 : 0; i < m_frames.size(); i++) {
            if (m_frames[i].m_frame) {
                sizeChange -= frameSize;
                m_frames[i].clear();
                if (!incremental)
                    m_source.destroyFrameAtIndex(i);
            }
        }
        
        // We just always invalidate our platform data, even in the incremental case.
        // This could be better, but it's not a big deal.
        m_isSolidColor = false;
        invalidateNativeData();
        
        if (sizeChange) {
            if (imageObserver())
                imageObserver()->decodedSizeChanging(this, sizeChange);
            m_decodedSize += sizeChange;
            if (imageObserver())
                imageObserver()->decodedSizeChanged(this, sizeChange);
        }
        
        if (!incremental) {
            // Reset the image source, since Image I/O has an underlying cache that it uses
            // while animating that it seems to never clear.
            m_source.clear();
            setData(true);
        }        
    }
}