MCPcopy Create free account
hub / github.com/Tencent/tgfx / addAtlasCellCodecTask

Method addAtlasCellCodecTask

src/gpu/DrawingManager.cpp:139–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139void DrawingManager::addAtlasCellCodecTask(const std::shared_ptr<TextureProxy>& textureProxy,
140 const Point& atlasOffset,
141 std::shared_ptr<ImageCodec> codec) {
142 if (textureProxy == nullptr || codec == nullptr) {
143 return;
144 }
145 auto padding = Plot::CellPadding;
146 void* dstPixels = nullptr;
147 auto dstWidth = codec->width() + 2 * padding;
148 auto dstHeight = codec->height() + 2 * padding;
149 ImageInfo dstInfo = {};
150 auto hardwareBuffer = textureProxy->getHardwareBuffer();
151 if (hardwareBuffer != nullptr) {
152 auto hardwareInfo = HardwareBufferGetInfo(hardwareBuffer);
153 dstInfo = hardwareInfo.makeIntersect(0, 0, dstWidth, dstHeight);
154 void* pixels = nullptr;
155 if (auto iter = atlasHardwareBuffers.find(textureProxy.get());
156 iter == atlasHardwareBuffers.end()) {
157 pixels = HardwareBufferLock(hardwareBuffer);
158 atlasHardwareBuffers.emplace(textureProxy.get(), std::make_pair(hardwareBuffer, pixels));
159 } else {
160 pixels = iter->second.second;
161 }
162 auto offsetX = static_cast<int>(atlasOffset.x) - padding;
163 auto offsetY = static_cast<int>(atlasOffset.y) - padding;
164 dstPixels = hardwareInfo.computeOffset(pixels, offsetX, offsetY);
165 } else {
166 dstInfo = GetAtlasImageInfo(dstWidth, dstHeight, codec->isAlphaOnly());
167 auto length = dstInfo.byteSize();
168 dstPixels = drawingBuffer->allocate(length);
169 if (dstPixels == nullptr) {
170 return;
171 }
172 auto data = Data::MakeWithoutCopy(dstPixels, length);
173 auto uploadOffset = atlasOffset;
174 auto floatPadding = static_cast<float>(padding);
175 uploadOffset.offset(-floatPadding, -floatPadding);
176 atlasCellDatas[textureProxy].emplace_back(std::move(data), dstInfo, uploadOffset);
177 }
178 auto task = std::make_shared<AtlasCellDecodeTask>(std::move(codec), dstPixels, dstInfo, padding);
179 atlasCellCodecTasks.emplace_back(std::move(task));
180}
181
182void DrawingManager::addSemaphoreWaitTask(std::shared_ptr<Semaphore> semaphore) {
183 if (semaphore == nullptr) {

Callers 2

Calls 15

GetAtlasImageInfoFunction · 0.85
makeIntersectMethod · 0.80
computeOffsetMethod · 0.80
allocateMethod · 0.80
HardwareBufferGetInfoFunction · 0.50
HardwareBufferLockFunction · 0.50
widthMethod · 0.45
heightMethod · 0.45
getHardwareBufferMethod · 0.45
findMethod · 0.45
getMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected