| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // These values come from the WhatWG spec. | 39 // These values come from the WhatWG spec. |
| 40 const int CanvasSurface::DefaultWidth = 300; | 40 const int CanvasSurface::DefaultWidth = 300; |
| 41 const int CanvasSurface::DefaultHeight = 150; | 41 const int CanvasSurface::DefaultHeight = 150; |
| 42 | 42 |
| 43 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it | 43 // Firefox limits width/height to 32767 pixels, but slows down dramatically befo
re it |
| 44 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, | 44 // reaches that limit. We limit by area instead, giving us larger maximum dimens
ions, |
| 45 // in exchange for a smaller maximum canvas size. | 45 // in exchange for a smaller maximum canvas size. |
| 46 const float CanvasSurface::MaxCanvasArea = 32768 * 8192; // Maximum canvas area
in CSS pixels | 46 const float CanvasSurface::MaxCanvasArea = 32768 * 8192; // Maximum canvas area
in CSS pixels |
| 47 | 47 |
| 48 #if PLATFORM(SKIA) |
| 49 // In Skia, we will also limit width/height to 32767. |
| 50 const float CanvasSurface::MaxSkiaDim = 32767.0F; // Maximum width/height in CSS
pixels. |
| 51 #endif |
| 52 |
| 48 CanvasSurface::CanvasSurface(float pageScaleFactor) | 53 CanvasSurface::CanvasSurface(float pageScaleFactor) |
| 49 : m_size(DefaultWidth, DefaultHeight) | 54 : m_size(DefaultWidth, DefaultHeight) |
| 50 , m_pageScaleFactor(pageScaleFactor) | 55 , m_pageScaleFactor(pageScaleFactor) |
| 51 , m_originClean(true) | 56 , m_originClean(true) |
| 52 , m_hasCreatedImageBuffer(false) | 57 , m_hasCreatedImageBuffer(false) |
| 53 { | 58 { |
| 54 } | 59 } |
| 55 | 60 |
| 56 CanvasSurface::~CanvasSurface() | 61 CanvasSurface::~CanvasSurface() |
| 57 { | 62 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 98 } |
| 94 | 99 |
| 95 IntSize CanvasSurface::convertLogicalToDevice(const FloatSize& logicalSize) cons
t | 100 IntSize CanvasSurface::convertLogicalToDevice(const FloatSize& logicalSize) cons
t |
| 96 { | 101 { |
| 97 float wf = ceilf(logicalSize.width() * m_pageScaleFactor); | 102 float wf = ceilf(logicalSize.width() * m_pageScaleFactor); |
| 98 float hf = ceilf(logicalSize.height() * m_pageScaleFactor); | 103 float hf = ceilf(logicalSize.height() * m_pageScaleFactor); |
| 99 | 104 |
| 100 if (!(wf >= 1 && hf >= 1 && wf * hf <= MaxCanvasArea)) | 105 if (!(wf >= 1 && hf >= 1 && wf * hf <= MaxCanvasArea)) |
| 101 return IntSize(); | 106 return IntSize(); |
| 102 | 107 |
| 108 #if PLATFORM(SKIA) |
| 109 if (wf > MaxSkiaDim || hf > MaxSkiaDim) |
| 110 return IntSize(); |
| 111 #endif |
| 112 |
| 103 return IntSize(static_cast<unsigned>(wf), static_cast<unsigned>(hf)); | 113 return IntSize(static_cast<unsigned>(wf), static_cast<unsigned>(hf)); |
| 104 } | 114 } |
| 105 | 115 |
| 106 IntPoint CanvasSurface::convertLogicalToDevice(const FloatPoint& logicalPos) con
st | 116 IntPoint CanvasSurface::convertLogicalToDevice(const FloatPoint& logicalPos) con
st |
| 107 { | 117 { |
| 108 float xf = logicalPos.x() * m_pageScaleFactor; | 118 float xf = logicalPos.x() * m_pageScaleFactor; |
| 109 float yf = logicalPos.y() * m_pageScaleFactor; | 119 float yf = logicalPos.y() * m_pageScaleFactor; |
| 110 | 120 |
| 111 return IntPoint(static_cast<unsigned>(xf), static_cast<unsigned>(yf)); | 121 return IntPoint(static_cast<unsigned>(xf), static_cast<unsigned>(yf)); |
| 112 } | 122 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 { | 181 { |
| 172 return static_cast<HTMLCanvasElement*>(this)->computedStyle(); | 182 return static_cast<HTMLCanvasElement*>(this)->computedStyle(); |
| 173 } | 183 } |
| 174 | 184 |
| 175 CSSStyleSelector* CanvasSurface::styleSelector() | 185 CSSStyleSelector* CanvasSurface::styleSelector() |
| 176 { | 186 { |
| 177 return static_cast<HTMLCanvasElement*>(this)->document()->styleSelector(); | 187 return static_cast<HTMLCanvasElement*>(this)->document()->styleSelector(); |
| 178 } | 188 } |
| 179 | 189 |
| 180 } // namespace WebCore | 190 } // namespace WebCore |
| OLD | NEW |