LayerState.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2008 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <utils/Errors.h>
  17. #include <binder/Parcel.h>
  18. #include <gui/ISurfaceComposerClient.h>
  19. #include <gui/IGraphicBufferProducer.h>
  20. #include <private/gui/LayerState.h>
  21. namespace android {
  22. status_t layer_state_t::write(Parcel& output) const
  23. {
  24. output.writeStrongBinder(surface);
  25. output.writeUint32(what);
  26. output.writeFloat(x);
  27. output.writeFloat(y);
  28. output.writeUint32(z);
  29. output.writeUint32(w);
  30. output.writeUint32(h);
  31. output.writeUint32(layerStack);
  32. output.writeFloat(blur);
  33. output.writeStrongBinder(blurMaskSurface);
  34. output.writeUint32(blurMaskSampling);
  35. output.writeFloat(blurMaskAlphaThreshold);
  36. output.writeFloat(alpha);
  37. output.writeUint32(flags);
  38. output.writeUint32(mask);
  39. *reinterpret_cast<layer_state_t::matrix22_t *>(
  40. output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
  41. output.write(crop);
  42. output.write(transparentRegion);
  43. return NO_ERROR;
  44. }
  45. status_t layer_state_t::read(const Parcel& input)
  46. {
  47. surface = input.readStrongBinder();
  48. what = input.readUint32();
  49. x = input.readFloat();
  50. y = input.readFloat();
  51. z = input.readUint32();
  52. w = input.readUint32();
  53. h = input.readUint32();
  54. layerStack = input.readUint32();
  55. blur = input.readFloat();
  56. blurMaskSurface = input.readStrongBinder();
  57. blurMaskSampling = input.readUint32();
  58. blurMaskAlphaThreshold = input.readFloat();
  59. alpha = input.readFloat();
  60. flags = static_cast<uint8_t>(input.readUint32());
  61. mask = static_cast<uint8_t>(input.readUint32());
  62. const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
  63. if (matrix_data) {
  64. matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
  65. } else {
  66. return BAD_VALUE;
  67. }
  68. input.read(crop);
  69. input.read(transparentRegion);
  70. return NO_ERROR;
  71. }
  72. status_t ComposerState::write(Parcel& output) const {
  73. output.writeStrongBinder(IInterface::asBinder(client));
  74. return state.write(output);
  75. }
  76. status_t ComposerState::read(const Parcel& input) {
  77. client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
  78. return state.read(input);
  79. }
  80. status_t DisplayState::write(Parcel& output) const {
  81. output.writeStrongBinder(token);
  82. output.writeStrongBinder(IInterface::asBinder(surface));
  83. output.writeUint32(what);
  84. output.writeUint32(layerStack);
  85. output.writeUint32(orientation);
  86. output.write(viewport);
  87. output.write(frame);
  88. output.writeUint32(width);
  89. output.writeUint32(height);
  90. return NO_ERROR;
  91. }
  92. status_t DisplayState::read(const Parcel& input) {
  93. token = input.readStrongBinder();
  94. surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
  95. what = input.readUint32();
  96. layerStack = input.readUint32();
  97. orientation = input.readUint32();
  98. input.read(viewport);
  99. input.read(frame);
  100. width = input.readUint32();
  101. height = input.readUint32();
  102. return NO_ERROR;
  103. }
  104. }; // namespace android