1 /* 2 * Copyright (C) 2006 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 17 #ifndef SkGLCanvas_DEFINED 18 #define SkGLCanvas_DEFINED 19 20 #include "SkCanvas.h" 21 22 #ifdef SK_BUILD_FOR_MAC 23 #include <OpenGL/gl.h> 24 #elif defined(ANDROID) 25 #include <GLES/gl.h> 26 #endif 27 28 class SkGLDevice; 29 class SkGLClipIter; 30 31 class SkGLCanvas : public SkCanvas { 32 public: 33 // notice, we do NOT allow the SkCanvas(bitmap) constructor, since that 34 // does not create a SkGLDevice, which we require 35 SkGLCanvas(); 36 virtual ~SkGLCanvas(); 37 38 // overrides from SkCanvas 39 40 virtual bool getViewport(SkIPoint*) const; 41 virtual bool setViewport(int width, int height); 42 43 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, 44 bool isOpaque, bool isForLayer); 45 46 // settings for the global texture cache 47 48 static size_t GetTextureCacheMaxCount(); 49 static void SetTextureCacheMaxCount(size_t count); 50 51 static size_t GetTextureCacheMaxSize(); 52 static void SetTextureCacheMaxSize(size_t size); 53 54 /** Call glDeleteTextures for all textures (including those for text) 55 This should be called while the gl-context is still valid. Its purpose 56 is to free up gl resources. Note that if a bitmap or text is drawn after 57 this call, new caches will be created. 58 */ 59 static void DeleteAllTextures(); 60 61 /** Forget all textures without calling delete (including those for text). 62 This should be called if the gl-context has changed, and the texture 63 IDs that have been cached are no longer valid. 64 */ 65 static void AbandonAllTextures(); 66 67 private: 68 SkIPoint fViewportSize; 69 70 // need to disallow this guy setBitmapDevice(const SkBitmap & bitmap)71 virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap) { 72 sk_throw(); 73 return NULL; 74 } 75 76 typedef SkCanvas INHERITED; 77 }; 78 79 #endif 80 81