| 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 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 29 matching lines...) Expand all Loading... |
| 40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebCompositorSupport.h" | 41 #include "public/platform/WebCompositorSupport.h" |
| 42 #include "public/platform/WebExternalBitmap.h" | 42 #include "public/platform/WebExternalBitmap.h" |
| 43 #include "public/platform/WebExternalTextureLayer.h" | 43 #include "public/platform/WebExternalTextureLayer.h" |
| 44 #include "public/platform/WebGraphicsContext3D.h" | 44 #include "public/platform/WebGraphicsContext3D.h" |
| 45 #include "public/platform/WebGraphicsContext3DProvider.h" | 45 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 46 #ifndef NDEBUG | 46 #ifndef NDEBUG |
| 47 #include "wtf/RefCountedLeakCounter.h" | 47 #include "wtf/RefCountedLeakCounter.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 using namespace std; | |
| 51 | |
| 52 namespace blink { | 50 namespace blink { |
| 53 | 51 |
| 54 namespace { | 52 namespace { |
| 55 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. | 53 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. |
| 56 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would | 54 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would |
| 57 // exceed the global cap will instead clear the buffer. | 55 // exceed the global cap will instead clear the buffer. |
| 58 const int s_maximumResourceUsePixels = 16 * 1024 * 1024; | 56 const int s_maximumResourceUsePixels = 16 * 1024 * 1024; |
| 59 int s_currentResourceUsePixels = 0; | 57 int s_currentResourceUsePixels = 0; |
| 60 const float s_resourceAdjustedRatio = 0.5; | 58 const float s_resourceAdjustedRatio = 0.5; |
| 61 | 59 |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 { | 750 { |
| 753 if (m_size == size) | 751 if (m_size == size) |
| 754 return; | 752 return; |
| 755 | 753 |
| 756 s_currentResourceUsePixels += pixelDelta(size, m_size); | 754 s_currentResourceUsePixels += pixelDelta(size, m_size); |
| 757 m_size = size; | 755 m_size = size; |
| 758 } | 756 } |
| 759 | 757 |
| 760 int DrawingBuffer::pixelDelta(const IntSize& newSize, const IntSize& curSize) | 758 int DrawingBuffer::pixelDelta(const IntSize& newSize, const IntSize& curSize) |
| 761 { | 759 { |
| 762 return (max(0, newSize.width()) * max(0, newSize.height())) - (max(0, curSiz
e.width()) * max(0, curSize.height())); | 760 return (std::max(0, newSize.width()) * std::max(0, newSize.height())) - (std
::max(0, curSize.width()) * std::max(0, curSize.height())); |
| 763 } | 761 } |
| 764 | 762 |
| 765 IntSize DrawingBuffer::adjustSize(const IntSize& desiredSize, const IntSize& cur
Size, int maxTextureSize) | 763 IntSize DrawingBuffer::adjustSize(const IntSize& desiredSize, const IntSize& cur
Size, int maxTextureSize) |
| 766 { | 764 { |
| 767 IntSize adjustedSize = desiredSize; | 765 IntSize adjustedSize = desiredSize; |
| 768 | 766 |
| 769 // Clamp if the desired size is greater than the maximum texture size for th
e device. | 767 // Clamp if the desired size is greater than the maximum texture size for th
e device. |
| 770 if (adjustedSize.height() > maxTextureSize) | 768 if (adjustedSize.height() > maxTextureSize) |
| 771 adjustedSize.setHeight(maxTextureSize); | 769 adjustedSize.setHeight(maxTextureSize); |
| 772 | 770 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1047 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 1050 { | 1048 { |
| 1051 if (info->imageId) { | 1049 if (info->imageId) { |
| 1052 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1050 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 1053 m_context->destroyImageCHROMIUM(info->imageId); | 1051 m_context->destroyImageCHROMIUM(info->imageId); |
| 1054 info->imageId = 0; | 1052 info->imageId = 0; |
| 1055 } | 1053 } |
| 1056 } | 1054 } |
| 1057 | 1055 |
| 1058 } // namespace blink | 1056 } // namespace blink |
| OLD | NEW |