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 "ui/gfx/android/java_bitmap.h" | 5 #include "ui/gfx/android/java_bitmap.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 format_ = info.format; | 30 format_ = info.format; |
31 stride_ = info.stride; | 31 stride_ = info.stride; |
32 byte_count_ = Java_BitmapHelper_getByteCount(AttachCurrentThread(), bitmap_); | 32 byte_count_ = Java_BitmapHelper_getByteCount(AttachCurrentThread(), bitmap_); |
33 } | 33 } |
34 | 34 |
35 JavaBitmap::~JavaBitmap() { | 35 JavaBitmap::~JavaBitmap() { |
36 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_); | 36 int err = AndroidBitmap_unlockPixels(AttachCurrentThread(), bitmap_); |
37 DCHECK(!err); | 37 DCHECK(!err); |
38 } | 38 } |
39 | 39 |
40 // static | |
41 bool JavaBitmap::RegisterJavaBitmap(JNIEnv* env) { | |
42 return RegisterNativesImpl(env); | |
43 } | |
44 | |
45 static int SkColorTypeToBitmapFormat(SkColorType color_type) { | 40 static int SkColorTypeToBitmapFormat(SkColorType color_type) { |
46 switch (color_type) { | 41 switch (color_type) { |
47 case kAlpha_8_SkColorType: | 42 case kAlpha_8_SkColorType: |
48 return BITMAP_FORMAT_ALPHA_8; | 43 return BITMAP_FORMAT_ALPHA_8; |
49 case kARGB_4444_SkColorType: | 44 case kARGB_4444_SkColorType: |
50 return BITMAP_FORMAT_ARGB_4444; | 45 return BITMAP_FORMAT_ARGB_4444; |
51 case kN32_SkColorType: | 46 case kN32_SkColorType: |
52 return BITMAP_FORMAT_ARGB_8888; | 47 return BITMAP_FORMAT_ARGB_8888; |
53 case kRGB_565_SkColorType: | 48 case kRGB_565_SkColorType: |
54 return BITMAP_FORMAT_RGB_565; | 49 return BITMAP_FORMAT_RGB_565; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return kN32_SkColorType; | 124 return kN32_SkColorType; |
130 case BITMAP_FORMAT_RGB_565: | 125 case BITMAP_FORMAT_RGB_565: |
131 return kRGB_565_SkColorType; | 126 return kRGB_565_SkColorType; |
132 case BITMAP_FORMAT_NO_CONFIG: | 127 case BITMAP_FORMAT_NO_CONFIG: |
133 default: | 128 default: |
134 return kUnknown_SkColorType; | 129 return kUnknown_SkColorType; |
135 } | 130 } |
136 } | 131 } |
137 | 132 |
138 } // namespace gfx | 133 } // namespace gfx |
OLD | NEW |