Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-05-06 Thread 'Vladimir Levin' via blink-dev
Hey Steven,

The path to convert information necessary for rendering into SkPictures may
or may not exist in the Chromium codebase, but it's certainly not actively
maintained or developed. Ultimately all information is available, but it
may come from several different sources.

For images, for example, it's likely that the Skia information stores them
in an encoded format backed by one of the decoders in Blink. The cc
codebase has classes that extracts the encoded information and schedules
decoding and upload which is then rasterized and presented as necessary. It
isn't necessarily trivial to convert this whole process to a few Skia
commands, and largely depends on what you're looking to accomplish.

Here's a thread from skia-discuss@ roughly talking about the same thing:
https://groups.google.com/g/skia-discuss/c/hd1ZCRkM4OA. As Brian mentions
there, SkPictures are an important primitive (as are other Skia commands)
but it's not the only thing. Chromium uses display lists and paint ops to
draw its contents. You can probably look at the serialization code as the
closest thing that does all the right serialization (this is used in Out of
Process Rasterization):
https://source.chromium.org/chromium/chromium/src/+/main:cc/paint/paint_op_buffer_serializer.h;l=21;drc=e09826065bb5964f247be565890dcabda54ac9e3.
As I mentioned previously in a different thread, this won't help you with
images. Those need to be either decoded and serialized or serialized in
encoded form and dealt with on the client side.

As Ken also mentioned, graphics-dev (and also skia-discuss) may be better
forums for this type of discussion

Thanks,
Vlad

On Mon, May 6, 2024 at 3:32 AM Steven Whelan 
wrote:

> Hi,
> Also found out that through paint_op_helper's tostring method
> 
> , all the PaintOps related information can be printed. It includes all the
> information- coordinates, paint info etc.
> Wondering, can these be converted directly into SKIA commands to render
> the page?
> Please help me finalize the correct approach.
>
>
> On Sun, May 5, 2024 at 3:49 AM Ken Russell  wrote:
>
>> I'm not sure exactly how SkPicture recording works - please join
>> https://groups.google.com/a/chromium.org/g/graphics-dev and email
>> graphics-...@chromium.org .
>>
>> -Ken
>>
>>
>>
>> On Sat, May 4, 2024 at 6:21 AM Steven Whelan 
>> wrote:
>>
>>> Hi I am able to write the serialized SKData (captured from Serialize
>>> method of  paint_op_buffer_serializer
>>> 
>>>  as
>>> shown in the first mail) to a file and was also able to use this file for
>>> playback on canvas.
>>> However, it only played back the text. How do I ensure that images also
>>> get captured in my SKPicture recording? Do I have to have multiple
>>> SKPictureRecording at multiple places?
>>> Goal : To record everything being written on a canvas while loading  a
>>> page so that it can be played back on another browser.
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>> On Thursday, May 2, 2024 at 5:34:48 AM UTC+5:30 k...@chromium.org wrote:
>>>
 Yes - you can confirm this yourself - but we strongly recommend against
 disabling the renderer sandbox.


 On Tue, Apr 30, 2024 at 10:46 PM Steven Whelan 
 wrote:

> Yes, trying to do this in renderer process. Would it work if I run
> Chromium with --nosandbox flag.
>
> On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:
>
>> Are you trying to do this within Chrome's renderer or GPU processes?
>> If so, the sandbox will prevent you from touching the local disk. You 
>> would
>> need to extend the sandbox policies to allow writing to a directory on 
>> disk
>> - some place that will not collide with other programs, so that if a bad
>> actor causes data to be written to that directory, no harm will be 
>> caused.
>> See
>> https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
>> for the macOS sandbox policies.
>>
>> -Ken
>>
>>
>>
>> On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
>> wrote:
>>
>>> Hi
>>> I have modified the Serialize
>>> 
>>>  method
>>> to Record all PaintOp as SKPicture.
>>> I want to replay this SKPicture on a remote browser. So, I am trying
>>> to save this SKPicture to a file, but I am not able to do so, since
>>> file.isOpen gives false.
>>> Please help here
>>>
>>> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,

Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-05-06 Thread Steven Whelan
Hi,
Also found out that through paint_op_helper's tostring method

, all the PaintOps related information can be printed. It includes all the
information- coordinates, paint info etc.
Wondering, can these be converted directly into SKIA commands to render the
page?
Please help me finalize the correct approach.


