Back to index

unity  6.0.0
IconRenderer.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef ICONRENDERER_H
00021 #define ICONRENDERER_H
00022 
00023 #include <Nux/Nux.h>
00024 #include <Nux/BaseWindow.h>
00025 #include <Nux/View.h>
00026 
00027 #include "AbstractIconRenderer.h"
00028 
00029 namespace unity
00030 {
00031 namespace ui
00032 {
00033 
00034 class IconTextureSource;
00035 
00036 class IconRenderer : public AbstractIconRenderer
00037 {
00038 public:
00039   IconRenderer();
00040   virtual ~IconRenderer();
00041 
00042   void PreprocessIcons(std::list<RenderArg>& args, nux::Geometry const& target_window);
00043 
00044   void RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& arg, nux::Geometry const& anchor_geo, nux::Geometry const& owner_geo);
00045 
00046   void SetTargetSize(int tile_size, int image_size, int spacing);
00047 
00048   static void DestroyTextures();
00049 
00050 protected:
00051   nux::BaseTexture* RenderCharToTexture(const char label, int width, int height);
00052 
00053   void RenderElement(nux::GraphicsEngine& GfxContext,
00054                      RenderArg const& arg,
00055                      nux::ObjectPtr<nux::IOpenGLBaseTexture> icon,
00056                      nux::Color bkg_color,
00057                      nux::Color colorify,
00058                      float alpha,
00059                      bool force_filter,
00060                      std::vector<nux::Vector4>& xform_coords);
00061 
00062   void RenderIndicators(nux::GraphicsEngine& GfxContext,
00063                         RenderArg const& arg,
00064                         int running,
00065                         int active,
00066                         float alpha,
00067                         nux::Geometry const& geo);
00068 
00069   void RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
00070                                nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
00071                                float progress_fill,
00072                                float bias);
00073 
00074   void UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
00075                            float x, float y, float w, float h, float z, ui::IconTextureSource::TransformIndex index);
00076 
00077   void UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
00078                                   float x, float y, float w, float h, float z, float xx, float yy, float ww, float hh, ui::IconTextureSource::TransformIndex index);
00079 
00080   void GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
00081                                          int ViewportWidth,
00082                                          int ViewportHeight,
00083                                          float NearClipPlane,
00084                                          float FarClipPlane,
00085                                          float Fovy);
00086 
00087   void SetOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
00088 
00089   void RestoreSystemRenderTarget();
00090 
00091 private:
00092   int icon_size;
00093   int image_size;
00094   int spacing;
00095 
00096   nux::Matrix4 _stored_projection_matrix;
00097 };
00098 
00099 }
00100 }
00101 
00102 #endif // ICONRENDERER_H
00103