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

Side by Side Diff: src/core/SkDevice.cpp

Issue 143073008: add installPixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkMallocPixelRef.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkMetaData.h" 10 #include "SkMetaData.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap->width(), 85 SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap->width(),
86 bitmap->height()); 86 bitmap->height());
87 SkIRect devbounds = SkIRect::MakeWH(src.width(), src.height()); 87 SkIRect devbounds = SkIRect::MakeWH(src.width(), src.height());
88 if (!srcRect.intersect(devbounds)) { 88 if (!srcRect.intersect(devbounds)) {
89 return false; 89 return false;
90 } 90 }
91 91
92 SkBitmap tmp; 92 SkBitmap tmp;
93 SkBitmap* bmp; 93 SkBitmap* bmp;
94 if (bitmap->isNull()) { 94 if (bitmap->isNull()) {
95 tmp.setConfig(SkBitmap::kARGB_8888_Config, bitmap->width(), 95 if (!tmp.allocPixels(SkImageInfo::MakeN32Premul(bitmap->width(),
96 bitmap->height()); 96 bitmap->height()))) {
97 if (!tmp.allocPixels()) {
98 return false; 97 return false;
99 } 98 }
100 bmp = &tmp; 99 bmp = &tmp;
101 } else { 100 } else {
102 bmp = bitmap; 101 bmp = bitmap;
103 } 102 }
104 103
105 SkIRect subrect = srcRect; 104 SkIRect subrect = srcRect;
106 subrect.offset(-x, -y); 105 subrect.offset(-x, -y);
107 SkBitmap bmpSubset; 106 SkBitmap bmpSubset;
108 bmp->extractSubset(&bmpSubset, subrect); 107 bmp->extractSubset(&bmpSubset, subrect);
109 108
110 bool result = this->onReadPixels(bmpSubset, 109 bool result = this->onReadPixels(bmpSubset,
111 srcRect.fLeft, 110 srcRect.fLeft,
112 srcRect.fTop, 111 srcRect.fTop,
113 config8888); 112 config8888);
114 if (result && bmp == &tmp) { 113 if (result && bmp == &tmp) {
115 tmp.swap(*bitmap); 114 tmp.swap(*bitmap);
116 } 115 }
117 return result; 116 return result;
118 } 117 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkMallocPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698