00001 /* 00002 * Copyright (C) 2006 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkGLCanvas_DEFINED 00018 #define SkGLCanvas_DEFINED 00019 00020 #include "SkCanvas.h" 00021 00022 #ifdef SK_BUILD_FOR_MAC 00023 #include <OpenGL/gl.h> 00024 #elif defined(ANDROID) 00025 #include <GLES/gl.h> 00026 #endif 00027 00028 class SkGLDevice; 00029 class SkGLClipIter; 00030 00031 class SkGLCanvas : public SkCanvas { 00032 public: 00033 // notice, we do NOT allow the SkCanvas(bitmap) constructor, since that 00034 // does not create a SkGLDevice, which we require 00035 SkGLCanvas(); 00036 virtual ~SkGLCanvas(); 00037 00038 // overrides from SkCanvas 00039 00040 virtual bool getViewport(SkIPoint*) const; 00041 virtual bool setViewport(int width, int height); 00042 00043 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, 00044 bool isOpaque, bool isForLayer); 00045 00046 // settings for the global texture cache 00047 00048 static size_t GetTextureCacheMaxCount(); 00049 static void SetTextureCacheMaxCount(size_t count); 00050 00051 static size_t GetTextureCacheMaxSize(); 00052 static void SetTextureCacheMaxSize(size_t size); 00053 00059 static void DeleteAllTextures(); 00060 00065 static void AbandonAllTextures(); 00066 00067 private: 00068 SkIPoint fViewportSize; 00069 00070 // need to disallow this guy 00071 virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap) { 00072 sk_throw(); 00073 return NULL; 00074 } 00075 00076 typedef SkCanvas INHERITED; 00077 }; 00078 00079 #endif 00080