MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / paint

Method paint

src/main/java/fieldcef/browser/HTMLToTexture.kt:160–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 y0 = 0
159 x1 = w
160 y1 = h
161 } else {
162 for (y in r.y until r.y + r.height) {
163 buffer.limit(r.x * 4 + y * 4 * w + r.width * 4)
164 buffer.position(r.x * 4 + y * 4 * w)
165 sourceView.limit(r.x * 4 + y * 4 * w + r.width * 4)
166 sourceView.position(r.x * 4 + y * 4 * w)
167 sourceView.put(buffer)
168 }
169 // System.out.println("r= " + r);
170 x0 = Math.min(x0, r.x)
171 x1 = Math.max(x1, r.width + r.x)
172 y0 = Math.min(y0, r.y)
173 y1 = Math.max(y1, r.height + r.y)
174 }
175 }
176 sourceView.clear()
177 buffer.clear()
178 mod.incrementAndGet()
179 cb?.run()
180 }
181
182 protected fun run() {
183 val now = System.currentTimeMillis()
184 if (now - timeSinceLastLoad > 2000 && pendingRequests.size > 0) {
185 requestDone = true
186 checkAndRunRequests()
187 }
188 }
189
190 companion object {
191 fun toTextureWhenReady(b: Future<ByteBuffer?>, m: Texture) {
192 m.attach(-1, Perform {
193 if (b.isDone) {
194 try {
195 // the buffer is done, but perhaps nobody has painted into it yet; which is clearly not what we want done to be
196 m.upload(b.get(), false)
197 } catch (e: InterruptedException) {
198 e.printStackTrace()
199 } catch (e: ExecutionException) {
200 e.printStackTrace()
201 }
202 false
203 } else {
204 true
205 }
206 })
207 }
208 }
209
210 init {
211 a = Ports.nextAvailable(9080)
212 b = Ports.nextAvailable(a + 1)
213 try {
214 s = Server(a, b)
215 } catch (e: IOException) {
216 e.printStackTrace()
217 }

Callers

nothing calls this directly

Calls 9

replaceMethod · 0.80
positionMethod · 0.65
printlnMethod · 0.45
clearMethod · 0.45
putMethod · 0.45
limitMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected