bool cache<P>::removeOldest(const value_type & v) { bool remove(Lru::removeOldest(v) || (sizeBytes() >= capacityBytes())); if (remove) { _sizeBytes -= calcSize(v.first, v.second._value); } return remove; }
ShGcInt::ValueType ShGcInt::getValue() { mRt.processesQueue(); auto bv = mFutr.get(); ValueType v= 0; memcpy(&v, bv.data(), bv.sizeBytes()); return v; }
RWImageData(uint2 size, Format format) { this->size = size; this->format = format; setDefaultSizes(); ownedData = DynamicBuffer<uint8_t>(sizeBytes()); mutableData = ownedData; data = mutableData; }
bool SDLSurface::renderToSurface(RGBVideoSample& videoSample) { if (!videoSample) { return false; } if (!isInitialized()) { return false; } #ifdef DEBUG std::cout << "SDLSurface::renderToSurface" << std::endl; #endif SDLSurfaceLock surfaceLock(m_pSurface); if (!surfaceLock) { return false; } RGBVideoFormat videoFormat(videoSample.sampleFormat()); if (videoFormat.sizePixels() != sizePixels()) { return false; } if (videoFormat.bitsPerPixel() != bitsPerPixel()) { return false; } if (videoFormat.sizeRowBytes() != sizeRowBytes()) { return false; } if (videoFormat.sizeBytes() != sizeBytes()) { return false; } if (videoFormat.rgbFormat() != rgbFormat()) { return false; } RGBVideoFrameSharedPtr pVideoFrame(videoSample.sampleData()); ImageViewType imageView(pVideoFrame->imageView()); switch (rgbFormat()) { case RGB888: renderImageToSurface<rgb8_view_t, rgb8_ptr_t>(imageView); break; case RGBA8888: renderImageToSurface<rgba8_view_t, rgba8_ptr_t>(imageView); break; case BGR888: renderImageToSurface<bgr8_view_t, bgr8_ptr_t>(imageView); break; case ABGR8888: renderImageToSurface<abgr8_view_t, abgr8_ptr_t>(imageView); break; default: return false; } return true; }
bool SDLSurface::hasData() const { typedef boost::uint8_t Byte; typedef Byte* BytePtr; if (!isInitialized()) { return false; } SizeType countBytes = sizeBytes(); BytePtr byteArray = reinterpret_cast<BytePtr>(m_pSurface->pixels); for (SizeType i = 0; i < countBytes; ++i) { Byte byteValue = byteArray[i]; if (byteValue) { return true; } } return false; }
// if sizes==0, then keep current shape int Data::realloc(Data::Type t, const int * sizes, int n){ Data old(*this); // REV0 if(sizes){ // new shape requested clear(); shape(sizes, n); } else{ // just changing type, leave shape unchanged // Data old(*this); // REV0 clear(); shape(old.mSizes, old.maxDim()); } if(size()){ mType = t; mStride= 1; switch(type()){ case Data::BOOL: mData = pointer(new bool[size()]); break; case Data::INT: mData = pointer(new int[size()]); break; case Data::FLOAT: mData = pointer(new float[size()]); break; case Data::DOUBLE: mData = pointer(new double[size()]); break; case Data::STRING: mData = pointer(new std::string[size()]); break; default: goto end; } acquire(mData); offset(0); // if(hasData() && isNumerical()) assignAll(0); // REV0 if(hasData() && isNumerical()){ if(old.hasData()){ assign(old); // copy over as many old elements as possible if(size() > old.size()) slice(old.size()).assignAll(0); } else{ assignAll(0); } } } end: return sizeBytes() - old.sizeBytes(); }
template<class T> inline size_t pcl::gpu::DeviceArray<T>::size() const { return sizeBytes() / elem_size; }
int64_t LogByteSizeMergePolicy::size(SegmentInfoPtr info) { return sizeBytes(info); }