| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/examples/bitmap_uploader/bitmap_uploader.h" | 5 #include "mojo/examples/bitmap_uploader/bitmap_uploader.h" |
| 6 | 6 |
| 7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
| 8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
| 9 #endif // GL_GLEXT_PROTOTYPES | 9 #endif // GL_GLEXT_PROTOTYPES |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Upload(); | 77 Upload(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void BitmapUploader::SetBitmap(const SkBitmap& bitmap) { | 80 void BitmapUploader::SetBitmap(const SkBitmap& bitmap) { |
| 81 bitmap_ = bitmap; | 81 bitmap_ = bitmap; |
| 82 if (surface_) | 82 if (surface_) |
| 83 Upload(); | 83 Upload(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void BitmapUploader::Upload() { | 86 void BitmapUploader::Upload() { |
| 87 const gfx::Size& size(view_->bounds().size()); | 87 const gfx::Size size(view_->bounds().width, view_->bounds().height); |
| 88 if (size.IsEmpty()) { | 88 if (size.IsEmpty()) { |
| 89 view_->SetSurfaceId(SurfaceId::New()); | 89 view_->SetSurfaceId(SurfaceId::New()); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 if (!surface_) // Can't upload yet, store for later. | 92 if (!surface_) // Can't upload yet, store for later. |
| 93 return; | 93 return; |
| 94 if (id_.is_null() || size != surface_size_) { | 94 if (id_.is_null() || size != surface_size_) { |
| 95 if (!id_.is_null()) | 95 if (!id_.is_null()) |
| 96 surface_->DestroySurface(SurfaceId::From(id_)); | 96 surface_->DestroySurface(SurfaceId::From(id_)); |
| 97 id_ = id_allocator_->GenerateId(); | 97 id_ = id_allocator_->GenerateId(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 size.height(), | 224 size.height(), |
| 225 0, | 225 0, |
| 226 TextureFormat(), | 226 TextureFormat(), |
| 227 GL_UNSIGNED_BYTE, | 227 GL_UNSIGNED_BYTE, |
| 228 0); | 228 0); |
| 229 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 229 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 230 return texture; | 230 return texture; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace mojo | 233 } // namespace mojo |
| OLD | NEW |