mirror of
https://gitee.com/energye/energy.git
synced 2024-11-29 18:28:06 +08:00
U: dirtyRects, Optimize the way event variables are valued
This commit is contained in:
parent
15d2d25227
commit
f8a3aeda6a
@ -23,7 +23,7 @@ import (
|
||||
type chromiumEventOnResult func(sender lcl.IObject, aResultOK bool) // 通用Result bool
|
||||
type chromiumEventOnResultFloat func(sender lcl.IObject, result float64) // 通用Result float
|
||||
|
||||
type chromiumEventOnAcceleratedPaint func(sender lcl.IObject, browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRectsCount uint32, dirtyRects []*TCefRect, sharedHandle uintptr)
|
||||
type chromiumEventOnAcceleratedPaint func(sender lcl.IObject, browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRects *TCefRectArray, sharedHandle uintptr)
|
||||
type chromiumEventOnAllConnectionsClosed func(sender lcl.IObject)
|
||||
type chromiumEventOnAudioStreamError func(sender lcl.IObject, browser *ICefBrowser, message string)
|
||||
type chromiumEventOnAudioStreamPacket func(sender lcl.IObject, browser *ICefBrowser, data *uintptr, frames int32, pts int64)
|
||||
@ -81,7 +81,7 @@ type chromiumEventOnMediaAccessChange func(sender lcl.IObject, browser *ICefBrow
|
||||
type chromiumEventOnMediaRouteCreateFinished func(sender lcl.IObject, result consts.TCefMediaRouterCreateResult, error string, route *ICefMediaRoute) // TODO ICefMediaRoute
|
||||
type chromiumEventOnMediaSinkDeviceInfo func(sender lcl.IObject, ipAddress string, port int32, modelName string)
|
||||
type chromiumEventOnNavigationVisitorResultAvailable func(sender lcl.IObject, entry *ICefNavigationEntry, current bool, index, total int32) bool // TODO ICefNavigationEntry
|
||||
type chromiumEventOnPaint func(sender lcl.IObject, browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRectsCount uint32, dirtyRects []*TCefRect, buffer uintptr, width, height int32)
|
||||
type chromiumEventOnPaint func(sender lcl.IObject, browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRects *TCefRectArray, buffer uintptr, width, height int32)
|
||||
type chromiumEventOnPdfPrintFinished func(sender lcl.IObject, ok bool)
|
||||
type chromiumEventOnPopupShow func(sender lcl.IObject, browser *ICefBrowser, show bool)
|
||||
type chromiumEventOnPopupSize func(sender lcl.IObject, browser *ICefBrowser, rect *TCefRect)
|
||||
|
@ -49,17 +49,8 @@ func init() {
|
||||
kind := consts.TCefPaintElementType(getVal(2))
|
||||
dirtyRectsCount := uint32(getVal(3))
|
||||
dirtyRectsPtr := getVal(4)
|
||||
var dirtyRects []*TCefRect
|
||||
if dirtyRectsCount > 0 {
|
||||
var rect TCefRect
|
||||
var rectSize = unsafe.Sizeof(rect)
|
||||
dirtyRects = make([]*TCefRect, dirtyRectsCount, dirtyRectsCount)
|
||||
for i := 0; i < int(dirtyRectsCount); i++ {
|
||||
dirtyRects[i] = (*TCefRect)(common.GetParamPtr(dirtyRectsPtr, i*int(rectSize)))
|
||||
}
|
||||
}
|
||||
sharedHandle := getVal(5)
|
||||
fn.(chromiumEventOnAcceleratedPaint)(lcl.AsObject(getPtr(0)), browser, kind, dirtyRectsCount, dirtyRects, sharedHandle)
|
||||
fn.(chromiumEventOnAcceleratedPaint)(lcl.AsObject(getPtr(0)), browser, kind, NewTCefRectArray(dirtyRectsPtr, dirtyRectsCount), sharedHandle)
|
||||
case chromiumEventOnAllConnectionsClosed:
|
||||
fn.(chromiumEventOnAllConnectionsClosed)(lcl.AsObject(getPtr(0)))
|
||||
case chromiumEventOnAudioStreamError:
|
||||
@ -475,18 +466,9 @@ func init() {
|
||||
kind := consts.TCefPaintElementType(getVal(2))
|
||||
dirtyRectsCount := uint32(getVal(3))
|
||||
dirtyRectsPtr := getVal(4)
|
||||
var dirtyRects []*TCefRect
|
||||
if dirtyRectsCount > 0 {
|
||||
var rect TCefRect
|
||||
var rectSize = unsafe.Sizeof(rect)
|
||||
dirtyRects = make([]*TCefRect, dirtyRectsCount, dirtyRectsCount)
|
||||
for i := 0; i < int(dirtyRectsCount); i++ {
|
||||
dirtyRects[i] = (*TCefRect)(common.GetParamPtr(dirtyRectsPtr, i*int(rectSize)))
|
||||
}
|
||||
}
|
||||
buffer := getVal(5)
|
||||
width, height := int32(getVal(6)), int32(getVal(7))
|
||||
fn.(chromiumEventOnPaint)(lcl.AsObject(getPtr(0)), browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height)
|
||||
fn.(chromiumEventOnPaint)(lcl.AsObject(getPtr(0)), browser, kind, NewTCefRectArray(dirtyRectsPtr, dirtyRectsCount), buffer, width, height)
|
||||
case chromiumEventOnPdfPrintFinished:
|
||||
fn.(chromiumEventOnPdfPrintFinished)(lcl.AsObject(getPtr(0)), api.GoBool(getVal(1)))
|
||||
case chromiumEventOnPopupShow:
|
||||
|
@ -12,7 +12,6 @@ package cef
|
||||
|
||||
import (
|
||||
"github.com/energye/energy/v2/cef/internal/def"
|
||||
"github.com/energye/energy/v2/common"
|
||||
"github.com/energye/energy/v2/common/imports"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/golcl/lcl"
|
||||
@ -172,8 +171,8 @@ type renderHandlerGetScreenPoint func(browser *ICefBrowser, viewX, viewY int32)
|
||||
type renderHandlerGetScreenInfo func(browser *ICefBrowser) (screenInfo *TCefScreenInfo, result bool)
|
||||
type renderHandlerOnPopupShow func(browser *ICefBrowser, show bool)
|
||||
type renderHandlerOnPopupSize func(browser *ICefBrowser, rect *TCefRect)
|
||||
type renderHandlerOnPaint func(browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRectsCount uint32, dirtyRects []*TCefRect, buffer uintptr, width, height int32)
|
||||
type renderHandlerOnAcceleratedPaint func(browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRectsCount uint32, dirtyRects []*TCefRect, sharedHandle uintptr)
|
||||
type renderHandlerOnPaint func(browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRects *TCefRectArray, buffer uintptr, width, height int32)
|
||||
type renderHandlerOnAcceleratedPaint func(browser *ICefBrowser, kind consts.TCefPaintElementType, dirtyRects *TCefRectArray, sharedHandle uintptr)
|
||||
type renderHandlerGetTouchHandleSize func(browser *ICefBrowser, orientation consts.TCefHorizontalAlignment) *TCefSize
|
||||
type renderHandlerOnTouchHandleStateChanged func(browser *ICefBrowser, state *TCefTouchHandleState)
|
||||
type renderHandlerOnStartDragging func(browser *ICefBrowser, dragData *ICefDragData, allowedOps consts.TCefDragOperations, x, y int32) bool
|
||||
@ -236,33 +235,16 @@ func init() {
|
||||
kind := consts.TCefPaintElementType(getVal(1))
|
||||
dirtyRectsCount := uint32(getVal(2))
|
||||
dirtyRectsPtr := getVal(3)
|
||||
var dirtyRects []*TCefRect
|
||||
if dirtyRectsCount > 0 {
|
||||
var rectSize = unsafe.Sizeof(TCefRect{})
|
||||
dirtyRects = make([]*TCefRect, dirtyRectsCount, dirtyRectsCount)
|
||||
for i := 0; i < int(dirtyRectsCount); i++ {
|
||||
dirtyRects[i] = (*TCefRect)(common.GetParamPtr(dirtyRectsPtr, i*int(rectSize)))
|
||||
}
|
||||
}
|
||||
buffer := getVal(4)
|
||||
width, height := int32(getVal(5)), int32(getVal(6))
|
||||
fn.(renderHandlerOnPaint)(browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height)
|
||||
fn.(renderHandlerOnPaint)(browser, kind, NewTCefRectArray(dirtyRectsPtr, dirtyRectsCount), buffer, width, height)
|
||||
case renderHandlerOnAcceleratedPaint:
|
||||
browser := &ICefBrowser{instance: getPtr(0)}
|
||||
kind := consts.TCefPaintElementType(getVal(1))
|
||||
dirtyRectsCount := uint32(getVal(2))
|
||||
dirtyRectsPtr := getVal(3)
|
||||
var dirtyRects []*TCefRect
|
||||
if dirtyRectsCount > 0 {
|
||||
var rect TCefRect
|
||||
var rectSize = unsafe.Sizeof(rect)
|
||||
dirtyRects = make([]*TCefRect, dirtyRectsCount, dirtyRectsCount)
|
||||
for i := 0; i < int(dirtyRectsCount); i++ {
|
||||
dirtyRects[i] = (*TCefRect)(common.GetParamPtr(dirtyRectsPtr, i*int(rectSize)))
|
||||
}
|
||||
}
|
||||
sharedHandle := getVal(4)
|
||||
fn.(renderHandlerOnAcceleratedPaint)(browser, kind, dirtyRectsCount, dirtyRects, sharedHandle)
|
||||
fn.(renderHandlerOnAcceleratedPaint)(browser, kind, NewTCefRectArray(dirtyRectsPtr, dirtyRectsCount), sharedHandle)
|
||||
case renderHandlerGetTouchHandleSize:
|
||||
browser := &ICefBrowser{instance: getPtr(0)}
|
||||
orientation := consts.TCefHorizontalAlignment(getVal(1))
|
||||
|
28
cef/types.go
28
cef/types.go
@ -15,6 +15,7 @@
|
||||
package cef
|
||||
|
||||
import (
|
||||
"github.com/energye/energy/v2/common"
|
||||
. "github.com/energye/energy/v2/consts"
|
||||
. "github.com/energye/energy/v2/types"
|
||||
"github.com/energye/golcl/lcl"
|
||||
@ -171,6 +172,33 @@ type TCefRect struct {
|
||||
Height int32
|
||||
}
|
||||
|
||||
type TCefRectArray struct {
|
||||
ptr uintptr
|
||||
sizeOf uintptr
|
||||
count uint32
|
||||
}
|
||||
|
||||
// NewTCefRectArray
|
||||
// TCefRect 动态数组结构, 通过指针引用取值
|
||||
func NewTCefRectArray(ptr uintptr, count uint32) *TCefRectArray {
|
||||
return &TCefRectArray{
|
||||
ptr: ptr,
|
||||
sizeOf: unsafe.Sizeof(TCefRect{}),
|
||||
count: count,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *TCefRectArray) Count() uint32 {
|
||||
return m.count
|
||||
}
|
||||
|
||||
func (m *TCefRectArray) Get(index int) *TCefRect {
|
||||
if m.count == 0 || index < 0 || index >= int(m.count) {
|
||||
return nil
|
||||
}
|
||||
return (*TCefRect)(common.GetParamPtr(m.ptr, index*int(m.sizeOf)))
|
||||
}
|
||||
|
||||
// TCefSize
|
||||
// /include/internal/cef_types_geometry.h (cef_size_t)
|
||||
type TCefSize struct {
|
||||
|
Loading…
Reference in New Issue
Block a user