Skip to content

Commit

Permalink
Remove PlatformCanvas::GetBitmapContext()
Browse files Browse the repository at this point in the history
This API is only used from ~CanvasSkiaPaint(), and is similar in behavior
to ScopedPlatformPaint::GetNativeDrawingContext().

Refactor the only client to use the latter, get rid of the GetBitmapContext()
virtual and platform_device_foo stubs.

BUG=675977
R=reed@google.com
TBR=danakj@chromium.org

Review-Url: https://codereview.chromium.org/2607603004
Cr-Commit-Position: refs/heads/master@{#441127}
  • Loading branch information
fmalita authored and Commit bot committed Jan 3, 2017
1 parent 6fa5a21 commit 6b76da0
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 91 deletions.
4 changes: 0 additions & 4 deletions skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ component("skia") {
"ext/image_operations.cc",
"ext/opacity_filter_canvas.cc",
"ext/platform_device.cc",
"ext/platform_device_linux.cc",
"ext/platform_device_mac.cc",
"ext/platform_device_win.cc",
"ext/recursive_gaussian_convolution.cc",
"ext/skia_histogram.cc",
"ext/skia_memory_dump_provider.cc",
Expand Down Expand Up @@ -420,7 +417,6 @@ component("skia") {

if (is_android) {
set_sources_assignment_filter([])
sources += [ "ext/platform_device_linux.cc" ]
set_sources_assignment_filter(sources_assignment_filter)
deps += [
"//third_party/android_tools:cpu_features",
Expand Down
5 changes: 3 additions & 2 deletions skia/ext/bitmap_platform_device_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ BitmapPlatformDevice::~BitmapPlatformDevice() {
CGContextRelease(bitmap_context_);
}

CGContextRef BitmapPlatformDevice::GetBitmapContext(const SkMatrix& transform,
const SkIRect& clip_bounds) {
NativeDrawingContext BitmapPlatformDevice::BeginPlatformPaint(
const SkMatrix& transform,
const SkIRect& clip_bounds) {
LoadConfig(transform, clip_bounds);
return bitmap_context_;
}
Expand Down
7 changes: 3 additions & 4 deletions skia/ext/bitmap_platform_device_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice

~BitmapPlatformDevice() override;

// PlatformDevice overrides
CGContextRef GetBitmapContext(const SkMatrix& transform,
const SkIRect& clip_bounds) override;

protected:
BitmapPlatformDevice(CGContextRef context,
const SkBitmap& bitmap);

SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;

private:
NativeDrawingContext BeginPlatformPaint(const SkMatrix& transform,
const SkIRect& clip_bounds) override;

void ReleaseBitmapContext();

// Loads the current transform and clip into the context. Can be called even
Expand Down
12 changes: 0 additions & 12 deletions skia/ext/platform_canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,6 @@ void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) {
bool IsPreviewMetafile(const SkCanvas& canvas) {
return GetBoolMetaData(canvas, kIsPreviewMetafileKey);
}

CGContextRef GetBitmapContext(const SkCanvas& canvas) {
PlatformDevice* platform_device =
GetPlatformDevice(canvas.getTopDevice(true));
SkIRect clip_bounds;
canvas.getClipDeviceBounds(&clip_bounds);
return platform_device ?
platform_device->GetBitmapContext(
canvas.getTotalMatrix(), clip_bounds) :
nullptr;
}

#endif

ScopedPlatformPaint::ScopedPlatformPaint(SkCanvas* canvas) :
Expand Down
4 changes: 0 additions & 4 deletions skia/ext/platform_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ SK_API SkMetaData& GetMetaData(const SkCanvas& canvas);
#if defined(OS_MACOSX)
SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview);
SK_API bool IsPreviewMetafile(const SkCanvas& canvas);

// Returns the CGContext that backing the SkCanvas.
// Returns NULL if none is bound.
SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas);
#endif

} // namespace skia
Expand Down
2 changes: 2 additions & 0 deletions skia/ext/platform_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ PlatformDevice* GetPlatformDevice(SkBaseDevice* device) {
return NULL;
}

PlatformDevice::~PlatformDevice() {}

} // namespace skia
17 changes: 2 additions & 15 deletions skia/ext/platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#include <vector>
#endif

#include "skia/ext/native_drawing_context.h"
#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkTypes.h"
Expand Down Expand Up @@ -50,22 +45,14 @@ SK_API PlatformDevice* GetPlatformDevice(SkBaseDevice* device);
// from it.
class SK_API PlatformDevice {
public:
virtual ~PlatformDevice() {}

#if defined(OS_MACOSX)
// The CGContext that corresponds to the bitmap, used for CoreGraphics
// operations drawing into the bitmap. This is possibly heavyweight, so it
// should exist only during one pass of rendering.
virtual CGContextRef GetBitmapContext(const SkMatrix& transform,
const SkIRect& clip_bounds) = 0;
#endif
virtual ~PlatformDevice();

private:
// The DC that corresponds to the bitmap, used for GDI operations drawing
// into the bitmap. This is possibly heavyweight, so it should be existant
// only during one pass of rendering.
virtual NativeDrawingContext BeginPlatformPaint(const SkMatrix& transform,
const SkIRect& clip_bounds);
const SkIRect& clip_bounds) = 0;

friend class ScopedPlatformPaint;
};
Expand Down
15 changes: 0 additions & 15 deletions skia/ext/platform_device_linux.cc

This file was deleted.

14 changes: 0 additions & 14 deletions skia/ext/platform_device_mac.cc

This file was deleted.

20 changes: 0 additions & 20 deletions skia/ext/platform_device_win.cc

This file was deleted.

3 changes: 2 additions & 1 deletion ui/gfx/canvas_paint_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
canvas->restoreToCount(1);

// Blit the dirty rect to the current context.
skia::ScopedPlatformPaint spp(canvas);
CGImageRef image =
CGBitmapContextCreateImage(skia::GetBitmapContext(*canvas));
CGBitmapContextCreateImage(spp.GetNativeDrawingContext());
CGRect dest_rect = NSRectToCGRect(rectangle_);

CGContextRef destination_context =
Expand Down

0 comments on commit 6b76da0

Please sign in to comment.