| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cassert> | 7 #include <cassert> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // This is called by the browser when the 2D context has been flushed to the | 27 // This is called by the browser when the 2D context has been flushed to the |
| 28 // browser window. | 28 // browser window. |
| 29 void FlushCallback(void* data, int32_t result) { | 29 void FlushCallback(void* data, int32_t result) { |
| 30 static_cast<pi_generator::PiGenerator*>(data)->set_flush_pending(false); | 30 static_cast<pi_generator::PiGenerator*>(data)->set_flush_pending(false); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 namespace pi_generator { | 35 namespace pi_generator { |
| 36 | 36 |
| 37 // A small helper RAII class that implementes a scoped pthread_mutex lock. | 37 // A small helper RAII class that implements a scoped pthread_mutex lock. |
| 38 class ScopedMutexLock { | 38 class ScopedMutexLock { |
| 39 public: | 39 public: |
| 40 explicit ScopedMutexLock(pthread_mutex_t* mutex) : mutex_(mutex) { | 40 explicit ScopedMutexLock(pthread_mutex_t* mutex) : mutex_(mutex) { |
| 41 if (pthread_mutex_lock(mutex_) != kPthreadMutexSuccess) { | 41 if (pthread_mutex_lock(mutex_) != kPthreadMutexSuccess) { |
| 42 mutex_ = NULL; | 42 mutex_ = NULL; |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 ~ScopedMutexLock() { | 45 ~ScopedMutexLock() { |
| 46 if (mutex_) | 46 if (mutex_) |
| 47 pthread_mutex_unlock(mutex_); | 47 pthread_mutex_unlock(mutex_); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Set color to red. | 233 // Set color to red. |
| 234 color += 4 << kRedShift; | 234 color += 4 << kRedShift; |
| 235 color &= kRedMask; | 235 color &= kRedMask; |
| 236 } | 236 } |
| 237 pixel_bits[pi_generator->width() * py + px] = color | kOpaqueColorMask; | 237 pixel_bits[pi_generator->width() * py + px] = color | kOpaqueColorMask; |
| 238 } | 238 } |
| 239 return 0; | 239 return 0; |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace pi_generator | 242 } // namespace pi_generator |
| OLD | NEW |