| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #define O3D_CORE_CROSS_CAIRO_RENDERER_CAIRO_H_ | 35 #define O3D_CORE_CROSS_CAIRO_RENDERER_CAIRO_H_ |
| 36 | 36 |
| 37 #include <cairo.h> | 37 #include <cairo.h> |
| 38 #include <build/build_config.h> | 38 #include <build/build_config.h> |
| 39 #include <vector> | 39 #include <vector> |
| 40 #include "core/cross/renderer_platform.h" | 40 #include "core/cross/renderer_platform.h" |
| 41 #include "core/cross/renderer.h" | 41 #include "core/cross/renderer.h" |
| 42 | 42 |
| 43 namespace o3d { | 43 namespace o3d { |
| 44 | 44 |
| 45 class Image2D; |
| 46 |
| 45 class RendererCairo : public Renderer { | 47 class RendererCairo : public Renderer { |
| 46 public: | 48 public: |
| 47 static RendererCairo* CreateDefault(ServiceLocator* service_locator); | 49 static RendererCairo* CreateDefault(ServiceLocator* service_locator); |
| 48 | 50 |
| 49 virtual ~RendererCairo(); | 51 virtual ~RendererCairo(); |
| 50 | 52 |
| 51 // Initializes stuff that has to happen after Init | 53 // Initializes stuff that has to happen after Init |
| 52 virtual void InitCommon(); | 54 virtual void InitCommon(); |
| 53 | 55 |
| 54 virtual void UninitCommon(); | 56 virtual void UninitCommon(); |
| 55 | 57 |
| 56 // Initialises the renderer for use, claiming hardware resources. | 58 // Initialises the renderer for use, claiming hardware resources. |
| 57 virtual InitStatus InitPlatformSpecific(const DisplayWindow& display, | 59 virtual InitStatus InitPlatformSpecific(const DisplayWindow& display, |
| 58 bool off_screen); | 60 bool off_screen); |
| 59 | 61 |
| 60 // Released all hardware resources. | 62 // Released all hardware resources. |
| 61 virtual void Destroy(); | 63 virtual void Destroy(); |
| 62 | 64 |
| 63 // set the image surface used to render images to the main surface. | |
| 64 void SetNewFrame(const void* src_data, unsigned src_width, | |
| 65 unsigned src_height, int src_pitch); | |
| 66 | |
| 67 // Paint the frame to the main view | 65 // Paint the frame to the main view |
| 68 void Paint(); | 66 void Paint(); |
| 69 | 67 |
| 68 // Insert the given Image2D to the back of the array. |
| 69 void AddImage2D(Image2D* image); |
| 70 |
| 71 // Remove the given Image2D from the array. |
| 72 void RemoveImage2D(Image2D* image); |
| 73 |
| 70 // Handles the plugin resize event. | 74 // Handles the plugin resize event. |
| 71 virtual void Resize(int width, int height); | 75 virtual void Resize(int width, int height); |
| 72 | 76 |
| 73 // Creates and returns a platform-specific RenderDepthStencilSurface object | 77 // Creates and returns a platform-specific RenderDepthStencilSurface object |
| 74 // for use as a depth-stencil render target. | 78 // for use as a depth-stencil render target. |
| 75 virtual RenderDepthStencilSurface::Ref CreateDepthStencilSurface(int width, | 79 virtual RenderDepthStencilSurface::Ref CreateDepthStencilSurface(int width, |
| 76 int height); | 80 int height); |
| 77 | 81 |
| 78 // Turns fullscreen display on. | 82 // Turns fullscreen display on. |
| 79 // Parameters: | 83 // Parameters: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 135 |
| 132 // Creates and returns a platform specific Sampler object. | 136 // Creates and returns a platform specific Sampler object. |
| 133 virtual Sampler::Ref CreateSampler(); | 137 virtual Sampler::Ref CreateSampler(); |
| 134 | 138 |
| 135 // Returns a platform specific 4 element swizzle table for RGBA UByteN | 139 // Returns a platform specific 4 element swizzle table for RGBA UByteN |
| 136 // fields. | 140 // fields. |
| 137 // The should contain the index of R, G, B, and A in that order for the | 141 // The should contain the index of R, G, B, and A in that order for the |
| 138 // current platform. | 142 // current platform. |
| 139 virtual const int* GetRGBAUByteNSwizzleTable(); | 143 virtual const int* GetRGBAUByteNSwizzleTable(); |
| 140 | 144 |
| 145 // Overriden from Renderer |
| 141 void PushRenderStates(State* state); | 146 void PushRenderStates(State* state); |
| 142 | 147 |
| 148 // Overrider from Renderer |
| 149 void PopRenderStates(); |
| 150 |
| 143 protected: | 151 protected: |
| 152 typedef std::vector<Image2D*> Image2DRefArray; |
| 153 |
| 144 // Keep the constructor protected so only factory methods can create | 154 // Keep the constructor protected so only factory methods can create |
| 145 // renderers. | 155 // renderers. |
| 146 explicit RendererCairo(ServiceLocator* service_locator); | 156 explicit RendererCairo(ServiceLocator* service_locator); |
| 147 | 157 |
| 148 // Sets rendering to the back buffer. | 158 // Sets rendering to the back buffer. |
| 149 virtual void SetBackBufferPlatformSpecific(); | 159 virtual void SetBackBufferPlatformSpecific(); |
| 150 | 160 |
| 151 // Sets the render surfaces on a specific platform. | 161 // Sets the render surfaces on a specific platform. |
| 152 virtual void SetRenderSurfacesPlatformSpecific( | 162 virtual void SetRenderSurfacesPlatformSpecific( |
| 153 const RenderSurface* surface, | 163 const RenderSurface* surface, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 virtual void ApplyDirtyStates(); | 208 virtual void ApplyDirtyStates(); |
| 199 | 209 |
| 200 // Sets the viewport. This is the platform specific version. | 210 // Sets the viewport. This is the platform specific version. |
| 201 virtual void SetViewportInPixels(int left, | 211 virtual void SetViewportInPixels(int left, |
| 202 int top, | 212 int top, |
| 203 int width, | 213 int width, |
| 204 int height, | 214 int height, |
| 205 float min_z, | 215 float min_z, |
| 206 float max_z); | 216 float max_z); |
| 207 | 217 |
| 218 // Mask the are of image_2d_array[index] that will collide with other images. |
| 219 // It assumes the image_2d_array has sorted images as index 0 with |
| 220 // is the most front image. |
| 221 virtual void MaskArea(cairo_t* cr, int index); |
| 222 |
| 223 // Paint the background with black color. |
| 224 virtual void PaintBackGround(cairo_t* cr); |
| 225 |
| 208 // Linux Client Display | 226 // Linux Client Display |
| 209 Display* display_; | 227 Display* display_; |
| 210 // Linux Client Window | 228 // Linux Client Window |
| 211 Window window_; | 229 Window window_; |
| 212 | 230 |
| 213 // Main surface to render cairo | 231 // Main surface to render cairo |
| 214 cairo_surface_t* main_surface_; | 232 cairo_surface_t* main_surface_; |
| 215 | 233 |
| 216 // Current Frame Data Source | 234 // Draw the background |
| 217 const void* frame_src_data_; | 235 cairo_t* bg_drawing_; |
| 218 // Current Frame Source Width | 236 |
| 219 unsigned frame_src_width_; | 237 // Array of Image2d |
| 220 // Current Frame Source Height | 238 Image2DRefArray image_2d_array_; |
| 221 unsigned frame_src_height_; | |
| 222 // Current Frame Source Pitch | |
| 223 int frame_src_pitch_; | |
| 224 }; | 239 }; |
| 225 | 240 |
| 226 } // namespace o3d | 241 } // namespace o3d |
| 227 | 242 |
| 228 #endif // O3D_CORE_CROSS_CAIRO_RENDERER_CAIRO_H_ | 243 #endif // O3D_CORE_CROSS_CAIRO_RENDERER_CAIRO_H_ |
| 229 | 244 |
| OLD | NEW |