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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 ImageBuffer::~ImageBuffer() | 92 ImageBuffer::~ImageBuffer() |
93 { | 93 { |
94 } | 94 } |
95 | 95 |
96 GraphicsContext* ImageBuffer::context() const | 96 GraphicsContext* ImageBuffer::context() const |
97 { | 97 { |
98 if (!isSurfaceValid()) | 98 if (!isSurfaceValid()) |
99 return 0; | 99 return 0; |
100 m_surface->willUse(); | |
101 ASSERT(m_context.get()); | 100 ASSERT(m_context.get()); |
102 return m_context.get(); | 101 return m_context.get(); |
103 } | 102 } |
104 | 103 |
105 const SkBitmap& ImageBuffer::bitmap() const | 104 const SkBitmap& ImageBuffer::bitmap() const |
106 { | 105 { |
107 m_surface->willUse(); | 106 m_surface->didDraw(); // conservative |
108 return m_surface->bitmap(); | 107 return m_surface->bitmap(); |
109 } | 108 } |
110 | 109 |
111 bool ImageBuffer::isSurfaceValid() const | 110 bool ImageBuffer::isSurfaceValid() const |
112 { | 111 { |
113 return m_surface->isValid(); | 112 return m_surface->isValid(); |
114 } | 113 } |
115 | 114 |
116 bool ImageBuffer::restoreSurface() const | 115 bool ImageBuffer::restoreSurface() const |
117 { | 116 { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 421 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
423 return "data:,"; | 422 return "data:,"; |
424 | 423 |
425 Vector<char> base64Data; | 424 Vector<char> base64Data; |
426 base64Encode(encodedImage, base64Data); | 425 base64Encode(encodedImage, base64Data); |
427 | 426 |
428 return "data:" + mimeType + ";base64," + base64Data; | 427 return "data:" + mimeType + ";base64," + base64Data; |
429 } | 428 } |
430 | 429 |
431 } // namespace blink | 430 } // namespace blink |
OLD | NEW |