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

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

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
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"
11 #include "SkRasterClip.h" 11 #include "SkRasterClip.h"
12 #include "SkShader.h" 12 #include "SkShader.h"
13 13
14 SK_DEFINE_INST_COUNT(SkBitmapDevice) 14 SK_DEFINE_INST_COUNT(SkBitmapDevice)
15 15
16 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \ 16 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \
17 do { if (paint.isNoDrawAnnotation()) { return; } } while (0) 17 do { if (paint.isNoDrawAnnotation()) { return; } } while (0)
18 18
19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) 19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
20 : fBitmap(bitmap) { 20 : fBitmap(bitmap) {
21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); 21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config());
22 } 22 }
23 23
24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) 24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
25 : SkBaseDevice(deviceProperties) 25 : SkBaseDevice(deviceProperties)
26 , fBitmap(bitmap) { 26 , fBitmap(bitmap) {
27 } 27 }
28 28
29 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque) { 29 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque) {
30 fBitmap.setConfig(config, width, height); 30 fBitmap.setConfig(config, width, height, 0, isOpaque ?
scroggo 2013/10/18 19:32:40 Should we update the parameter? Maybe in the futur
31 kOpaque_SkAlphaType : kPremul_SkAlphaType);
31 fBitmap.allocPixels(); 32 fBitmap.allocPixels();
32 fBitmap.setIsOpaque(isOpaque);
33 if (!isOpaque) { 33 if (!isOpaque) {
34 fBitmap.eraseColor(SK_ColorTRANSPARENT); 34 fBitmap.eraseColor(SK_ColorTRANSPARENT);
35 } 35 }
36 } 36 }
37 37
38 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque, 38 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque,
39 const SkDeviceProperties& deviceProperties) 39 const SkDeviceProperties& deviceProperties)
40 : SkBaseDevice(deviceProperties) { 40 : SkBaseDevice(deviceProperties) {
41 41
42 fBitmap.setConfig(config, width, height); 42 fBitmap.setConfig(config, width, height, 0, isOpaque ?
43 kOpaque_SkAlphaType : kPremul_SkAlphaType);
43 fBitmap.allocPixels(); 44 fBitmap.allocPixels();
44 fBitmap.setIsOpaque(isOpaque);
45 if (!isOpaque) { 45 if (!isOpaque) {
46 fBitmap.eraseColor(SK_ColorTRANSPARENT); 46 fBitmap.eraseColor(SK_ColorTRANSPARENT);
47 } 47 }
48 } 48 }
49 49
50 SkBitmapDevice::~SkBitmapDevice() { 50 SkBitmapDevice::~SkBitmapDevice() {
51 } 51 }
52 52
53 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 53 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
54 SkASSERT(bm.width() == fBitmap.width()); 54 SkASSERT(bm.width() == fBitmap.width());
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 paint.getStyle() != SkPaint::kFill_Style || 400 paint.getStyle() != SkPaint::kFill_Style ||
401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
402 // turn off lcd 402 // turn off lcd
403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
404 flags->fHinting = paint.getHinting(); 404 flags->fHinting = paint.getHinting();
405 return true; 405 return true;
406 } 406 }
407 // we're cool with the paint as is 407 // we're cool with the paint as is
408 return false; 408 return false;
409 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698