浏览代码

clean c++ code

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
69f68e78
共有 7 个文件被更改,包括 40 次插入51 次删除
  1. 13
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
  2. 13
      engine/README.md
  3. 23
      engine/src/flow/raster_cache.cc
  4. 32
      engine/src/lib/ui/text/paragraph.cc
  5. 1
      engine/src/shell/gpu/gpu_surface_gl.cc
  6. 1
      engine/src/shell/platform/unity/android/uiwidgets_system.h
  7. 8
      engine/src/shell/platform/unity/android/unity_surface_manager.cc

13
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs


using System.Collections.Generic;
using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;
using UnityEngine.UI;
using Color = Unity.UIWidgets.ui.Color;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

{
base.OnEnable();
}
#if !UNITY_EDITOR
internal const string dllName = "libUIWidgets_d";
[DllImport(dllName)]
static extern float TestFloat();
#endif
Debug.Log("???? main");
ui_.runApp(new MyApp());
}

13
engine/README.md


Follow https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment
2. Compiling for Windows
Follow https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-windows
3. Checkout flutter-1.18-candidate.5
2. Checkout flutter-1.18-candidate.5
```
cd engine/src/flutter

If the compilation fails because "no available Mac SDK is found" (in flutter-1.17 the build tool will only try to find Mac 10.XX SDKs), please modify the file "/src/build/Mac/find_sdk.py" under flutter root by setting "sdks" as your current sdk, e.g., ['11.0'].
### build icu
```
cd <uiwidigets_dir>\engine
```
### build uiwidgets
```
cd <uiwidigets_dir>\engine
mono bee.exe
```

23
engine/src/flow/raster_cache.cc


RasterCacheResult::RasterCacheResult(sk_sp<SkImage> image,
const SkRect& logical_rect)
: image_(std::move(image)), logical_rect_(logical_rect) {}
#if __ANDROID__
#define ABS(x) abs(x)
template<typename T>
T abs(T x) {
if (x < 0) {
return -x;
}
return x;
}
#else
#define ABS(x) std::abs(x)
#endif
void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const {
TRACE_EVENT0("uiwidgets", "RasterCacheResult::draw");

auto a = bounds.size().width() - image_->dimensions().width();
if(a < 0){
a = -a;
}
auto b = bounds.size().height() - image_->dimensions().height();
if(b < 0){
b = -b;
}
a <= 1 &&
b <= 1);
ABS(bounds.size().width() - image_->dimensions().width()) <= 1 &&
ABS(bounds.size().height() - image_->dimensions().height()) <= 1);
canvas.resetMatrix();
canvas.drawImage(image_, bounds.fLeft, bounds.fTop, paint);
}

32
engine/src/lib/ui/text/paragraph.cc


return result;
}
// static void EncodeTextBoxes(const std::vector<txt::Paragraph::TextBox>& boxes,
// float* result) {
// // Layout:
// // First value is the number of values.
// // Then there are boxes.size() groups of 5 which are LTRBD, where D is the
// // text direction index.
static void EncodeTextBoxes(const std::vector<txt::Paragraph::TextBox>& boxes,
float* result) {
// Layout:
// First value is the number of values.
// Then there are boxes.size() groups of 5 which are LTRBD, where D is the
// text direction index.
// unsigned long position = 0;
// for (unsigned long i = 0; i < boxes.size(); i++) {
// const txt::Paragraph::TextBox& box = boxes[i];
// result[position++] = box.rect.fLeft;
// result[position++] = box.rect.fTop;
// result[position++] = box.rect.fRight;
// result[position++] = box.rect.fBottom;
// result[position++] = static_cast<float>(box.direction);
// }
// }
unsigned long position = 0;
for (unsigned long i = 0; i < boxes.size(); i++) {
const txt::Paragraph::TextBox& box = boxes[i];
result[position++] = box.rect.fLeft;
result[position++] = box.rect.fTop;
result[position++] = box.rect.fRight;
result[position++] = box.rect.fBottom;
result[position++] = static_cast<float>(box.direction);
}
}
Float32List Paragraph::getRectsForRange(unsigned start, unsigned end,
unsigned boxHeightStyle,

1
engine/src/shell/gpu/gpu_surface_gl.cc


{
TRACE_EVENT0("uiwidgets", "SkCanvas::Flush");
onscreen_surface_->getCanvas()->flush();
// onscreen_surface_->getContext()->submit(true);
}
if (!delegate_->GLContextPresent()) {

1
engine/src/shell/platform/unity/android/uiwidgets_system.h


void printf_console(const char* log, ...) {
va_list vl;
va_start(vl, log);
// TODO: error in __android_log_vprint -> vsnprintf -> __vfprintf -> strlen_a
// unity_uiwidgets_->printf_consolev(log, vl);
va_end(vl);
}

8
engine/src/shell/platform/unity/android/unity_surface_manager.cc


FML_DCHECK(fbo_ != 0);
glDeleteFramebuffers(1, &fbo_);
fbo_ = 0;
// FML_DCHECK(fbo_texture_ != 0);
// glDeleteTextures(1, &fbo_texture_);
// fbo_texture_ = 0;
// FML_DCHECK(fbo_egl_image_ != nullptr);
// eglDestroyImageKHR(egl_display_, fbo_egl_image_);
// fbo_egl_image_ = nullptr;
}
bool UnitySurfaceManager::ClearCurrent()

正在加载...
取消
保存