OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 ImageBuffer::~ImageBuffer() | 98 ImageBuffer::~ImageBuffer() |
99 { | 99 { |
100 if (m_gpuMemoryUsage) { | 100 if (m_gpuMemoryUsage) { |
101 DCHECK_GT(s_globalAcceleratedImageBufferCount, 0u); | 101 DCHECK_GT(s_globalAcceleratedImageBufferCount, 0u); |
102 s_globalAcceleratedImageBufferCount--; | 102 s_globalAcceleratedImageBufferCount--; |
103 } | 103 } |
104 ImageBuffer::s_globalGPUMemoryUsage -= m_gpuMemoryUsage; | 104 ImageBuffer::s_globalGPUMemoryUsage -= m_gpuMemoryUsage; |
105 } | 105 } |
106 | 106 |
| 107 bool ImageBuffer::canCreateImageBuffer(const IntSize& size) |
| 108 { |
| 109 if (size.isEmpty()) |
| 110 return false; |
| 111 CheckedNumeric<int> area = size.width(); |
| 112 area *= size.height(); |
| 113 if (!area.IsValid() || area.ValueOrDie() > MaxCanvasArea) |
| 114 return false; |
| 115 if (size.width() > MaxSkiaDim || size.height() > MaxSkiaDim) |
| 116 return false; |
| 117 return true; |
| 118 } |
| 119 |
107 SkCanvas* ImageBuffer::canvas() const | 120 SkCanvas* ImageBuffer::canvas() const |
108 { | 121 { |
109 return m_surface->canvas(); | 122 return m_surface->canvas(); |
110 } | 123 } |
111 | 124 |
112 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const | 125 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const |
113 { | 126 { |
114 return m_surface->disableDeferral(reason); | 127 return m_surface->disableDeferral(reason); |
115 } | 128 } |
116 | 129 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 477 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
465 | 478 |
466 Vector<unsigned char> result; | 479 Vector<unsigned char> result; |
467 if (!encodeImage(mimeType, quality, &result)) | 480 if (!encodeImage(mimeType, quality, &result)) |
468 return "data:,"; | 481 return "data:,"; |
469 | 482 |
470 return "data:" + mimeType + ";base64," + base64Encode(result); | 483 return "data:" + mimeType + ";base64," + base64Encode(result); |
471 } | 484 } |
472 | 485 |
473 } // namespace blink | 486 } // namespace blink |
OLD | NEW |