OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 format, | 1946 format, |
1947 GL_UNSIGNED_BYTE, | 1947 GL_UNSIGNED_BYTE, |
1948 row); | 1948 row); |
1949 } | 1949 } |
1950 delete[] row; | 1950 delete[] row; |
1951 } | 1951 } |
1952 } | 1952 } |
1953 return 0; | 1953 return 0; |
1954 } | 1954 } |
1955 | 1955 |
1956 int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLImageElement* image, | 1956 int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, |
1957 bool flipY, bool premultiplyAlpha) | 1957 bool flipY, bool premultiplyAlpha) |
1958 { | 1958 { |
1959 CachedImage* cachedImage = image->cachedImage(); | 1959 ASSERT(image); |
1960 if (cachedImage == NULL) { | 1960 |
1961 ASSERT_NOT_REACHED(); | |
1962 return -1; | |
1963 } | |
1964 Image* img = cachedImage->image(); | |
1965 int res = -1; | 1961 int res = -1; |
1966 #if PLATFORM(SKIA) | 1962 #if PLATFORM(SKIA) |
1967 NativeImageSkia* skiaImage = img->nativeImageForCurrentFrame(); | 1963 NativeImageSkia* skiaImage = image->nativeImageForCurrentFrame(); |
1968 if (skiaImage == NULL) { | 1964 if (skiaImage == NULL) { |
1969 ASSERT_NOT_REACHED(); | 1965 ASSERT_NOT_REACHED(); |
1970 return -1; | 1966 return -1; |
1971 } | 1967 } |
1972 SkBitmap::Config skiaConfig = skiaImage->config(); | 1968 SkBitmap::Config skiaConfig = skiaImage->config(); |
1973 // FIXME: must support more image configurations. | 1969 // FIXME: must support more image configurations. |
1974 if (skiaConfig != SkBitmap::kARGB_8888_Config) { | 1970 if (skiaConfig != SkBitmap::kARGB_8888_Config) { |
1975 ASSERT_NOT_REACHED(); | 1971 ASSERT_NOT_REACHED(); |
1976 return -1; | 1972 return -1; |
1977 } | 1973 } |
1978 SkBitmap& skiaImageRef = *skiaImage; | 1974 SkBitmap& skiaImageRef = *skiaImage; |
1979 SkAutoLockPixels lock(skiaImageRef); | 1975 SkAutoLockPixels lock(skiaImageRef); |
1980 int width = skiaImage->width(); | 1976 int width = skiaImage->width(); |
1981 int height = skiaImage->height(); | 1977 int height = skiaImage->height(); |
1982 unsigned char* pixels = | 1978 unsigned char* pixels = |
1983 reinterpret_cast<unsigned char*>(skiaImage->getPixels()); | 1979 reinterpret_cast<unsigned char*>(skiaImage->getPixels()); |
1984 int rowBytes = skiaImage->rowBytes(); | 1980 int rowBytes = skiaImage->rowBytes(); |
1985 res = texImage2DHelper(target, level, | 1981 res = texImage2DHelper(target, level, |
1986 width, height, | 1982 width, height, |
1987 rowBytes, | 1983 rowBytes, |
1988 flipY, premultiplyAlpha, | 1984 flipY, premultiplyAlpha, |
1989 GL_BGRA, | 1985 GL_BGRA, |
1990 false, | 1986 false, |
1991 pixels); | 1987 pixels); |
1992 #elif PLATFORM(CG) | 1988 #elif PLATFORM(CG) |
1993 CGImageRef cgImage = img->nativeImageForCurrentFrame(); | 1989 CGImageRef cgImage = image->nativeImageForCurrentFrame(); |
1994 if (cgImage == NULL) { | 1990 if (cgImage == NULL) { |
1995 ASSERT_NOT_REACHED(); | 1991 ASSERT_NOT_REACHED(); |
1996 return -1; | 1992 return -1; |
1997 } | 1993 } |
1998 int width = CGImageGetWidth(cgImage); | 1994 int width = CGImageGetWidth(cgImage); |
1999 int height = CGImageGetHeight(cgImage); | 1995 int height = CGImageGetHeight(cgImage); |
2000 int rowBytes = width * 4; | 1996 int rowBytes = width * 4; |
2001 CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage); | 1997 CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage); |
2002 bool skipAlpha = (info == kCGImageAlphaNone || | 1998 bool skipAlpha = (info == kCGImageAlphaNone || |
2003 info == kCGImageAlphaNoneSkipLast || | 1999 info == kCGImageAlphaNoneSkipLast || |
(...skipping 10 matching lines...) Expand all Loading... |
2014 CGContextRelease(tmpContext); | 2010 CGContextRelease(tmpContext); |
2015 res = texImage2DHelper(target, level, width, height, rowBytes, | 2011 res = texImage2DHelper(target, level, width, height, rowBytes, |
2016 flipY, premultiplyAlpha, GL_RGBA, skipAlpha, imageData); | 2012 flipY, premultiplyAlpha, GL_RGBA, skipAlpha, imageData); |
2017 delete[] imageData; | 2013 delete[] imageData; |
2018 #else | 2014 #else |
2019 #error Must port to your platform | 2015 #error Must port to your platform |
2020 #endif | 2016 #endif |
2021 return res; | 2017 return res; |
2022 } | 2018 } |
2023 | 2019 |
2024 int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, | |
2025 bool flipY, bool premultiplyAlpha) | |
2026 { | |
2027 // FIXME: implement. | |
2028 notImplemented(); | |
2029 return -1; | |
2030 } | |
2031 | |
2032 int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, | 2020 int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, |
2033 bool flipY, bool premultiplyAlpha) | 2021 bool flipY, bool premultiplyAlpha) |
2034 { | 2022 { |
2035 // FIXME: implement. | 2023 // FIXME: implement. |
2036 notImplemented(); | 2024 notImplemented(); |
2037 return -1; | 2025 return -1; |
2038 } | 2026 } |
2039 | 2027 |
2040 GL_SAME_METHOD_3(TexParameterf, texParameterf, unsigned, unsigned, float); | 2028 GL_SAME_METHOD_3(TexParameterf, texParameterf, unsigned, unsigned, float); |
2041 | 2029 |
(...skipping 28 matching lines...) Expand all Loading... |
2070 notImplemented(); | 2058 notImplemented(); |
2071 return -1; | 2059 return -1; |
2072 } | 2060 } |
2073 | 2061 |
2074 int GraphicsContext3D::texSubImage2D(unsigned target, | 2062 int GraphicsContext3D::texSubImage2D(unsigned target, |
2075 unsigned level, | 2063 unsigned level, |
2076 unsigned xoffset, | 2064 unsigned xoffset, |
2077 unsigned yoffset, | 2065 unsigned yoffset, |
2078 unsigned width, | 2066 unsigned width, |
2079 unsigned height, | 2067 unsigned height, |
2080 HTMLImageElement* image, | 2068 Image* image, |
2081 bool flipY, | 2069 bool flipY, |
2082 bool premultiplyAlpha) | 2070 bool premultiplyAlpha) |
2083 { | 2071 { |
2084 // FIXME: implement. | 2072 // FIXME: implement. |
2085 notImplemented(); | 2073 notImplemented(); |
2086 return -1; | 2074 return -1; |
2087 } | 2075 } |
2088 | 2076 |
2089 int GraphicsContext3D::texSubImage2D(unsigned target, | 2077 int GraphicsContext3D::texSubImage2D(unsigned target, |
2090 unsigned level, | 2078 unsigned level, |
2091 unsigned xoffset, | 2079 unsigned xoffset, |
2092 unsigned yoffset, | 2080 unsigned yoffset, |
2093 unsigned width, | 2081 unsigned width, |
2094 unsigned height, | 2082 unsigned height, |
2095 HTMLCanvasElement* canvas, | |
2096 bool flipY, | |
2097 bool premultiplyAlpha) | |
2098 { | |
2099 // FIXME: implement. | |
2100 notImplemented(); | |
2101 return -1; | |
2102 } | |
2103 | |
2104 int GraphicsContext3D::texSubImage2D(unsigned target, | |
2105 unsigned level, | |
2106 unsigned xoffset, | |
2107 unsigned yoffset, | |
2108 unsigned width, | |
2109 unsigned height, | |
2110 HTMLVideoElement* video, | 2083 HTMLVideoElement* video, |
2111 bool flipY, | 2084 bool flipY, |
2112 bool premultiplyAlpha) | 2085 bool premultiplyAlpha) |
2113 { | 2086 { |
2114 // FIXME: implement. | 2087 // FIXME: implement. |
2115 notImplemented(); | 2088 notImplemented(); |
2116 return -1; | 2089 return -1; |
2117 } | 2090 } |
2118 | 2091 |
2119 GL_SAME_METHOD_2(Uniform1f, uniform1f, long, float) | 2092 GL_SAME_METHOD_2(Uniform1f, uniform1f, long, float) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 | 2215 |
2243 void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height) | 2216 void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height) |
2244 { | 2217 { |
2245 makeContextCurrent(); | 2218 makeContextCurrent(); |
2246 m_internal->viewportImpl(x, y, width, height); | 2219 m_internal->viewportImpl(x, y, width, height); |
2247 } | 2220 } |
2248 | 2221 |
2249 } | 2222 } |
2250 | 2223 |
2251 #endif // ENABLE(3D_CANVAS) | 2224 #endif // ENABLE(3D_CANVAS) |
OLD | NEW |