| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Google, Inc. | 3 * Copyright (C) 2008, 2009 Google, Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 void ImageFrame::ZeroFillPixelData() { | 77 void ImageFrame::ZeroFillPixelData() { |
| 78 bitmap_.eraseARGB(0, 0, 0, 0); | 78 bitmap_.eraseARGB(0, 0, 0, 0); |
| 79 has_alpha_ = true; | 79 has_alpha_ = true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool ImageFrame::CopyBitmapData(const ImageFrame& other) { | 82 bool ImageFrame::CopyBitmapData(const ImageFrame& other) { |
| 83 DCHECK_NE(this, &other); | 83 DCHECK_NE(this, &other); |
| 84 has_alpha_ = other.has_alpha_; | 84 has_alpha_ = other.has_alpha_; |
| 85 bitmap_.reset(); | 85 bitmap_.reset(); |
| 86 return other.bitmap_.copyTo(&bitmap_, other.bitmap_.colorType()); | 86 SkImageInfo info = other.bitmap_.info(); |
| 87 return bitmap_.tryAllocPixels(info) && |
| 88 other.bitmap_.readPixels(info, bitmap_.getPixels(), bitmap_.rowBytes(), |
| 89 0, 0); |
| 87 } | 90 } |
| 88 | 91 |
| 89 bool ImageFrame::TakeBitmapDataIfWritable(ImageFrame* other) { | 92 bool ImageFrame::TakeBitmapDataIfWritable(ImageFrame* other) { |
| 90 DCHECK(other); | 93 DCHECK(other); |
| 91 DCHECK_EQ(kFrameComplete, other->status_); | 94 DCHECK_EQ(kFrameComplete, other->status_); |
| 92 DCHECK_EQ(kFrameEmpty, status_); | 95 DCHECK_EQ(kFrameEmpty, status_); |
| 93 DCHECK_NE(this, other); | 96 DCHECK_NE(this, other); |
| 94 if (other->bitmap_.isImmutable()) | 97 if (other->bitmap_.isImmutable()) |
| 95 return false; | 98 return false; |
| 96 has_alpha_ = other->has_alpha_; | 99 has_alpha_ = other->has_alpha_; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // If the frame is not fully loaded, there will be transparent pixels, | 202 // If the frame is not fully loaded, there will be transparent pixels, |
| 200 // so we can't tell skia we're opaque, even for image types that logically | 203 // so we can't tell skia we're opaque, even for image types that logically |
| 201 // always are (e.g. jpeg). | 204 // always are (e.g. jpeg). |
| 202 if (!has_alpha_ && status_ == kFrameComplete) | 205 if (!has_alpha_ && status_ == kFrameComplete) |
| 203 return kOpaque_SkAlphaType; | 206 return kOpaque_SkAlphaType; |
| 204 | 207 |
| 205 return premultiply_alpha_ ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 208 return premultiply_alpha_ ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| 206 } | 209 } |
| 207 | 210 |
| 208 } // namespace blink | 211 } // namespace blink |
| OLD | NEW |