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

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

Issue 163823002: Revert of add peekPixels to SkCanvas and SkSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « samplecode/SampleLayers.cpp ('k') | src/core/SkCanvas.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque, 47 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque,
48 const SkDeviceProperties& deviceProperties) 48 const SkDeviceProperties& deviceProperties)
49 : SkBaseDevice(deviceProperties) 49 : SkBaseDevice(deviceProperties)
50 { 50 {
51 this->init(config, width, height, isOpaque); 51 this->init(config, width, height, isOpaque);
52 } 52 }
53 53
54 SkBitmapDevice::~SkBitmapDevice() { 54 SkBitmapDevice::~SkBitmapDevice() {
55 } 55 }
56 56
57 SkImageInfo SkBitmapDevice::imageInfo() const {
58 return fBitmap.info();
59 }
60
61 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 57 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
62 SkASSERT(bm.width() == fBitmap.width()); 58 SkASSERT(bm.width() == fBitmap.width());
63 SkASSERT(bm.height() == fBitmap.height()); 59 SkASSERT(bm.height() == fBitmap.height());
64 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 60 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
65 fBitmap.lockPixels(); 61 fBitmap.lockPixels();
66 } 62 }
67 63
68 SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(SkBitmap::Config config, 64 SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(SkBitmap::Config config,
69 int width, int height, 65 int width, int height,
70 bool isOpaque, 66 bool isOpaque,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 379 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
384 int x, int y, const SkPaint& paint) { 380 int x, int y, const SkPaint& paint) {
385 const SkBitmap& src = device->accessBitmap(false); 381 const SkBitmap& src = device->accessBitmap(false);
386 draw.drawSprite(src, x, y, paint); 382 draw.drawSprite(src, x, y, paint);
387 } 383 }
388 384
389 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) { 385 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) {
390 return SkSurface::NewRaster(info); 386 return SkSurface::NewRaster(info);
391 } 387 }
392 388
393 const void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) {
394 if (fBitmap.getPixels() && fBitmap.asImageInfo(info)) {
395 if (rowBytes) {
396 *rowBytes = fBitmap.rowBytes();
397 }
398 return fBitmap.getPixels();
399 }
400 return NULL;
401 }
402
403 /////////////////////////////////////////////////////////////////////////////// 389 ///////////////////////////////////////////////////////////////////////////////
404 390
405 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { 391 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
406 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { 392 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
407 // we're cool with the paint as is 393 // we're cool with the paint as is
408 return false; 394 return false;
409 } 395 }
410 396
411 if (SkBitmap::kARGB_8888_Config != fBitmap.config() || 397 if (SkBitmap::kARGB_8888_Config != fBitmap.config() ||
412 paint.getRasterizer() || 398 paint.getRasterizer() ||
413 paint.getPathEffect() || 399 paint.getPathEffect() ||
414 paint.isFakeBoldText() || 400 paint.isFakeBoldText() ||
415 paint.getStyle() != SkPaint::kFill_Style || 401 paint.getStyle() != SkPaint::kFill_Style ||
416 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 402 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
417 // turn off lcd 403 // turn off lcd
418 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 404 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
419 flags->fHinting = paint.getHinting(); 405 flags->fHinting = paint.getHinting();
420 return true; 406 return true;
421 } 407 }
422 // we're cool with the paint as is 408 // we're cool with the paint as is
423 return false; 409 return false;
424 } 410 }
OLDNEW
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698