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 "ppapi/proxy/ppb_image_data_proxy.h" | 5 #include "ppapi/proxy/ppb_image_data_proxy.h" |
6 | 6 |
7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 PlatformImageData::~PlatformImageData() { | 385 PlatformImageData::~PlatformImageData() { |
386 } | 386 } |
387 | 387 |
388 void* PlatformImageData::Map() { | 388 void* PlatformImageData::Map() { |
389 if (!mapped_canvas_.get()) { | 389 if (!mapped_canvas_.get()) { |
390 if (!transport_dib_.get()) | 390 if (!transport_dib_.get()) |
391 return NULL; | 391 return NULL; |
392 | 392 |
393 const bool is_opaque = false; | 393 const bool is_opaque = false; |
394 mapped_canvas_ = | 394 mapped_canvas_.reset(transport_dib_->GetPlatformCanvas( |
395 sk_sp<SkCanvas>(transport_dib_->GetPlatformCanvas(desc_.size.width, | 395 desc_.size.width, desc_.size.height, is_opaque)); |
396 desc_.size.height, | |
397 is_opaque)); | |
398 if (!mapped_canvas_.get()) | 396 if (!mapped_canvas_.get()) |
399 return NULL; | 397 return NULL; |
400 } | 398 } |
401 SkPixmap pixmap; | 399 SkPixmap pixmap; |
402 skia::GetWritablePixels(mapped_canvas_.get(), &pixmap); | 400 skia::GetWritablePixels(mapped_canvas_.get(), &pixmap); |
403 return pixmap.writable_addr(); | 401 return pixmap.writable_addr(); |
404 } | 402 } |
405 | 403 |
406 void PlatformImageData::Unmap() { | 404 void PlatformImageData::Unmap() { |
407 // TODO(brettw) have a way to unmap a TransportDIB. Currently this isn't | 405 // TODO(brettw) have a way to unmap a TransportDIB. Currently this isn't |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // still cached in our process, the proxy still holds a reference so we can | 671 // still cached in our process, the proxy still holds a reference so we can |
674 // remove the one the renderer just sent is. If the proxy no longer holds a | 672 // remove the one the renderer just sent is. If the proxy no longer holds a |
675 // reference, we released everything and we should also release the one the | 673 // reference, we released everything and we should also release the one the |
676 // renderer just sent us. | 674 // renderer just sent us. |
677 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 675 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
678 API_ID_PPB_CORE, old_image_data)); | 676 API_ID_PPB_CORE, old_image_data)); |
679 } | 677 } |
680 | 678 |
681 } // namespace proxy | 679 } // namespace proxy |
682 } // namespace ppapi | 680 } // namespace ppapi |
OLD | NEW |