公司经常组织一些培训,培训的都是些奇技淫巧。什么设计模式啦,开发策略啦,git啦,repo啦,另外就是培训一些开发流程的东东,例如CMMI啦。可是,却忘记了,程序员终究要归结到三个问题上:

1.解决什么问题?

2.为什么这样解决问题?

3.有没有更好的解决方案?

这些东东才是最核心的东东。但是却是一个程序员一辈子都无法完全掌握的东西。很多人以为写出了高难度的反射代码就是很牛,也有人认为利用C++模板来进行编程就多牛多牛,还有人觉得会写makefile文件,掌握了某种高难度语言很牛。但是我认为这些都不重要,重要的是要有思想。思考者比行动者在关键时候定大局。中国人的技术书籍缺乏的就是思想。在中国,可以肯定,没有几个人能写出像thinking in java这样的鸿篇巨著,更没有人能够超越 design pattern,来描述其思想。反之,像《自己动手写操作系统》,《21天学java》,《程序员的自我修养》,《面试宝典》,《C++面试一百例》, android内核开发要点等等等等一系列的书籍在中国却是层出不穷。为什么,因为缺乏思考,来不及思考,更或者懒得思考。然而,作为一名专业级的程序员,不思考就意味着退步,不学习就意味着淘汰。

这几天一直在思考ANativeWindow是个什么东西,今天终于找到了,代码贴出来,大家参考一下。

  1. struct ANativeWindow
  2. {
  3. #ifdef __cplusplus
  4. ANativeWindow()
  5. : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
  6. {
  7. common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
  8. common.version = sizeof(ANativeWindow);
  9. memset(common.reserved, 0, sizeof(common.reserved));
  10. }
  11. /* Implement the methods that sp<ANativeWindow> expects so that it
  12. can be used to automatically refcount ANativeWindow's. */
  13. void incStrong(const void* id) const {
  14. common.incRef(const_cast<android_native_base_t*>(&common));
  15. }
  16. void decStrong(const void* id) const {
  17. common.decRef(const_cast<android_native_base_t*>(&common));
  18. }
  19. #endif
  20. struct android_native_base_t common;
  21. /* flags describing some attributes of this surface or its updater */
  22. const uint32_t flags;
  23. /* min swap interval supported by this updated */
  24. const int   minSwapInterval;
  25. /* max swap interval supported by this updated */
  26. const int   maxSwapInterval;
  27. /* horizontal and vertical resolution in DPI */
  28. const float xdpi;
  29. const float ydpi;
  30. /* Some storage reserved for the OEM's driver. */
  31. intptr_t    oem[4];
  32. /*
  33. * Set the swap interval for this surface.
  34. *
  35. * Returns 0 on success or -errno on error.
  36. */
  37. int     (*setSwapInterval)(struct ANativeWindow* window,
  38. int interval);
  39. /*
  40. * Hook called by EGL to acquire a buffer. After this call, the buffer
  41. * is not locked, so its content cannot be modified. This call may block if
  42. * no buffers are available.
  43. *
  44. * The window holds a reference to the buffer between dequeueBuffer and
  45. * either queueBuffer or cancelBuffer, so clients only need their own
  46. * reference if they might use the buffer after queueing or canceling it.
  47. * Holding a reference to a buffer after queueing or canceling it is only
  48. * allowed if a specific buffer count has been set.
  49. *
  50. * Returns 0 on success or -errno on error.
  51. */
  52. int     (*dequeueBuffer)(struct ANativeWindow* window,
  53. struct ANativeWindowBuffer** buffer);
  54. /*
  55. * hook called by EGL to lock a buffer. This MUST be called before modifying
  56. * the content of a buffer. The buffer must have been acquired with
  57. * dequeueBuffer first.
  58. *
  59. * Returns 0 on success or -errno on error.
  60. */
  61. int     (*lockBuffer)(struct ANativeWindow* window,
  62. struct ANativeWindowBuffer* buffer);
  63. /*
  64. * Hook called by EGL when modifications to the render buffer are done.
  65. * This unlocks and post the buffer.
  66. *
  67. * The window holds a reference to the buffer between dequeueBuffer and
  68. * either queueBuffer or cancelBuffer, so clients only need their own
  69. * reference if they might use the buffer after queueing or canceling it.
  70. * Holding a reference to a buffer after queueing or canceling it is only
  71. * allowed if a specific buffer count has been set.
  72. *
  73. * Buffers MUST be queued in the same order than they were dequeued.
  74. *
  75. * Returns 0 on success or -errno on error.
  76. */
  77. int     (*queueBuffer)(struct ANativeWindow* window,
  78. struct ANativeWindowBuffer* buffer);
  79. /*
  80. * hook used to retrieve information about the native window.
  81. *
  82. * Returns 0 on success or -errno on error.
  83. */
  84. int     (*query)(const struct ANativeWindow* window,
  85. int what, int* value);
  86. /*
  87. * hook used to perform various operations on the surface.
  88. * (*perform)() is a generic mechanism to add functionality to
  89. * ANativeWindow while keeping backward binary compatibility.
  90. *
  91. * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions
  92. * defined below.
  93. *
  94. *  (*perform)() returns -ENOENT if the 'what' parameter is not supported
  95. *  by the surface's implementation.
  96. *
  97. * The valid operations are:
  98. *     NATIVE_WINDOW_SET_USAGE
  99. *     NATIVE_WINDOW_CONNECT               (deprecated)
  100. *     NATIVE_WINDOW_DISCONNECT            (deprecated)
  101. *     NATIVE_WINDOW_SET_CROP
  102. *     NATIVE_WINDOW_SET_BUFFER_COUNT
  103. *     NATIVE_WINDOW_SET_BUFFERS_GEOMETRY  (deprecated)
  104. *     NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
  105. *     NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
  106. *     NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
  107. *     NATIVE_WINDOW_SET_BUFFERS_FORMAT
  108. *     NATIVE_WINDOW_SET_SCALING_MODE
  109. *     NATIVE_WINDOW_LOCK                   (private)
  110. *     NATIVE_WINDOW_UNLOCK_AND_POST        (private)
  111. *     NATIVE_WINDOW_API_CONNECT            (private)
  112. *     NATIVE_WINDOW_API_DISCONNECT         (private)
  113. *
  114. */
  115. int     (*perform)(struct ANativeWindow* window,
  116. int operation, ... );
  117. /*
  118. * Hook used to cancel a buffer that has been dequeued.
  119. * No synchronization is performed between dequeue() and cancel(), so
  120. * either external synchronization is needed, or these functions must be
  121. * called from the same thread.
  122. *
  123. * The window holds a reference to the buffer between dequeueBuffer and
  124. * either queueBuffer or cancelBuffer, so clients only need their own
  125. * reference if they might use the buffer after queueing or canceling it.
  126. * Holding a reference to a buffer after queueing or canceling it is only
  127. * allowed if a specific buffer count has been set.
  128. */
  129. int     (*cancelBuffer)(struct ANativeWindow* window,
  130. struct ANativeWindowBuffer* buffer);
  131. void* reserved_proc[2];
  132. };