On Sun, May 5, 2024 at 3:49 AM Ken Russell  wrote:

> I'm not sure exactly how SkPicture recording works - please join
> https://groups.google.com/a/chromium.org/g/graphics-dev and email
> graphics-...@chromium.org .
>
> -Ken
>
>
>
> On Sat, May 4, 2024 at 6:21 AM Steven Whelan 
> wrote:
>
>> Hi I am able to write the serialized SKData (captured from Serialize
>> method of  paint_op_buffer_serializer
>> 
>>  as
>> shown in the first mail) to a file and was also able to use this file for
>> playback on canvas.
>> However, it only played back the text. How do I ensure that images also
>> get captured in my SKPicture recording? Do I have to have multiple
>> SKPictureRecording at multiple places?
>> Goal : To record everything being written on a canvas while loading  a
>> page so that it can be played back on another browser.
>>
>> Thanks
>>
>>
>>
>>
>> On Thursday, May 2, 2024 at 5:34:48 AM UTC+5:30 k...@chromium.org wrote:
>>
>>> Yes - you can confirm this yourself - but we strongly recommend against
>>> disabling the renderer sandbox.
>>>
>>>
>>> On Tue, Apr 30, 2024 at 10:46 PM Steven Whelan 
>>> wrote:
>>>
 Yes, trying to do this in renderer process. Would it work if I run
 Chromium with --nosandbox flag.

 On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:

> Are you trying to do this within Chrome's renderer or GPU processes?
> If so, the sandbox will prevent you from touching the local disk. You 
> would
> need to extend the sandbox policies to allow writing to a directory on 
> disk
> - some place that will not collide with other programs, so that if a bad
> actor causes data to be written to that directory, no harm will be caused.
> See
> https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
> for the macOS sandbox policies.
>
> -Ken
>
>
>
> On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
> wrote:
>
>> Hi
>> I have modified the Serialize
>> 
>>  method
>> to Record all PaintOp as SKPicture.
>> I want to replay this SKPicture on a remote browser. So, I am trying
>> to save this SKPicture to a file, but I am not able to do so, since
>> file.isOpen gives false.
>> Please help here
>>
>> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
>> const std::vector*
>> offsets,
>> const Preamble& preamble) {
>>   DCHECK_EQ(serialized_op_count_, 0u);
>>
>>   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
>>   // These PlaybackParams use the initial (identity) canvas matrix,
>> as they are
>>   // only used for serializing the preamble and the initial save /
>> final restore
>>   // SerializeBuffer will create its own PlaybackParams based on the
>>
>>  * SkPictureRecorder recorder;*
>>  * SkCanvas* recordingCanvas =
>> recorder.beginRecording(canvas->getLocalClipBounds()); *
>>   // post-preamble canvas.
>>   PlaybackParams params = MakeParams(canvas.get());
>>   int save_count = canvas->getSaveCount();
>>   Save(canvas.get(), params);
>>   SerializePreamble(canvas.get(), preamble, params);
>>   SerializeBuffer(canvas.get(), buffer, offsets);
>>   *SerializeBuffer(recordingCanvas, buffer, offsets);*
>>
>>
>> *sk_sp picture = recorder.finishRecordingAsPicture();
>> SkSerialProcs sProcs;  sk_sp readableData =
>> picture->serialize(&sProcs);*
>>   // Assuming the byte array is stored in the 'data' field of the
>> SkData object
>>   const void* data = readableData->data();
>>   size_t size = readableData->size();
>>
>> * *
>>   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
>>   sk_sp copy =
>>   SkPicture::MakeFromData(receievedData->data(),
>> receievedData->size());
>>   copy->playback(recordingCanvas);*/
>>   RestoreToCount(canvas.get(), save_count, params);
>> }
>>
>> --
>> You received this message because you are subscribed to the

Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-05-04 Thread Ken Russell
I'm not sure exactly how SkPicture recording works - please join
https://groups.google.com/a/chromium.org/g/graphics-dev and email
graphics-...@chromium.org .

-Ken



On Sat, May 4, 2024 at 6:21 AM Steven Whelan 
wrote:

> Hi I am able to write the serialized SKData (captured from Serialize
> method of  paint_op_buffer_serializer
> 
>  as
> shown in the first mail) to a file and was also able to use this file for
> playback on canvas.
> However, it only played back the text. How do I ensure that images also
> get captured in my SKPicture recording? Do I have to have multiple
> SKPictureRecording at multiple places?
> Goal : To record everything being written on a canvas while loading  a
> page so that it can be played back on another browser.
>
> Thanks
>
>
>
>
> On Thursday, May 2, 2024 at 5:34:48 AM UTC+5:30 k...@chromium.org wrote:
>
>> Yes - you can confirm this yourself - but we strongly recommend against
>> disabling the renderer sandbox.
>>
>>
>> On Tue, Apr 30, 2024 at 10:46 PM Steven Whelan 
>> wrote:
>>
>>> Yes, trying to do this in renderer process. Would it work if I run
>>> Chromium with --nosandbox flag.
>>>
>>> On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:
>>>
 Are you trying to do this within Chrome's renderer or GPU processes? If
 so, the sandbox will prevent you from touching the local disk. You would
 need to extend the sandbox policies to allow writing to a directory on disk
 - some place that will not collide with other programs, so that if a bad
 actor causes data to be written to that directory, no harm will be caused.
 See
 https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
 for the macOS sandbox policies.

 -Ken



 On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
 wrote:

> Hi
> I have modified the Serialize
> 
>  method
> to Record all PaintOp as SKPicture.
> I want to replay this SKPicture on a remote browser. So, I am trying
> to save this SKPicture to a file, but I am not able to do so, since
> file.isOpen gives false.
> Please help here
>
> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
> const std::vector*
> offsets,
> const Preamble& preamble) {
>   DCHECK_EQ(serialized_op_count_, 0u);
>
>   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
>   // These PlaybackParams use the initial (identity) canvas matrix, as
> they are
>   // only used for serializing the preamble and the initial save /
> final restore
>   // SerializeBuffer will create its own PlaybackParams based on the
>
>  * SkPictureRecorder recorder;*
>  * SkCanvas* recordingCanvas =
> recorder.beginRecording(canvas->getLocalClipBounds()); *
>   // post-preamble canvas.
>   PlaybackParams params = MakeParams(canvas.get());
>   int save_count = canvas->getSaveCount();
>   Save(canvas.get(), params);
>   SerializePreamble(canvas.get(), preamble, params);
>   SerializeBuffer(canvas.get(), buffer, offsets);
>   *SerializeBuffer(recordingCanvas, buffer, offsets);*
>
>
> *sk_sp picture = recorder.finishRecordingAsPicture();
> SkSerialProcs sProcs;  sk_sp readableData =
> picture->serialize(&sProcs);*
>   // Assuming the byte array is stored in the 'data' field of the
> SkData object
>   const void* data = readableData->data();
>   size_t size = readableData->size();
>
> * *
>   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
>   sk_sp copy =
>   SkPicture::MakeFromData(receievedData->data(),
> receievedData->size());
>   copy->playback(recordingCanvas);*/
>   RestoreToCount(canvas.get(), save_count, params);
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blink-dev+...@chromium.org.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org
> 
> .
>


-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+

Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-05-04 Thread Steven Whelan
Hi I am able to write the serialized SKData (captured from Serialize method 
of  paint_op_buffer_serializer 

 as 
shown in the first mail) to a file and was also able to use this file for 
playback on canvas.
However, it only played back the text. How do I ensure that images also get 
captured in my SKPicture recording? Do I have to have multiple 
SKPictureRecording at multiple places?
Goal : To record everything being written on a canvas while loading  a page 
so that it can be played back on another browser.

Thanks




On Thursday, May 2, 2024 at 5:34:48 AM UTC+5:30 k...@chromium.org wrote:

> Yes - you can confirm this yourself - but we strongly recommend against 
> disabling the renderer sandbox.
>
>
> On Tue, Apr 30, 2024 at 10:46 PM Steven Whelan  
> wrote:
>
>> Yes, trying to do this in renderer process. Would it work if I run 
>> Chromium with --nosandbox flag.
>>
>> On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:
>>
>>> Are you trying to do this within Chrome's renderer or GPU processes? If 
>>> so, the sandbox will prevent you from touching the local disk. You would 
>>> need to extend the sandbox policies to allow writing to a directory on disk 
>>> - some place that will not collide with other programs, so that if a bad 
>>> actor causes data to be written to that directory, no harm will be caused. 
>>> See 
>>> https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
>>>  
>>> for the macOS sandbox policies.
>>>
>>> -Ken
>>>
>>>
>>>
>>> On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan  
>>> wrote:
>>>
 Hi 
 I have modified the Serialize 
 
  method 
 to Record all PaintOp as SKPicture. 
 I want to replay this SKPicture on a remote browser. So, I am trying to 
 save this SKPicture to a file, but I am not able to do so, since 
 file.isOpen gives false.
 Please help here

 void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
 const std::vector* 
 offsets,
 const Preamble& preamble) {
   DCHECK_EQ(serialized_op_count_, 0u);

   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
   // These PlaybackParams use the initial (identity) canvas matrix, as 
 they are
   // only used for serializing the preamble and the initial save / 
 final restore
   // SerializeBuffer will create its own PlaybackParams based on the
 
  * SkPictureRecorder recorder;*
  * SkCanvas* recordingCanvas = 
 recorder.beginRecording(canvas->getLocalClipBounds()); *
   // post-preamble canvas.
   PlaybackParams params = MakeParams(canvas.get());
   int save_count = canvas->getSaveCount();
   Save(canvas.get(), params);
   SerializePreamble(canvas.get(), preamble, params);
   SerializeBuffer(canvas.get(), buffer, offsets);
   *SerializeBuffer(recordingCanvas, buffer, offsets);*
   

 *sk_sp picture = recorder.finishRecordingAsPicture();  
 SkSerialProcs sProcs;  sk_sp readableData = 
 picture->serialize(&sProcs);*
   // Assuming the byte array is stored in the 'data' field of the 
 SkData object
   const void* data = readableData->data();
   size_t size = readableData->size();

 * *
   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
   sk_sp copy =
   SkPicture::MakeFromData(receievedData->data(), 
 receievedData->size());
   copy->playback(recordingCanvas);*/
   RestoreToCount(canvas.get(), save_count, params);
 }

 -- 
 You received this message because you are subscribed to the Google 
 Groups "blink-dev" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to blink-dev+...@chromium.org.
 To view this discussion on the web visit 
 https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org
  
 
 .

>>>

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/73a49e04-60de-4315-88e9-45315c2887c6n%40chromium.org.


Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-05-01 Thread Ken Russell
Yes - you can confirm this yourself - but we strongly recommend against
disabling the renderer sandbox.


On Tue, Apr 30, 2024 at 10:46 PM Steven Whelan 
wrote:

> Yes, trying to do this in renderer process. Would it work if I run
> Chromium with --nosandbox flag.
>
> On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:
>
>> Are you trying to do this within Chrome's renderer or GPU processes? If
>> so, the sandbox will prevent you from touching the local disk. You would
>> need to extend the sandbox policies to allow writing to a directory on disk
>> - some place that will not collide with other programs, so that if a bad
>> actor causes data to be written to that directory, no harm will be caused.
>> See
>> https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
>> for the macOS sandbox policies.
>>
>> -Ken
>>
>>
>>
>> On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
>> wrote:
>>
>>> Hi
>>> I have modified the Serialize
>>> 
>>>  method
>>> to Record all PaintOp as SKPicture.
>>> I want to replay this SKPicture on a remote browser. So, I am trying to
>>> save this SKPicture to a file, but I am not able to do so, since
>>> file.isOpen gives false.
>>> Please help here
>>>
>>> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
>>> const std::vector*
>>> offsets,
>>> const Preamble& preamble) {
>>>   DCHECK_EQ(serialized_op_count_, 0u);
>>>
>>>   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
>>>   // These PlaybackParams use the initial (identity) canvas matrix, as
>>> they are
>>>   // only used for serializing the preamble and the initial save / final
>>> restore
>>>   // SerializeBuffer will create its own PlaybackParams based on the
>>>
>>>  * SkPictureRecorder recorder;*
>>>  * SkCanvas* recordingCanvas =
>>> recorder.beginRecording(canvas->getLocalClipBounds()); *
>>>   // post-preamble canvas.
>>>   PlaybackParams params = MakeParams(canvas.get());
>>>   int save_count = canvas->getSaveCount();
>>>   Save(canvas.get(), params);
>>>   SerializePreamble(canvas.get(), preamble, params);
>>>   SerializeBuffer(canvas.get(), buffer, offsets);
>>>   *SerializeBuffer(recordingCanvas, buffer, offsets);*
>>>
>>>
>>> *sk_sp picture = recorder.finishRecordingAsPicture();
>>> SkSerialProcs sProcs;  sk_sp readableData =
>>> picture->serialize(&sProcs);*
>>>   // Assuming the byte array is stored in the 'data' field of the SkData
>>> object
>>>   const void* data = readableData->data();
>>>   size_t size = readableData->size();
>>>
>>> * *
>>>   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
>>>   sk_sp copy =
>>>   SkPicture::MakeFromData(receievedData->data(),
>>> receievedData->size());
>>>   copy->playback(recordingCanvas);*/
>>>   RestoreToCount(canvas.get(), save_count, params);
>>> }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "blink-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to blink-dev+unsubscr...@chromium.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAMYvS2eqsWPK09kuN3%3DCU3xj1ON3gO-tK4DZaXFg9giJ5Q6keg%40mail.gmail.com.


Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-04-30 Thread Steven Whelan
Yes, trying to do this in renderer process. Would it work if I run Chromium
with --nosandbox flag.

