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

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

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt Created 6 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 | « src/core/SkBitmap.cpp ('k') | src/core/SkBitmapProcState.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) 64 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
65 : SkBaseDevice(deviceProperties) 65 : SkBaseDevice(deviceProperties)
66 , fBitmap(bitmap) 66 , fBitmap(bitmap)
67 { 67 {
68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL)); 68 SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
69 } 69 }
70 70
71 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, 71 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
72 const SkDeviceProperties* props) { 72 const SkDeviceProperties* props) {
73 SkImageInfo info = origInfo; 73 SkAlphaType newAT = origInfo.alphaType();
74 if (!valid_for_bitmap_device(info, &info.fAlphaType)) { 74 if (!valid_for_bitmap_device(origInfo, &newAT)) {
75 return NULL; 75 return NULL;
76 } 76 }
77 77
78 const SkImageInfo info = origInfo.makeAlphaType(newAT);
78 SkBitmap bitmap; 79 SkBitmap bitmap;
79 80
80 if (kUnknown_SkColorType == info.colorType()) { 81 if (kUnknown_SkColorType == info.colorType()) {
81 if (!bitmap.setInfo(info)) { 82 if (!bitmap.setInfo(info)) {
82 return NULL; 83 return NULL;
83 } 84 }
84 } else { 85 } else {
85 if (!bitmap.tryAllocPixels(info)) { 86 if (!bitmap.tryAllocPixels(info)) {
86 return NULL; 87 return NULL;
87 } 88 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 #include "SkConfig8888.h" 145 #include "SkConfig8888.h"
145 146
146 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels, 147 bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi xels,
147 size_t srcRowBytes, int x, int y) { 148 size_t srcRowBytes, int x, int y) {
148 // since we don't stop creating un-pixeled devices yet, check for no pixels here 149 // since we don't stop creating un-pixeled devices yet, check for no pixels here
149 if (NULL == fBitmap.getPixels()) { 150 if (NULL == fBitmap.getPixels()) {
150 return false; 151 return false;
151 } 152 }
152 153
153 SkImageInfo dstInfo = fBitmap.info(); 154 const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.h eight());
154 dstInfo.fWidth = srcInfo.width();
155 dstInfo.fHeight = srcInfo.height();
156 155
157 void* dstPixels = fBitmap.getAddr(x, y); 156 void* dstPixels = fBitmap.getAddr(x, y);
158 size_t dstRowBytes = fBitmap.rowBytes(); 157 size_t dstRowBytes = fBitmap.rowBytes();
159 158
160 if (SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPix els, srcRowBytes)) { 159 if (SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPix els, srcRowBytes)) {
161 fBitmap.notifyPixelsChanged(); 160 fBitmap.notifyPixelsChanged();
162 return true; 161 return true;
163 } 162 }
164 return false; 163 return false;
165 } 164 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 paint.getStyle() != SkPaint::kFill_Style || 387 paint.getStyle() != SkPaint::kFill_Style ||
389 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 388 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
390 // turn off lcd 389 // turn off lcd
391 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 390 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
392 flags->fHinting = paint.getHinting(); 391 flags->fHinting = paint.getHinting();
393 return true; 392 return true;
394 } 393 }
395 // we're cool with the paint as is 394 // we're cool with the paint as is
396 return false; 395 return false;
397 } 396 }
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698