Unverified Commit 60c332f3 authored by Ivan Matkov's avatar Ivan Matkov Committed by GitHub

Use proper `bbhFactory` in `onMakePictureSnapshot` (#1075)

Fixes [CMP-8701](https://youtrack.jetbrains.com/issue/CMP-8701)

Addition to https://github.com/JetBrains/skia/pull/11
parent 0e9f76d4
...@@ -259,8 +259,7 @@ SkRect RenderNode::onGetBounds() { ...@@ -259,8 +259,7 @@ SkRect RenderNode::onGetBounds() {
} }
sk_sp<SkPicture> RenderNode::onMakePictureSnapshot() { sk_sp<SkPicture> RenderNode::onMakePictureSnapshot() {
const SkRect bounds = this->getBounds(); SkCanvas* canvas = this->beginRecording();
SkCanvas* canvas = this->recorder.beginRecording(bounds);
UnrollDrawableCanvas unrollCanvas(canvas); UnrollDrawableCanvas unrollCanvas(canvas);
this->draw(&unrollCanvas); this->draw(&unrollCanvas);
return this->recorder.finishRecordingAsPicture(); return this->recorder.finishRecordingAsPicture();
......
...@@ -9,7 +9,7 @@ import kotlin.test.assertTrue ...@@ -9,7 +9,7 @@ import kotlin.test.assertTrue
class RenderNodeTest { class RenderNodeTest {
@Test @Test
fun verifyInterop() { fun verifyInterop() {
val surface = Surface.Companion.makeRasterN32Premul(16, 16) val surface = Surface.makeRasterN32Premul(16, 16)
val context = RenderNodeContext() val context = RenderNodeContext()
val node = RenderNode(context) val node = RenderNode(context)
...@@ -78,4 +78,27 @@ class RenderNodeTest { ...@@ -78,4 +78,27 @@ class RenderNodeTest {
node.close() node.close()
context.close() context.close()
} }
}
\ No newline at end of file @Test
fun pictureCullRect() {
val context = RenderNodeContext(measureDrawBounds = true)
val node = RenderNode(context)
node.bounds = Rect(0f, 0f, 100f, 100f)
val recordCanvas = node.beginRecording()
recordCanvas.drawRect(Rect(20f,20f,40f,40f), Paint())
node.endRecording()
val pictureRecorder = PictureRecorder()
val bbhFactory = RTreeFactory()
val pictureCanvas = pictureRecorder.beginRecording(Rect(0f, 0f, 100f, 100f), bbhFactory)
node.drawInto(pictureCanvas)
val picture = pictureRecorder.finishRecordingAsPicture()
assertEquals(Rect(20f, 20f, 40f, 40f), picture.cullRect)
picture.close()
node.close()
context.close()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment