Class: Skia::Picture
- Inherits:
-
Base
- Object
- Base
- Skia::Picture
show all
- Defined in:
- lib/skia/picture.rb
Instance Attribute Summary
Attributes inherited from Base
#ptr
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#null?, release_callback, #to_ptr
Constructor Details
#initialize(ptr) ⇒ Picture
Returns a new instance of Picture.
5
6
7
|
# File 'lib/skia/picture.rb', line 5
def initialize(ptr)
super(ptr, :sk_picture_unref)
end
|
Class Method Details
.from_data(data) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/skia/picture.rb', line 9
def self.from_data(data)
data_obj = data.is_a?(Data) ? data : Data.new(data)
ptr = Native.sk_picture_deserialize_from_data(data_obj.ptr)
raise Error, "Failed to deserialize picture" if ptr.nil? || ptr.null?
new(ptr)
end
|
.load(path) ⇒ Object
58
59
60
61
|
# File 'lib/skia/picture.rb', line 58
def self.load(path)
data = Data.from_file(path)
from_data(data)
end
|
.record(bounds, &block) ⇒ Object
17
18
19
20
|
# File 'lib/skia/picture.rb', line 17
def self.record(bounds, &block)
recorder = PictureRecorder.new
recorder.begin_recording(bounds, &block)
end
|
Instance Method Details
#approximate_bytes_used ⇒ Object
48
49
50
|
# File 'lib/skia/picture.rb', line 48
def approximate_bytes_used
Native.sk_picture_approximate_bytes_used(@ptr)
end
|
#approximate_op_count(nested: true) ⇒ Object
44
45
46
|
# File 'lib/skia/picture.rb', line 44
def approximate_op_count(nested: true)
Native.sk_picture_approximate_op_count(@ptr, nested)
end
|
#cull_rect ⇒ Object
26
27
28
29
30
|
# File 'lib/skia/picture.rb', line 26
def cull_rect
rect_struct = Native::SKRect.new
Native.sk_picture_get_cull_rect(@ptr, rect_struct)
Rect.from_struct(rect_struct)
end
|
#playback(canvas) ⇒ Object
32
33
34
35
|
# File 'lib/skia/picture.rb', line 32
def playback(canvas)
Native.sk_picture_playback(@ptr, canvas.ptr)
self
end
|
#save(path) ⇒ Object
52
53
54
55
56
|
# File 'lib/skia/picture.rb', line 52
def save(path)
data = serialize
File.binwrite(path, data.to_s)
self
end
|
#serialize ⇒ Object
37
38
39
40
41
42
|
# File 'lib/skia/picture.rb', line 37
def serialize
data_ptr = Native.sk_picture_serialize_to_data(@ptr)
raise Error, "Failed to serialize picture" if data_ptr.nil? || data_ptr.null?
Data.new(data_ptr)
end
|
#unique_id ⇒ Object
22
23
24
|
# File 'lib/skia/picture.rb', line 22
def unique_id
Native.sk_picture_get_unique_id(@ptr)
end
|