On Tue, Apr 30, 2024, 21:58 Ken Russell  wrote:

> Are you trying to do this within Chrome's renderer or GPU processes? If
> so, the sandbox will prevent you from touching the local disk. You would
> need to extend the sandbox policies to allow writing to a directory on disk
> - some place that will not collide with other programs, so that if a bad
> actor causes data to be written to that directory, no harm will be caused.
> See
> https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
> for the macOS sandbox policies.
>
> -Ken
>
>
>
> On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
> wrote:
>
>> Hi
>> I have modified the Serialize
>> 
>>  method
>> to Record all PaintOp as SKPicture.
>> I want to replay this SKPicture on a remote browser. So, I am trying to
>> save this SKPicture to a file, but I am not able to do so, since
>> file.isOpen gives false.
>> Please help here
>>
>> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
>> const std::vector*
>> offsets,
>> const Preamble& preamble) {
>>   DCHECK_EQ(serialized_op_count_, 0u);
>>
>>   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
>>   // These PlaybackParams use the initial (identity) canvas matrix, as
>> they are
>>   // only used for serializing the preamble and the initial save / final
>> restore
>>   // SerializeBuffer will create its own PlaybackParams based on the
>>
>>  * SkPictureRecorder recorder;*
>>  * SkCanvas* recordingCanvas =
>> recorder.beginRecording(canvas->getLocalClipBounds()); *
>>   // post-preamble canvas.
>>   PlaybackParams params = MakeParams(canvas.get());
>>   int save_count = canvas->getSaveCount();
>>   Save(canvas.get(), params);
>>   SerializePreamble(canvas.get(), preamble, params);
>>   SerializeBuffer(canvas.get(), buffer, offsets);
>>   *SerializeBuffer(recordingCanvas, buffer, offsets);*
>>
>>
>> *sk_sp picture = recorder.finishRecordingAsPicture();
>> SkSerialProcs sProcs;  sk_sp readableData =
>> picture->serialize(&sProcs);*
>>   // Assuming the byte array is stored in the 'data' field of the SkData
>> object
>>   const void* data = readableData->data();
>>   size_t size = readableData->size();
>>
>> * *
>>   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
>>   sk_sp copy =
>>   SkPicture::MakeFromData(receievedData->data(),
>> receievedData->size());
>>   copy->playback(recordingCanvas);*/
>>   RestoreToCount(canvas.get(), save_count, params);
>> }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "blink-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to blink-dev+unsubscr...@chromium.org.
>> To view this discussion on the web visit
>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAO%2BCLgCWVV5q%2BnPcTXW7v_x9_zperfwifFThPfLpUba98mRjpQ%40mail.gmail.com.


Re: [blink-dev] Unable to write Serialized SkPicture into a File

2024-04-30 Thread Ken Russell
Are you trying to do this within Chrome's renderer or GPU processes? If so,
the sandbox will prevent you from touching the local disk. You would need
to extend the sandbox policies to allow writing to a directory on disk -
some place that will not collide with other programs, so that if a bad
actor causes data to be written to that directory, no harm will be caused.
See
https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/
for the macOS sandbox policies.

-Ken



On Tue, Apr 30, 2024 at 8:59 AM Steven Whelan 
wrote:

> Hi
> I have modified the Serialize
> 
>  method
> to Record all PaintOp as SKPicture.
> I want to replay this SKPicture on a remote browser. So, I am trying to
> save this SKPicture to a file, but I am not able to do so, since
> file.isOpen gives false.
> Please help here
>
> void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
> const std::vector* offsets,
> const Preamble& preamble) {
>   DCHECK_EQ(serialized_op_count_, 0u);
>
>   std::unique_ptr canvas = MakeAnalysisCanvas(options_);
>   // These PlaybackParams use the initial (identity) canvas matrix, as
> they are
>   // only used for serializing the preamble and the initial save / final
> restore
>   // SerializeBuffer will create its own PlaybackParams based on the
>
>  * SkPictureRecorder recorder;*
>  * SkCanvas* recordingCanvas =
> recorder.beginRecording(canvas->getLocalClipBounds()); *
>   // post-preamble canvas.
>   PlaybackParams params = MakeParams(canvas.get());
>   int save_count = canvas->getSaveCount();
>   Save(canvas.get(), params);
>   SerializePreamble(canvas.get(), preamble, params);
>   SerializeBuffer(canvas.get(), buffer, offsets);
>   *SerializeBuffer(recordingCanvas, buffer, offsets);*
>
>
> *sk_sp picture = recorder.finishRecordingAsPicture();
> SkSerialProcs sProcs;  sk_sp readableData =
> picture->serialize(&sProcs);*
>   // Assuming the byte array is stored in the 'data' field of the SkData
> object
>   const void* data = readableData->data();
>   size_t size = readableData->size();
>
> * *
>   /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
>   sk_sp copy =
>   SkPicture::MakeFromData(receievedData->data(),
> receievedData->size());
>   copy->playback(recordingCanvas);*/
>   RestoreToCount(canvas.get(), save_count, params);
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to blink-dev+unsubscr...@chromium.org.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAMYvS2d3HqhLAkNg3AFKTJFPMVPaju_rmuq0dza8i7YisbEyMA%40mail.gmail.com.


[blink-dev] Unable to write Serialized SkPicture into a File

2024-04-30 Thread Steven Whelan
Hi 
I have modified the Serialize 

 method 
to Record all PaintOp as SKPicture. 
I want to replay this SKPicture on a remote browser. So, I am trying to 
save this SKPicture to a file, but I am not able to do so, since 
file.isOpen gives false.
Please help here

void PaintOpBufferSerializer::Serialize(const PaintOpBuffer& buffer,
const std::vector* offsets,
const Preamble& preamble) {
  DCHECK_EQ(serialized_op_count_, 0u);

  std::unique_ptr canvas = MakeAnalysisCanvas(options_);
  // These PlaybackParams use the initial (identity) canvas matrix, as they 
are
  // only used for serializing the preamble and the initial save / final 
restore
  // SerializeBuffer will create its own PlaybackParams based on the

 * SkPictureRecorder recorder;*
 * SkCanvas* recordingCanvas = 
recorder.beginRecording(canvas->getLocalClipBounds()); *
  // post-preamble canvas.
  PlaybackParams params = MakeParams(canvas.get());
  int save_count = canvas->getSaveCount();
  Save(canvas.get(), params);
  SerializePreamble(canvas.get(), preamble, params);
  SerializeBuffer(canvas.get(), buffer, offsets);
  *SerializeBuffer(recordingCanvas, buffer, offsets);*
  

*sk_sp picture = recorder.finishRecordingAsPicture();  
SkSerialProcs sProcs;  sk_sp readableData = 
picture->serialize(&sProcs);*
  // Assuming the byte array is stored in the 'data' field of the SkData 
object
  const void* data = readableData->data();
  size_t size = readableData->size();

* *
  /*sk_sp receievedData = SkData::MakeWithoutCopy(data, size);
  sk_sp copy =
  SkPicture::MakeFromData(receievedData->data(), receievedData->size());
  copy->playback(recordingCanvas);*/
  RestoreToCount(canvas.get(), save_count, params);
}

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97946d8b-27dc-43c4-a262-e4f6288be9d6n%40chromium.org.