Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: skia/ext/bitmap_platform_device_android.cc

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « skia/ext/bitmap_platform_device_android.h ('k') | skia/ext/bitmap_platform_device_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "skia/ext/bitmap_platform_device_android.h" 5 #include "skia/ext/bitmap_platform_device_android.h"
6 #include "skia/ext/platform_canvas.h" 6 #include "skia/ext/platform_canvas.h"
7 7
8 namespace skia { 8 namespace skia {
9 9
10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height, 10 BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
(...skipping 28 matching lines...) Expand all
39 if (data) 39 if (data)
40 bitmap.setPixels(data); 40 bitmap.setPixels(data);
41 else if (!bitmap.allocPixels()) 41 else if (!bitmap.allocPixels())
42 return NULL; 42 return NULL;
43 43
44 bitmap.setIsOpaque(is_opaque); 44 bitmap.setIsOpaque(is_opaque);
45 return new BitmapPlatformDevice(bitmap); 45 return new BitmapPlatformDevice(bitmap);
46 } 46 }
47 47
48 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap) 48 BitmapPlatformDevice::BitmapPlatformDevice(const SkBitmap& bitmap)
49 : SkDevice(bitmap) { 49 : SkBitmapDevice(bitmap) {
50 SetPlatformDevice(this, this); 50 SetPlatformDevice(this, this);
51 } 51 }
52 52
53 BitmapPlatformDevice::~BitmapPlatformDevice() { 53 BitmapPlatformDevice::~BitmapPlatformDevice() {
54 } 54 }
55 55
56 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( 56 SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
57 SkBitmap::Config config, int width, int height, bool isOpaque, 57 SkBitmap::Config config, int width, int height, bool isOpaque,
58 Usage /*usage*/) { 58 Usage /*usage*/) {
59 SkASSERT(config == SkBitmap::kARGB_8888_Config); 59 SkASSERT(config == SkBitmap::kARGB_8888_Config);
60 return BitmapPlatformDevice::Create(width, height, isOpaque); 60 return BitmapPlatformDevice::Create(width, height, isOpaque);
61 } 61 }
62 62
63 PlatformSurface BitmapPlatformDevice::BeginPlatformPaint() { 63 PlatformSurface BitmapPlatformDevice::BeginPlatformPaint() {
64 // TODO(zhenghao): What should we return? The ptr to the address of the 64 // TODO(zhenghao): What should we return? The ptr to the address of the
65 // pixels? Maybe this won't be called at all. 65 // pixels? Maybe this won't be called at all.
66 return accessBitmap(true).getPixels(); 66 return accessBitmap(true).getPixels();
67 } 67 }
68 68
69 void BitmapPlatformDevice::DrawToNativeContext( 69 void BitmapPlatformDevice::DrawToNativeContext(
70 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { 70 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) {
71 // Should never be called on Android. 71 // Should never be called on Android.
72 SkASSERT(false); 72 SkASSERT(false);
73 } 73 }
74 74
75 // PlatformCanvas impl 75 // PlatformCanvas impl
76 76
77 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, 77 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque,
78 uint8_t* data, OnFailureType failureType) { 78 uint8_t* data, OnFailureType failureType) {
79 skia::RefPtr<SkDevice> dev = skia::AdoptRef( 79 skia::RefPtr<SkBaseDevice> dev = skia::AdoptRef(
80 BitmapPlatformDevice::Create(width, height, is_opaque, data)); 80 BitmapPlatformDevice::Create(width, height, is_opaque, data));
81 return CreateCanvas(dev, failureType); 81 return CreateCanvas(dev, failureType);
82 } 82 }
83 83
84 // Port of PlatformBitmap to android 84 // Port of PlatformBitmap to android
85 PlatformBitmap::~PlatformBitmap() { 85 PlatformBitmap::~PlatformBitmap() {
86 // Nothing to do. 86 // Nothing to do.
87 } 87 }
88 88
89 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { 89 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
90 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height); 90 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
91 if (!bitmap_.allocPixels()) 91 if (!bitmap_.allocPixels())
92 return false; 92 return false;
93 93
94 bitmap_.setIsOpaque(is_opaque); 94 bitmap_.setIsOpaque(is_opaque);
95 surface_ = bitmap_.getPixels(); 95 surface_ = bitmap_.getPixels();
96 return true; 96 return true;
97 } 97 }
98 98
99 } // namespace skia 99 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_android.h ('k') | skia/ext/bitmap_platform_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698