ANativeWindow是个什么东西的更多相关文章

  1. Android中*_handle_t/ANativeWindowBuffer/ANativeWindow/GraphicBuffer/Surface的关系

    在阅读SurfaceFlinger HardwareComposer以及gralloc相关代码的过程中,我们经常会遇到native_handle private_handle_t ANativeWin ...

  2. 多线程爬坑之路-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类)

    前言:刚学习了一段机器学习,最近需要重构一个java项目,又赶过来看java.大多是线程代码,没办法,那时候总觉得多线程是个很难的部分很少用到,所以一直没下决定去啃,那些年留下的坑,总是得自己跳进去填 ...

  3. iOS有关横向TableView的东西

    之前看到Apple store里面有横向的tableview,当然也有可能是collectionview啦. 尤其是项目中只有一条那么需要横向滑动的东西,就没有必要使用庞大的collectionvie ...

  4. 使用ENode框架前您需要了解的东西(初稿)

    选择ENode意味着什么可能很多人还不太清楚.我简单整理了一下: 意味着你选择了:你需要做DDD领域建模.选择了事件驱动的架构.选择了CQRS架构.选择了最终一致性.选择了事件溯源.选择了分布式.这些 ...

  5. 如何写出高质量的技术博客 这边文章出自http://www.jianshu.com/p/ae9ab21a5730 觉得不错直接拿过来了 好东西要大家分享嘛

        如何写出高质量的技术博客?答案是:如果你想,就一定能写出高质量的技术博客.看起来很唯心,但这就是事实.有足够愿力去做一件目标明确,有良好反馈系统的事情往往很简单.就是不停地训练,慢慢地,你自己 ...

  6. Intellij IDEA的一些东西

    Intellij IDEA的一些东西 2016-03-19 15:26 Ctrl + R 在当前文件进行文本替换 (必备) Ctrl + N 根据输入的 类名 查找类文件 Ctrl + Ctrl + ...

  7. 神奇的BFC以及被忽略的东西

    BFC是CSS中一个非常重要的概念,经常用来清除浮动以及处理外边距折叠,但BFC到底是个什么东西却很难准确的表达清楚,国内的相关技术文档基本都不全面,本文的目的就是对BFC的方方面面做个整理,当然未必 ...

  8. 关于这个博客以及C++入门该懂的一些东西

    给三牧中学c++入门的同学们看的博客. 大概是入门一类的?说不定会写点自己的结题报告. 写的不好/写错了别怪我,蒟蒻瑟瑟发抖. 天哪要开始写入门了我好慌那么接下来是编译器连接. (本蒟蒻喜欢用DEV ...

  9. LabVIEW 吸星大法 - 看见的好东西都是我的(上篇)

    前言 写了多年的LabVIEW程序,你是否面临这样的问题 总是在做一些重复的工作,感觉很没有意思: 总在不停的写代码,做类似的控件,实现相同的功能,丝毫没有成就感: 总在天加班,没有时间去提高自己; ...

随机推荐

  1. 数往知来C#之 String 集合 深拷与浅拷 序列化<五>

    C# 基础常用string方法篇 复习. 1.引用类型与值类型     -->文件的复制与快捷方式的复制 2.垃圾回收 3.静态与非静态   -->如何定义静态成员与静态类   --> ...

  2. Using NuGet without committing packages to source control(在没有把包包提交到代码管理器的情况下使用NuGet进行还原 )

    外国老用的语言就是谨慎,连场景都限定好了,其实我们经常下载到有用NuGet引用包包然而却没法编译的情况,上谷歌百度搜又没法使用准确的关键字,最多能用到的就是nuget跟packages.config, ...

  3. AC多模式匹配算法

    建议:学习ac算法最好的途径是看论文pdf_Efficient_String_Matching_An_Aid_to_Biblio 一.一般的搜索算法 keyword: { he, she, his, ...

  4. SSO单点登录在web上的关键点 cookie跨域

    概述 其实WEB单点登录的原理挺简单的,抛开那些复杂的概念,简单来讲讲如何实现一个最基本的单点登录 首先需要有两个程序 例如:http://www.site-a.com 我们简称A http://ww ...

  5. 对easyui datagrid组件的一个小改进

    #对easyui datagrid组件的一个小改进 ##问题 在实际项目中使用datagrid时,受版面限制,有时候表格不能太大,这时候表格里面的内容就不能完全显示,用户需要经常拖动调整列宽才能看完整 ...

  6. windows端口被占用

    查看端口号被占用进程netstat -a -n -o 强制结束PIDtaskkill /pid:604 /F

  7. 2 weekend110的HDFS的JAVA客户端编写 + filesystem设计思想总结

    HDFS的JAVA客户端编写  现在,我们来玩玩,在linux系统里,玩eclipse 或者, 即,更改图标,成功 这个,别慌.重新换个版本就好,有错误出错是好事. http://www.eclips ...

  8. Python基础 列表

    ---***---传送门---***--- 文档解释 def append(self, p_object): """ L.append(object) -> Non ...

  9. 修改Android 程序的icon快捷方式图标和名称

    在res/drawable-hdpi或res/drawable-ldpi或res/drawable-mdpi目录下,加下你要显示的图片,最好后缀是为.png的,然后修改AndroidManifest. ...

  10. sql中 with rollup 、with cube、grouping 统计函数用法

    with rollup .with cube.grouping CUBE 和 ROLLUP 之间的区别在于: CUBE 生成的结果集显示了所选列中值的所有组合的聚合. ROLLUP 生成的结果集显示了 ...