OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ManagedTexture.h" | 32 #include "ManagedTexture.h" |
33 | 33 |
34 using namespace std; | 34 using namespace std; |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 | 38 |
39 namespace { | 39 namespace { |
40 size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize,
size_t minMegabytes, size_t maxMegabytes) | 40 size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize,
size_t minMegabytes, size_t maxMegabytes) |
41 { | 41 { |
| 42 if (!viewportMultiplier) |
| 43 return maxMegabytes * 1024 * 1024; |
42 if (viewportSize.isEmpty()) | 44 if (viewportSize.isEmpty()) |
43 return minMegabytes * 1024 * 1024; | 45 return minMegabytes * 1024 * 1024; |
44 return max(minMegabytes * 1024 * 1024, min(maxMegabytes * 1024 * 1024, viewp
ortMultiplier * TextureManager::memoryUseBytes(viewportSize, GraphicsContext3D::
RGBA))); | 46 return max(minMegabytes * 1024 * 1024, min(maxMegabytes * 1024 * 1024, viewp
ortMultiplier * TextureManager::memoryUseBytes(viewportSize, GraphicsContext3D::
RGBA))); |
45 } | 47 } |
46 } | 48 } |
47 | 49 |
48 size_t TextureManager::highLimitBytes(const IntSize& viewportSize) | 50 size_t TextureManager::highLimitBytes(const IntSize& viewportSize) |
49 { | 51 { |
50 size_t viewportMultiplier, minMegabytes, maxMegabytes; | 52 size_t viewportMultiplier, minMegabytes, maxMegabytes; |
51 viewportMultiplier = 12; | |
52 #if OS(ANDROID) | 53 #if OS(ANDROID) |
53 minMegabytes = 24; | 54 viewportMultiplier = 16; |
54 maxMegabytes = 40; | 55 minMegabytes = 32; |
| 56 maxMegabytes = 64; |
55 #else | 57 #else |
56 minMegabytes = 64; | 58 viewportMultiplier = 0; |
| 59 minMegabytes = 0; |
57 maxMegabytes = 128; | 60 maxMegabytes = 128; |
58 #endif | 61 #endif |
59 return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxM
egabytes); | 62 return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxM
egabytes); |
60 } | 63 } |
61 | 64 |
62 size_t TextureManager::reclaimLimitBytes(const IntSize& viewportSize) | 65 size_t TextureManager::reclaimLimitBytes(const IntSize& viewportSize) |
63 { | 66 { |
64 size_t viewportMultiplier, minMegabytes, maxMegabytes; | 67 size_t viewportMultiplier, minMegabytes, maxMegabytes; |
65 viewportMultiplier = 6; | |
66 #if OS(ANDROID) | 68 #if OS(ANDROID) |
67 minMegabytes = 9; | 69 viewportMultiplier = 8; |
| 70 minMegabytes = 16; |
68 maxMegabytes = 32; | 71 maxMegabytes = 32; |
69 #else | 72 #else |
70 minMegabytes = 32; | 73 viewportMultiplier = 0; |
| 74 minMegabytes = 0; |
71 maxMegabytes = 64; | 75 maxMegabytes = 64; |
72 #endif | 76 #endif |
73 return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxM
egabytes); | 77 return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxM
egabytes); |
74 } | 78 } |
75 | 79 |
76 size_t TextureManager::lowLimitBytes(const IntSize& viewportSize) | |
77 { | |
78 size_t viewportMultiplier, minMegabytes, maxMegabytes; | |
79 viewportMultiplier = 1; | |
80 minMegabytes = 2; | |
81 maxMegabytes = 3; | |
82 return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxM
egabytes); | |
83 } | |
84 | |
85 size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureForma
t) | 80 size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureForma
t) |
86 { | 81 { |
87 // FIXME: This assumes all textures are 1 byte/component. | 82 // FIXME: This assumes all textures are 1 byte/component. |
88 const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE; | 83 const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE; |
89 unsigned int componentsPerPixel = 4; | 84 unsigned int componentsPerPixel = 4; |
90 unsigned int bytesPerComponent = 1; | 85 unsigned int bytesPerComponent = 1; |
91 if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type,
&componentsPerPixel, &bytesPerComponent)) | 86 if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type,
&componentsPerPixel, &bytesPerComponent)) |
92 ASSERT_NOT_REACHED(); | 87 ASSERT_NOT_REACHED(); |
93 | 88 |
94 return size.width() * size.height() * componentsPerPixel * bytesPerComponent
; | 89 return size.width() * size.height() * componentsPerPixel * bytesPerComponent
; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 #ifndef NDEBUG | 295 #ifndef NDEBUG |
301 info.allocator = 0; | 296 info.allocator = 0; |
302 #endif | 297 #endif |
303 addTexture(token, info); | 298 addTexture(token, info); |
304 return true; | 299 return true; |
305 } | 300 } |
306 | 301 |
307 } | 302 } |
308 | 303 |
309 #endif // USE(ACCELERATED_COMPOSITING) | 304 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |